feat(scheduler-sim-diagnostics): wire info limit into REPL dispatch
repl_cmd_info() now recognizes "limit" as an info subcommand, routing to the already-implemented and tested repl_info_limit() with the same ntok<3 usage guard shape as the queue/worker/resource branches. Usage string and help text updated to list it. repl_info_limit()'s own body is untouched -- this is a pure, additive dispatch-wiring change. Two new tests drive it through the real repl_dispatch() entry point (not a direct call) for both `info limit <name>` and `info limit all`. `info limit <name|all>` is now reachable from a live REPL session -- scheduler-sim-diagnostics' first capability is functionally complete. Remaining: task 5 (determinism/regression validation). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
parent
4f60f148fb
commit
afe22d3122
4 changed files with 140 additions and 9 deletions
|
|
@ -272,6 +272,33 @@ static char* capture_info_limit(xce_sched_sim_driver_t* sim, const char* arg)
|
|||
return capture_stdout_around(run_info_limit_for_capture);
|
||||
}
|
||||
|
||||
/*
|
||||
* Captures the output of dispatching one REPL command line THROUGH THE REAL
|
||||
* repl_dispatch() entry point -- task 4's own dispatch-round-trip
|
||||
* requirement (unlike capture_info_limit() above, which calls
|
||||
* repl_info_limit() directly, bypassing repl_cmd_info()'s tokenization and
|
||||
* dispatch entirely). Same g_sim/g_line/run_for_capture()/capture() shape
|
||||
* as capture_info_limit() above, and the same pattern
|
||||
* test_repl_resource_table.c's/test_repl_breakpoints_inspection.c's own
|
||||
* capture_dispatch() already establish for this file family. Never a
|
||||
* "step"/"continue"/"quit" line (this helper does not expect
|
||||
* repl_dispatch() to return true).
|
||||
*/
|
||||
static xce_sched_sim_driver_t* g_dispatch_sim;
|
||||
static const char* g_dispatch_line;
|
||||
|
||||
static void run_dispatch_for_capture(void)
|
||||
{
|
||||
(void)repl_dispatch(g_dispatch_sim, g_dispatch_line);
|
||||
}
|
||||
|
||||
static char* capture_dispatch(xce_sched_sim_driver_t* sim, const char* line)
|
||||
{
|
||||
g_dispatch_sim = sim;
|
||||
g_dispatch_line = line;
|
||||
return capture_stdout_around(run_dispatch_for_capture);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Limit configuration fixture helpers */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
|
@ -1492,6 +1519,94 @@ test_info_limit_named_shows_no_active_usage_instance_when_host_scoped_vres_exist
|
|||
"scoped_vres_exists_but_no_worker_populated: PASS\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Task 4 (Requirement Set 1, Req 4.1/4.2): the first tests in this file to
|
||||
* drive `info limit <name>`/`info limit all` through the REAL repl_dispatch()
|
||||
* entry point (capture_dispatch(), above) instead of calling
|
||||
* repl_info_limit() directly (capture_info_limit(), used by every test
|
||||
* above this point) -- proving the `else if (strcmp(tokens[1], "limit") ==
|
||||
* 0)` dispatch branch this task adds to repl_cmd_info() (repl_info.c)
|
||||
* actually routes real typed-in REPL input to repl_info_limit(), not just
|
||||
* that repl_info_limit() itself works in isolation (already proven by every
|
||||
* test above). Before this task's GREEN phase, repl_cmd_info() has no
|
||||
* "limit" branch at all, so `tokens[1] == "limit"` falls into its own
|
||||
* unrecognized-subcommand else branch ("[sim] info: unrecognized subcommand
|
||||
* 'limit'") -- both assertions below are expected to fail at RED.
|
||||
*/
|
||||
static void test_info_limit_dispatch_named_reaches_repl_info_limit_via_real_dispatch(
|
||||
void)
|
||||
{
|
||||
xce_sched_sim_driver_t sim;
|
||||
xce_sched_plugin_t plugin;
|
||||
xce_scheduler_t group_sched;
|
||||
char* captured;
|
||||
int rc;
|
||||
|
||||
memset(&sim, 0, sizeof(sim));
|
||||
rc = xce_sched_core_init(&(sim.core));
|
||||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
|
||||
register_limit_plugin(&sim, &plugin, &group_sched);
|
||||
add_configured_limit(&plugin, "ug1_slots");
|
||||
|
||||
captured = capture_dispatch(&sim, "info limit ug1_slots");
|
||||
|
||||
TEST_ASSERT_NULL_MESSAGE(
|
||||
strstr(captured, "unrecognized subcommand"),
|
||||
"Req 4.1: 'info limit <name>' typed as real REPL input must be "
|
||||
"recognized -- repl_cmd_info() must route it to repl_info_limit(), "
|
||||
"not fall through to the unrecognized-subcommand branch");
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(
|
||||
strstr(captured, "limit: ug1_slots"),
|
||||
"Req 4.1: dispatching 'info limit ug1_slots' through repl_dispatch() "
|
||||
"must produce the same fmt_limit() dump a direct repl_info_limit() "
|
||||
"call already produces for this fixture");
|
||||
|
||||
free(captured);
|
||||
|
||||
printf("test_info_limit_dispatch_named_reaches_repl_info_limit_via_real_"
|
||||
"dispatch: PASS\n");
|
||||
}
|
||||
|
||||
static void
|
||||
test_info_limit_dispatch_all_reaches_repl_info_limit_via_real_dispatch(void)
|
||||
{
|
||||
xce_sched_sim_driver_t sim;
|
||||
xce_sched_plugin_t plugin;
|
||||
xce_scheduler_t group_sched;
|
||||
char* captured;
|
||||
int rc;
|
||||
|
||||
memset(&sim, 0, sizeof(sim));
|
||||
rc = xce_sched_core_init(&(sim.core));
|
||||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
|
||||
register_limit_plugin(&sim, &plugin, &group_sched);
|
||||
add_configured_limit(&plugin, "limitA");
|
||||
add_configured_limit(&plugin, "limitB");
|
||||
|
||||
captured = capture_dispatch(&sim, "info limit all");
|
||||
|
||||
TEST_ASSERT_NULL_MESSAGE(
|
||||
strstr(captured, "unrecognized subcommand"),
|
||||
"Req 4.2: 'info limit all' typed as real REPL input must be "
|
||||
"recognized -- repl_cmd_info() must route it to repl_info_limit(), "
|
||||
"not fall through to the unrecognized-subcommand branch");
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(
|
||||
strstr(captured, "limit: limitA"),
|
||||
"Req 4.2: dispatching 'info limit all' through repl_dispatch() must "
|
||||
"display every configured limit's setting, starting with limitA");
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(
|
||||
strstr(captured, "limit: limitB"),
|
||||
"Req 4.2: ... and limitB too -- every configured limit, not just "
|
||||
"one");
|
||||
|
||||
free(captured);
|
||||
|
||||
printf("test_info_limit_dispatch_all_reaches_repl_info_limit_via_real_"
|
||||
"dispatch: PASS\n");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
|
|
@ -1528,5 +1643,9 @@ int main(void)
|
|||
test_info_limit_named_shows_accounted_zero_for_host_with_capacity_but_never_charged);
|
||||
RUN_TEST(
|
||||
test_info_limit_named_shows_no_active_usage_instance_when_host_scoped_vres_exists_but_no_worker_populated);
|
||||
RUN_TEST(
|
||||
test_info_limit_dispatch_named_reaches_repl_info_limit_via_real_dispatch);
|
||||
RUN_TEST(
|
||||
test_info_limit_dispatch_all_reaches_repl_info_limit_via_real_dispatch);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue