@@ -2187,13 +2187,69 @@ test_synthetic_with_bindings_weighted()
2187
2187
assert (sched_as_string[4 ] == " .AA.AA.AA.AA.A.______________________________" );
2188
2188
}
2189
2189
2190
+ static void
2191
+ test_synthetic_with_bindings_invalid ()
2192
+ {
2193
+ std::cerr << " \n ----------------\n Testing synthetic with invalid bindings\n " ;
2194
+ static constexpr memref_tid_t TID_A = 42 ;
2195
+ std::vector<trace_entry_t > refs_A = {
2196
+ /* clang-format off */
2197
+ make_thread (TID_A),
2198
+ make_pid (1 ),
2199
+ make_version (TRACE_ENTRY_VERSION),
2200
+ make_timestamp (1 ),
2201
+ make_instr (10 ),
2202
+ make_exit (TID_A),
2203
+ /* clang-format on */
2204
+ };
2205
+ {
2206
+ // Test negative bindings.
2207
+ static constexpr int NUM_OUTPUTS = 2 ;
2208
+ std::vector<scheduler_t ::input_reader_t > readers;
2209
+ readers.emplace_back (std::unique_ptr<mock_reader_t >(new mock_reader_t (refs_A)),
2210
+ std::unique_ptr<mock_reader_t >(new mock_reader_t ()), TID_A);
2211
+ std::vector<scheduler_t ::input_workload_t > sched_inputs;
2212
+ sched_inputs.emplace_back (std::move (readers));
2213
+ std::set<scheduler_t ::output_ordinal_t > cores;
2214
+ cores.insert ({ 1 , -1 });
2215
+ sched_inputs.back ().thread_modifiers .emplace_back (cores);
2216
+ scheduler_t ::scheduler_options_t sched_ops (scheduler_t ::MAP_TO_ANY_OUTPUT,
2217
+ scheduler_t ::DEPENDENCY_TIMESTAMPS,
2218
+ scheduler_t ::SCHEDULER_DEFAULTS,
2219
+ /* verbosity=*/ 3 );
2220
+ scheduler_t scheduler;
2221
+ assert (scheduler.init (sched_inputs, NUM_OUTPUTS, std::move (sched_ops)) ==
2222
+ scheduler_t ::STATUS_ERROR_INVALID_PARAMETER);
2223
+ }
2224
+ {
2225
+ // Test too-large bindings.
2226
+ static constexpr int NUM_OUTPUTS = 2 ;
2227
+ std::vector<scheduler_t ::input_reader_t > readers;
2228
+ readers.emplace_back (std::unique_ptr<mock_reader_t >(new mock_reader_t (refs_A)),
2229
+ std::unique_ptr<mock_reader_t >(new mock_reader_t ()), TID_A);
2230
+ std::vector<scheduler_t ::input_workload_t > sched_inputs;
2231
+ sched_inputs.emplace_back (std::move (readers));
2232
+ std::set<scheduler_t ::output_ordinal_t > cores;
2233
+ cores.insert ({ 1 , 3 });
2234
+ sched_inputs.back ().thread_modifiers .emplace_back (cores);
2235
+ scheduler_t ::scheduler_options_t sched_ops (scheduler_t ::MAP_TO_ANY_OUTPUT,
2236
+ scheduler_t ::DEPENDENCY_TIMESTAMPS,
2237
+ scheduler_t ::SCHEDULER_DEFAULTS,
2238
+ /* verbosity=*/ 3 );
2239
+ scheduler_t scheduler;
2240
+ assert (scheduler.init (sched_inputs, NUM_OUTPUTS, std::move (sched_ops)) ==
2241
+ scheduler_t ::STATUS_ERROR_INVALID_PARAMETER);
2242
+ }
2243
+ }
2244
+
2190
2245
static void
2191
2246
test_synthetic_with_bindings ()
2192
2247
{
2193
2248
test_synthetic_with_bindings_time (/* time_deps=*/ true );
2194
2249
test_synthetic_with_bindings_time (/* time_deps=*/ false );
2195
2250
test_synthetic_with_bindings_more_out ();
2196
2251
test_synthetic_with_bindings_weighted ();
2252
+ test_synthetic_with_bindings_invalid ();
2197
2253
}
2198
2254
2199
2255
static void
@@ -5676,13 +5732,14 @@ test_unscheduled_initially_rebalance()
5676
5732
// We need the initial runqueue assignment to be unbalanced.
5677
5733
// We achieve that by using input bindings.
5678
5734
// This relies on knowing the scheduler takes the 1st binding if there
5679
- // are any: so we can set to all cores and these will all pile up on output #0
5735
+ // are any if the bindings don't include all cores: so we can set to all-but-one
5736
+ // core and these will all pile up on output #0
5680
5737
// prior to the init-time rebalance. That makes output
5681
5738
// #0 big enough for a rebalance attempt, which causes scheduler init to fail
5682
5739
// without the i#7318 fix as it can only move one of those blocked inputs and
5683
5740
// so it hits an IDLE status on a later move attempt.
5684
5741
std::set<scheduler_t ::output_ordinal_t > cores;
5685
- cores.insert ({ 0 , 1 , 2 });
5742
+ cores.insert ({ 0 , 1 });
5686
5743
std::vector<scheduler_t ::input_workload_t > sched_inputs;
5687
5744
sched_inputs.emplace_back (std::move (readers));
5688
5745
sched_inputs.back ().thread_modifiers .emplace_back (cores);
@@ -7026,6 +7083,11 @@ test_main(int argc, const char *argv[])
7026
7083
// Avoid races with lazy drdecode init (b/279350357).
7027
7084
dr_standalone_init ();
7028
7085
7086
+ if (argc < 20 ) {
7087
+ test_synthetic_with_bindings_invalid ();
7088
+ test_unscheduled_initially_rebalance ();
7089
+ return 0 ;
7090
+ }
7029
7091
test_serial ();
7030
7092
test_parallel ();
7031
7093
test_param_checks ();
0 commit comments