feat(scheduler-sim-decision-trace): pass the scheduler log path to the simulation driver
Task 4.4: the --logfile path (or the default, now SCHED_DEFAULT_LOG_PATH) reaches the sim driver as an owned copy so the trace file checks can reject the scheduler log. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
aa4c43c897
commit
e01ffe4c9c
5 changed files with 118 additions and 2 deletions
|
|
@ -588,6 +588,77 @@ static void test_null_arguments_return_einval(void)
|
|||
printf("test_null_arguments_return_einval: PASS\n");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Test 6 (scheduler-sim-decision-trace task 4.4, Req 8.3): the driver */
|
||||
/* holds the scheduler log path it was started with -- its own copy, not */
|
||||
/* the caller's buffer -- or SCHED_DEFAULT_LOG_PATH (the same default */
|
||||
/* main.c logs to without --logfile) when none is given. The trace-file */
|
||||
/* checks compare a trace file against this path. */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static void test_driver_holds_configured_log_path(void)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
char log_path[PATH_MAX + 16];
|
||||
uint64_t snapshot_ts = 0;
|
||||
sched_sim_args_t args;
|
||||
xce_sched_sim_driver_t sim;
|
||||
int rc;
|
||||
|
||||
write_valid_fixture(path, sizeof(path), &snapshot_ts, "_logpath");
|
||||
snprintf(log_path, sizeof(log_path), "%s.sched.log", path);
|
||||
|
||||
memset(&args, 0, sizeof(args));
|
||||
args.replay_path = path;
|
||||
args.sim_start_ts = SCHED_SIM_START_TS_LATEST;
|
||||
args.log_path = log_path;
|
||||
|
||||
rc = sched_sim_driver_start(&sim, &args);
|
||||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(sim.log_path);
|
||||
TEST_ASSERT_EQUAL_STRING(log_path, sim.log_path);
|
||||
TEST_ASSERT_TRUE(sim.log_path != log_path); /* owned copy */
|
||||
|
||||
/* The caller's buffer going away must not change the driver's path. */
|
||||
memset(log_path, 'x', sizeof(log_path) - 1);
|
||||
TEST_ASSERT_EQUAL_STRING_LEN(path, sim.log_path, strlen(path));
|
||||
|
||||
xce_core_set_active_for_logging(NULL);
|
||||
sched_sim_driver_fini(&sim);
|
||||
TEST_ASSERT_NULL(sim.log_path);
|
||||
|
||||
printf("test_driver_holds_configured_log_path: PASS\n");
|
||||
}
|
||||
|
||||
static void test_driver_holds_default_log_path_when_none_given(void)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
uint64_t snapshot_ts = 0;
|
||||
sched_sim_args_t args;
|
||||
xce_sched_sim_driver_t sim;
|
||||
int rc;
|
||||
|
||||
write_valid_fixture(path, sizeof(path), &snapshot_ts, "_logdefault");
|
||||
|
||||
memset(&args, 0, sizeof(args));
|
||||
args.replay_path = path;
|
||||
args.sim_start_ts = SCHED_SIM_START_TS_LATEST;
|
||||
|
||||
rc = sched_sim_driver_start(&sim, &args);
|
||||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(sim.log_path);
|
||||
TEST_ASSERT_EQUAL_STRING(SCHED_DEFAULT_LOG_PATH, sim.log_path);
|
||||
TEST_ASSERT_EQUAL_STRING("/tmp/xce_scheduler.log", sim.log_path);
|
||||
|
||||
xce_core_set_active_for_logging(NULL);
|
||||
sched_sim_driver_fini(&sim);
|
||||
TEST_ASSERT_NULL(sim.log_path);
|
||||
|
||||
printf("test_driver_holds_default_log_path_when_none_given: PASS\n");
|
||||
}
|
||||
|
||||
/* Test 6 (sched_sim_driver_run() -- design.md's literal entry point --
|
||||
* calling start() then failing loudly with -ENOSYS pending the event loop)
|
||||
* was removed here: the event loop now exists (scheduler-core spec, task
|
||||
|
|
@ -607,6 +678,8 @@ int main(void)
|
|||
RUN_TEST(test_first_message_not_replayheader_fails_cleanly);
|
||||
RUN_TEST(test_missing_replay_file_fails_cleanly);
|
||||
RUN_TEST(test_null_arguments_return_einval);
|
||||
RUN_TEST(test_driver_holds_configured_log_path);
|
||||
RUN_TEST(test_driver_holds_default_log_path_when_none_given);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue