feat(scheduler-sim-repl-verbosity): task 7.1 - RED-phase resource formatting tests
Adds 5 pure-function tests in a new test_repl_resource_formatting.c for repl_is_bytes_valued_resource()/repl_format_bytes_human() (classification, adaptive B/KB/MB/GB/TB/PB scaling including exact boundary values, swp's MB->bytes conversion), and 3 tests in test_repl_snapshot_params.c for set units raw|human|both parsing (Requirements 6.1-6.3). All fail as expected: link failure for the not-yet-existing helpers, compile failure for the not-yet-existing units_mode field/enum. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAWMhfRJFnmmnG8h97yUDd
This commit is contained in:
parent
da6ba96eb4
commit
11fe6194ce
4 changed files with 495 additions and 1 deletions
|
|
@ -21,6 +21,17 @@
|
|||
* one Observable that needs it" split test_repl_execution_control.c's own
|
||||
* header comment establishes.
|
||||
*
|
||||
* `set units raw|human|both` (scheduler-sim-repl-verbosity spec, task 7.1,
|
||||
* Requirement 6.2/6.3) is added below, alongside the existing `set speed`/
|
||||
* `set output`/`set verify` tests, per design.md's File Structure Plan
|
||||
* ("test_repl_snapshot_params.c -- extended with `set units raw|human|both`
|
||||
* parsing/validation tests ... alongside its existing `set speed`/`set
|
||||
* output`/`set verify` tests"). THIS SLICE IS RED-PHASE ONLY: neither
|
||||
* xce_sched_repl_state_s's `units_mode` field nor repl_cmd_set()'s `units`
|
||||
* branch exists yet (task 7.2, a separate later task, adds both) -- see
|
||||
* that test group's own header comment further below for the exact
|
||||
* build-failure shape this is expected to produce today.
|
||||
*
|
||||
* Fixture strategy and white-box #include set: identical to
|
||||
* test_repl_execution_control.c/test_repl_breakpoints_inspection.c (see
|
||||
* either file's own header comment) PLUS the new ../src/repl_params.c
|
||||
|
|
@ -776,6 +787,126 @@ static void test_set_output_opens_writes_preamble_and_off_closes(void)
|
|||
printf("test_set_output_opens_writes_preamble_and_off_closes: PASS\n");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Tests: `set units raw|human|both` (scheduler-sim-repl-verbosity spec, */
|
||||
/* task 7.1, Requirement 6.2/6.3). */
|
||||
/* */
|
||||
/* THESE THREE TESTS ARE RED-PHASE ONLY: neither xce_sched_repl_state_s's */
|
||||
/* `units_mode` field, the XCE_REPL_UNITS_RAW/HUMAN/BOTH enum constants, */
|
||||
/* nor repl_cmd_set()'s "units" branch exist anywhere in this codebase yet */
|
||||
/* -- task 7.2 (a separate, later task) adds all three. Referencing */
|
||||
/* `sim.repl_state->units_mode` and the enum constants below is therefore */
|
||||
/* expected to fail this file's COMPILATION (no member named 'units_mode', */
|
||||
/* undeclared identifiers) -- a build failure for the whole translation */
|
||||
/* unit, not merely a runtime assertion failure. That build failure IS this */
|
||||
/* slice's Observable evidence per tasks.md (task 7.1's own text: "the new */
|
||||
/* test cases fail against the current codebase, which has neither the */
|
||||
/* classifier/scaling helpers nor a `units` setting" -- a compile error is */
|
||||
/* a valid, and in this case the actual, form of "fail"). Once task 7.2 */
|
||||
/* lands the field/enum/branch, these same tests (unmodified) become the */
|
||||
/* GREEN-phase proof. */
|
||||
/* */
|
||||
/* Direct struct inspection (rs->units_mode) observes the setting rather */
|
||||
/* than routing through `info config`: today `info config` reports only */
|
||||
/* speed/output/verify/events_processed/current_ts/sessions
|
||||
* (test_info_config_reports_current_parameters below), it does not report
|
||||
* units_mode, and design.md's Traceability table never lists `info config`
|
||||
* as a Resource Value Formatter dependency -- extending it is out of this
|
||||
* task's scope (that belongs to task 8, the table-layout task). Direct
|
||||
* struct access is the same technique
|
||||
* test_set_speed_updates_shadow_and_core_atomics/
|
||||
* test_set_verify_toggles_flag already use for their own driver-state
|
||||
* fields (sim.sim_speed_num, sim.verify) above.
|
||||
*/
|
||||
|
||||
static void test_set_units_raw_human_both_update_display_mode(void)
|
||||
{
|
||||
xce_sched_sim_driver_t sim;
|
||||
bool handled;
|
||||
|
||||
memset(&sim, 0, sizeof(sim));
|
||||
sim.repl_state = repl_state_ensure(&sim);
|
||||
TEST_ASSERT_NOT_NULL(sim.repl_state);
|
||||
|
||||
handled = repl_cmd_set(&sim, "set units raw");
|
||||
TEST_ASSERT_FALSE_MESSAGE(handled, "`set` never hands control back");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(XCE_REPL_UNITS_RAW, sim.repl_state->units_mode,
|
||||
"`set units raw` must select the raw-only "
|
||||
"display mode");
|
||||
|
||||
handled = repl_cmd_set(&sim, "set units human");
|
||||
TEST_ASSERT_FALSE(handled);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(
|
||||
XCE_REPL_UNITS_HUMAN, sim.repl_state->units_mode,
|
||||
"`set units human` must select the human-only display mode");
|
||||
|
||||
handled = repl_cmd_set(&sim, "set units both");
|
||||
TEST_ASSERT_FALSE(handled);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(
|
||||
XCE_REPL_UNITS_BOTH, sim.repl_state->units_mode,
|
||||
"`set units both` must select the combined raw+human display mode");
|
||||
|
||||
printf("test_set_units_raw_human_both_update_display_mode: PASS\n");
|
||||
}
|
||||
|
||||
static void test_set_units_defaults_to_both_without_explicit_command(void)
|
||||
{
|
||||
xce_sched_sim_driver_t sim;
|
||||
|
||||
memset(&sim, 0, sizeof(sim));
|
||||
sim.repl_state = repl_state_ensure(&sim);
|
||||
TEST_ASSERT_NOT_NULL(sim.repl_state);
|
||||
|
||||
TEST_ASSERT_EQUAL_MESSAGE(
|
||||
XCE_REPL_UNITS_BOTH, sim.repl_state->units_mode,
|
||||
"absent an explicit `set units` command, units_mode must default "
|
||||
"to `both` (Requirement 6.3) -- design.md's own State Management "
|
||||
"section calls this out explicitly as the one field in this struct "
|
||||
"that cannot rely on calloc's zero-initialization alone (unless "
|
||||
"`both` is deliberately given enum value 0), so repl_state_ensure() "
|
||||
"must set it explicitly");
|
||||
|
||||
printf(
|
||||
"test_set_units_defaults_to_both_without_explicit_command: PASS\n");
|
||||
}
|
||||
|
||||
static xce_sched_sim_driver_t g_units_invalid_sim;
|
||||
|
||||
static void run_set_units_bogus(void)
|
||||
{
|
||||
repl_cmd_set(&g_units_invalid_sim, "set units bogus");
|
||||
}
|
||||
|
||||
static void test_set_units_invalid_value_rejected_like_existing_pattern(void)
|
||||
{
|
||||
char* captured;
|
||||
|
||||
memset(&g_units_invalid_sim, 0, sizeof(g_units_invalid_sim));
|
||||
g_units_invalid_sim.repl_state = repl_state_ensure(&g_units_invalid_sim);
|
||||
TEST_ASSERT_NOT_NULL(g_units_invalid_sim.repl_state);
|
||||
|
||||
captured = capture_stdout_around(run_set_units_bogus);
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(
|
||||
strstr(captured, "set units"),
|
||||
"an unrecognized `set units` value must be rejected with a "
|
||||
"units-specific usage message -- matching `set speed`'s "
|
||||
"\"[sim] set speed: usage: set speed <N>\" and `set verify`'s "
|
||||
"\"[sim] set verify: usage: set verify on|off\" per-key "
|
||||
"usage-error pattern (repl_params.c), NOT the generic \"[sim] set: "
|
||||
"unrecognized parameter 'units'\" message that fires today for an "
|
||||
"unrecognized KEY (units IS a recognized key once task 7.2 lands; "
|
||||
"only its VALUE here is invalid)");
|
||||
TEST_ASSERT_EQUAL_MESSAGE(
|
||||
XCE_REPL_UNITS_BOTH, g_units_invalid_sim.repl_state->units_mode,
|
||||
"a rejected `set units` value must leave the current display mode "
|
||||
"unchanged -- same discipline `set speed`/`set verify`'s own "
|
||||
"malformed-input tests already establish for their own fields");
|
||||
free(captured);
|
||||
|
||||
printf("test_set_units_invalid_value_rejected_like_existing_pattern: "
|
||||
"PASS\n");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Test: `info config` reports speed/output/verify/events_processed/ */
|
||||
/* current_ts/sessions, both while output is off and while it is active */
|
||||
|
|
@ -863,6 +994,9 @@ int main(void)
|
|||
RUN_TEST(test_set_speed_updates_shadow_and_core_atomics);
|
||||
RUN_TEST(test_set_verify_toggles_flag);
|
||||
RUN_TEST(test_set_output_opens_writes_preamble_and_off_closes);
|
||||
RUN_TEST(test_set_units_raw_human_both_update_display_mode);
|
||||
RUN_TEST(test_set_units_defaults_to_both_without_explicit_command);
|
||||
RUN_TEST(test_set_units_invalid_value_rejected_like_existing_pattern);
|
||||
RUN_TEST(test_info_config_reports_current_parameters);
|
||||
RUN_TEST(test_help_lists_snapshot_and_set_commands);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue