From 8931833132479396379bb431db338c4cd2410c77 Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Thu, 8 Oct 2026 14:56:31 +0000 Subject: [PATCH] feat(scheduler-sim-decision-trace): compile trace sources into REPL/sim tests and the sim isolation checks Task 5.1: the 26 white-box tests that include repl.c or sim_loop.c now include the REPL trace sources (and the core trace sources where no hooked source brings them); sched_sim_isolation_lib carries all trace sources and the sim isolation test scans the REPL trace files. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../scheduler-sim-decision-trace/tasks.md | 3 +- src/scheduler/meson.build | 15 ++++- src/scheduler/testsuite/meson.build | 18 ++++++ .../test_maxtasks_wiring_sim_driver_parity.c | 10 ++++ .../test_repl_breakpoints_inspection.c | 10 ++++ .../testsuite/test_repl_equivalence.c | 10 ++++ .../testsuite/test_repl_event_echo.c | 10 ++++ .../testsuite/test_repl_execution_control.c | 10 ++++ src/scheduler/testsuite/test_repl_help.c | 10 ++++ .../testsuite/test_repl_limit_table.c | 10 ++++ .../testsuite/test_repl_prompt_context.c | 10 ++++ .../testsuite/test_repl_resource_table.c | 10 ++++ .../testsuite/test_repl_round_rollup.c | 10 ++++ .../testsuite/test_repl_snapshot_params.c | 10 ++++ .../testsuite/test_repl_step_verbosity.c | 10 ++++ src/scheduler/testsuite/test_sim_alt_events.c | 10 ++++ .../testsuite/test_sim_contention_parity.c | 5 ++ .../testsuite/test_sim_discrete_clock.c | 10 ++++ .../test_sim_e2e_original_motivation.c | 5 ++ .../testsuite/test_sim_equivalence.c | 5 ++ src/scheduler/testsuite/test_sim_event_loop.c | 10 ++++ src/scheduler/testsuite/test_sim_isolation.c | 55 +++++++++++++++++-- .../testsuite/test_sim_print_decision_gate.c | 10 ++++ .../test_sim_reconcile_unaccounted.c | 5 ++ .../testsuite/test_sim_record_output.c | 10 ++++ .../testsuite/test_sim_resource_contention.c | 5 ++ .../test_sim_round_boundary_reconciliation.c | 5 ++ .../testsuite/test_sim_session_ordering.c | 5 ++ .../test_sim_snapshot_reconcile_gap.c | 10 ++++ src/scheduler/testsuite/test_sim_verify.c | 10 ++++ 30 files changed, 310 insertions(+), 6 deletions(-) diff --git a/.kiro/specs/scheduler-sim-decision-trace/tasks.md b/.kiro/specs/scheduler-sim-decision-trace/tasks.md index 0462a1d2..cc17ea62 100644 --- a/.kiro/specs/scheduler-sim-decision-trace/tasks.md +++ b/.kiro/specs/scheduler-sim-decision-trace/tasks.md @@ -269,7 +269,7 @@ - _Requirements: 1.6, 7.1, 7.2, 7.3, 8.1, 8.5_ - [ ] 5. Wire the trace into the REPL and the simulation driver -- [ ] 5.1 Make every white-box test that includes REPL or simulation sources compile the trace sources, and register the trace REPL sources with the simulation isolation checks +- [x] 5.1 Make every white-box test that includes REPL or simulation sources compile the trace sources, and register the trace REPL sources with the simulation isolation checks - Add the trace control, store and renderer sources to the simulation isolation library and to the simulation isolation test's scan list. - Find the tests with the design's full include-pattern search. To the 26 tests that include the REPL or simulation-loop sources, add the trace REPL sources. - Of those 26, 19 include no hooked source, so they also get the trace model and capture sources. Where the capture source needs a scheduler source those tests do not already include, add it or provide a stub, and list it in the task notes. @@ -370,3 +370,4 @@ - 4.4: the driver holds its own copy of the scheduler log path in `sim->log_path` (from `sched_sim_args_t.log_path`, else `SCHED_DEFAULT_LOG_PATH` in sim.h, "/tmp/xce_scheduler.log"). The log is always open in sim mode, so 4.5 can `stat(sim->log_path)` for its dev/ino same-file check. - 4.5: the trace FILE* and its dev/ino belong to the refcounted settings, and the last unref flushes and closes it. New functions in repl_internal.h: `repl_trace_settings_file()`, `repl_trace_file_conflicts(sim, path)` (5.2 wires it into `set output`) and `repl_trace_shutdown(sim)` (5.2 calls it on quit/EOF). Shutdown clears core.trace_ctl, releases cur/next, then calls store_fini, which memsets the trace state, so keep that order. 4.6 must emit only through `cur`'s file while it still holds `cur`, and flush after every record, because two append streams may share one file. - 4.6: the session hooks and emitter are in repl_trace_emit.c: `repl_trace_session_begin/end(sim)` and `repl_trace_on_decision/on_trace_only(sim, d)`, declared in repl_internal.h. `sim_print_decision` is now exported from sim.h. Session begin stamps `session_no = rs->session_count`, which sim_loop.c increments in `xce_repl_check_begin_round` before `xce_core_begin_session`. 5.3 must call session_begin after a successful begin-session and before signal_go/reconciliation, and session_end after the decision stream ends. Emission moves the record to the store (d->trace=NULL); write errors are reported once per session. policy_name is not stamped; capture falls back to the core picker. repl_trace_emit.c is not yet in sched_sim_isolation_lib or its scan (5.1). +- 5.1: all 26 tests that include repl.c/sim_loop.c now `#include` the five REPL trace sources (repl_trace_render.c, repl_trace_render_outcome.c, repl_trace_store.c, repl_trace.c, repl_trace_emit.c) and the four core trace sources, exactly once. sched_sim_isolation_lib carries all nine trace sources. test_sim_isolation.c's `test_sim_trace_repl_sources_are_isolated` scans the REPL trace files plus repl_trace_render.h; stdio is allowed there, controller symbols are not. A new REPL trace file must be added to the 26 tests, the lib and the scan. test_sim_startup.c includes only sim.c, so if sim.c starts calling trace code it needs the sources too. diff --git a/src/scheduler/meson.build b/src/scheduler/meson.build index 9921b6d2..8e5b080c 100644 --- a/src/scheduler/meson.build +++ b/src/scheduler/meson.build @@ -169,12 +169,25 @@ sched_core_isolation_lib = static_library( # object references zero controller-facing symbols (register_seqjob_ # allocator()/register_parjob_allocator(), plugins/seqjob_allocator.c and # plugins/parjob_allocator.c, touch only core-scoped resource/worker state). +# scheduler-sim-decision-trace task 5.1 adds the REPL trace sources +# (repl_trace.c, repl_trace_store.c, repl_trace_render.c, +# repl_trace_render_outcome.c, repl_trace_emit.c), which +# test_sim_isolation.c also text-scans, and the four core trace sources +# (sched_trace*.c). The core ones are here because sched_election.c (hooked +# by task 3.1) and repl_trace_store.c call them, so by the same "cover every +# file the driver calls" rule their undefined symbols belong in the nm(1) +# check; their text scan (forbidden headers/symbols plus no stdio) stays in +# test_core_isolation.c and is not repeated here. sched_sim_isolation_lib = static_library( 'sched_sim_isolation', ['src/sim.c', 'src/sim_loop.c', 'src/sim_picker.c', 'src/sim_limit.c', 'src/sim_alloc.c', 'src/sim_record.c', 'src/repl.c', 'src/repl_fmt.c', 'src/repl_break.c', 'src/repl_info.c', 'src/repl_params.c', - 'src/repl_rollup.c', 'src/sched_election.c'], + 'src/repl_rollup.c', 'src/repl_trace.c', 'src/repl_trace_store.c', + 'src/repl_trace_render.c', 'src/repl_trace_render_outcome.c', + 'src/repl_trace_emit.c', 'src/sched_election.c', 'src/sched_trace.c', + 'src/sched_trace_scan.c', 'src/sched_trace_capture.c', + 'src/sched_trace_outcome.c'], include_directories: incdir, dependencies: scheduler_deps, install: false) diff --git a/src/scheduler/testsuite/meson.build b/src/scheduler/testsuite/meson.build index b68e7f22..903e2a2e 100644 --- a/src/scheduler/testsuite/meson.build +++ b/src/scheduler/testsuite/meson.build @@ -683,6 +683,24 @@ sched_sim_isolation_test = executable( '-DXCE_SIM_REPL_FMT_C_PATH="' + (meson.current_source_dir() / '..' / 'src' / 'repl_fmt.c') + '"', + '-DXCE_SIM_REPL_TRACE_C_PATH="' + + (meson.current_source_dir() / '..' / 'src' / 'repl_trace.c') + + '"', + '-DXCE_SIM_REPL_TRACE_STORE_C_PATH="' + + (meson.current_source_dir() / '..' / 'src' / 'repl_trace_store.c') + + '"', + '-DXCE_SIM_REPL_TRACE_RENDER_C_PATH="' + + (meson.current_source_dir() / '..' / 'src' / 'repl_trace_render.c') + + '"', + '-DXCE_SIM_REPL_TRACE_RENDER_OUTCOME_C_PATH="' + + (meson.current_source_dir() / '..' / 'src' / 'repl_trace_render_outcome.c') + + '"', + '-DXCE_SIM_REPL_TRACE_RENDER_H_PATH="' + + (meson.current_source_dir() / '..' / 'src' / 'repl_trace_render.h') + + '"', + '-DXCE_SIM_REPL_TRACE_EMIT_C_PATH="' + + (meson.current_source_dir() / '..' / 'src' / 'repl_trace_emit.c') + + '"', '-DXCE_SIM_LIB_PATH="' + sched_sim_isolation_lib.full_path() + '"'], diff --git a/src/scheduler/testsuite/test_maxtasks_wiring_sim_driver_parity.c b/src/scheduler/testsuite/test_maxtasks_wiring_sim_driver_parity.c index 367b7cdd..c9fbd324 100644 --- a/src/scheduler/testsuite/test_maxtasks_wiring_sim_driver_parity.c +++ b/src/scheduler/testsuite/test_maxtasks_wiring_sim_driver_parity.c @@ -145,6 +145,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" diff --git a/src/scheduler/testsuite/test_repl_breakpoints_inspection.c b/src/scheduler/testsuite/test_repl_breakpoints_inspection.c index 13d891ab..4a89455c 100644 --- a/src/scheduler/testsuite/test_repl_breakpoints_inspection.c +++ b/src/scheduler/testsuite/test_repl_breakpoints_inspection.c @@ -85,6 +85,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_repl_equivalence.c b/src/scheduler/testsuite/test_repl_equivalence.c index afa2f7bd..788def76 100644 --- a/src/scheduler/testsuite/test_repl_equivalence.c +++ b/src/scheduler/testsuite/test_repl_equivalence.c @@ -144,6 +144,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_repl_event_echo.c b/src/scheduler/testsuite/test_repl_event_echo.c index ebc0e4a7..58acca41 100644 --- a/src/scheduler/testsuite/test_repl_event_echo.c +++ b/src/scheduler/testsuite/test_repl_event_echo.c @@ -102,6 +102,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_repl_execution_control.c b/src/scheduler/testsuite/test_repl_execution_control.c index 6004b149..ee694333 100644 --- a/src/scheduler/testsuite/test_repl_execution_control.c +++ b/src/scheduler/testsuite/test_repl_execution_control.c @@ -99,6 +99,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_repl_help.c b/src/scheduler/testsuite/test_repl_help.c index b8645406..292c0211 100644 --- a/src/scheduler/testsuite/test_repl_help.c +++ b/src/scheduler/testsuite/test_repl_help.c @@ -94,6 +94,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_repl_limit_table.c b/src/scheduler/testsuite/test_repl_limit_table.c index 26fae20a..e9985b25 100644 --- a/src/scheduler/testsuite/test_repl_limit_table.c +++ b/src/scheduler/testsuite/test_repl_limit_table.c @@ -89,6 +89,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_repl_prompt_context.c b/src/scheduler/testsuite/test_repl_prompt_context.c index 480126ed..51d377c3 100644 --- a/src/scheduler/testsuite/test_repl_prompt_context.c +++ b/src/scheduler/testsuite/test_repl_prompt_context.c @@ -98,6 +98,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" diff --git a/src/scheduler/testsuite/test_repl_resource_table.c b/src/scheduler/testsuite/test_repl_resource_table.c index 882cfd08..822bf660 100644 --- a/src/scheduler/testsuite/test_repl_resource_table.c +++ b/src/scheduler/testsuite/test_repl_resource_table.c @@ -65,6 +65,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_repl_round_rollup.c b/src/scheduler/testsuite/test_repl_round_rollup.c index 9b4d62f5..f24df586 100644 --- a/src/scheduler/testsuite/test_repl_round_rollup.c +++ b/src/scheduler/testsuite/test_repl_round_rollup.c @@ -61,6 +61,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_repl_snapshot_params.c b/src/scheduler/testsuite/test_repl_snapshot_params.c index d1607845..8b0e73e0 100644 --- a/src/scheduler/testsuite/test_repl_snapshot_params.c +++ b/src/scheduler/testsuite/test_repl_snapshot_params.c @@ -75,6 +75,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_repl_step_verbosity.c b/src/scheduler/testsuite/test_repl_step_verbosity.c index ecafa8a1..f20a1bba 100644 --- a/src/scheduler/testsuite/test_repl_step_verbosity.c +++ b/src/scheduler/testsuite/test_repl_step_verbosity.c @@ -115,6 +115,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_sim_alt_events.c b/src/scheduler/testsuite/test_sim_alt_events.c index fa55f531..df4a52ec 100644 --- a/src/scheduler/testsuite/test_sim_alt_events.c +++ b/src/scheduler/testsuite/test_sim_alt_events.c @@ -92,6 +92,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_sim_contention_parity.c b/src/scheduler/testsuite/test_sim_contention_parity.c index 316a1067..19cdc444 100644 --- a/src/scheduler/testsuite/test_sim_contention_parity.c +++ b/src/scheduler/testsuite/test_sim_contention_parity.c @@ -205,6 +205,11 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/resource.c" /* Hooked sources compile SCHED_TRACE bodies (scheduler-sim-decision-trace). */ #include "../src/sched_trace.c" diff --git a/src/scheduler/testsuite/test_sim_discrete_clock.c b/src/scheduler/testsuite/test_sim_discrete_clock.c index 43e59697..7288268f 100644 --- a/src/scheduler/testsuite/test_sim_discrete_clock.c +++ b/src/scheduler/testsuite/test_sim_discrete_clock.c @@ -78,6 +78,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" diff --git a/src/scheduler/testsuite/test_sim_e2e_original_motivation.c b/src/scheduler/testsuite/test_sim_e2e_original_motivation.c index 105acbb4..eb188122 100644 --- a/src/scheduler/testsuite/test_sim_e2e_original_motivation.c +++ b/src/scheduler/testsuite/test_sim_e2e_original_motivation.c @@ -199,6 +199,11 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/resource.c" /* Hooked sources compile SCHED_TRACE bodies (scheduler-sim-decision-trace). */ #include "../src/sched_trace.c" diff --git a/src/scheduler/testsuite/test_sim_equivalence.c b/src/scheduler/testsuite/test_sim_equivalence.c index a6bd5211..f796ca02 100644 --- a/src/scheduler/testsuite/test_sim_equivalence.c +++ b/src/scheduler/testsuite/test_sim_equivalence.c @@ -205,6 +205,11 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_sim_event_loop.c b/src/scheduler/testsuite/test_sim_event_loop.c index 05f53097..8bdbe178 100644 --- a/src/scheduler/testsuite/test_sim_event_loop.c +++ b/src/scheduler/testsuite/test_sim_event_loop.c @@ -108,6 +108,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_sim_isolation.c b/src/scheduler/testsuite/test_sim_isolation.c index 8caad713..ba906bb1 100644 --- a/src/scheduler/testsuite/test_sim_isolation.c +++ b/src/scheduler/testsuite/test_sim_isolation.c @@ -124,9 +124,20 @@ #error \ "XCE_SIM_REPL_PARAMS_C_PATH must be defined by meson.build to repl_params.c's absolute path" #endif +/* Task 5.1 (scheduler-sim-decision-trace, Req 11.3): the REPL trace + * sources and the renderer's private header. */ +#if !defined(XCE_SIM_REPL_TRACE_C_PATH) \ + || !defined(XCE_SIM_REPL_TRACE_STORE_C_PATH) \ + || !defined(XCE_SIM_REPL_TRACE_RENDER_C_PATH) \ + || !defined(XCE_SIM_REPL_TRACE_RENDER_OUTCOME_C_PATH) \ + || !defined(XCE_SIM_REPL_TRACE_RENDER_H_PATH) \ + || !defined(XCE_SIM_REPL_TRACE_EMIT_C_PATH) +#error \ + "XCE_SIM_REPL_TRACE_*_PATH must be defined by meson.build to the absolute paths of the repl_trace*.c sources and repl_trace_render.h" +#endif #ifndef XCE_SIM_LIB_PATH #error \ - "XCE_SIM_LIB_PATH must be defined by meson.build to the absolute path of sim.c+sim_loop.c+sim_picker.c+sim_record.c+repl.c+repl_break.c+repl_info.c+repl_params.c's isolated static_library() archive" + "XCE_SIM_LIB_PATH must be defined by meson.build to the absolute path of the sched_sim_isolation_lib static_library() archive (its sources are listed in src/scheduler/meson.build)" #endif /* Forbidden headers (design.md "Allowed Dependencies", same list @@ -657,6 +668,42 @@ static void test_sim_never_calls_forbidden_symbols(void) free(repl_fmt_c); } +/* + * test_sim_trace_repl_sources_are_isolated - the REPL trace sources + * (control, store, renderer, emitter) are part of the simulation driver: + * each one must be readable, include no forbidden header and name no + * controller-facing symbol. They may use stdio (the REPL prints), unlike + * the core trace sources test_core_isolation.c scans. + */ +static void test_sim_trace_repl_sources_are_isolated(void) +{ + static const char* const paths[] = { + XCE_SIM_REPL_TRACE_C_PATH, + XCE_SIM_REPL_TRACE_STORE_C_PATH, + XCE_SIM_REPL_TRACE_RENDER_C_PATH, + XCE_SIM_REPL_TRACE_RENDER_OUTCOME_C_PATH, + XCE_SIM_REPL_TRACE_RENDER_H_PATH, + XCE_SIM_REPL_TRACE_EMIT_C_PATH, + }; + size_t i; + + for (i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) { + char* raw = read_whole_file(paths[i]); + char* stripped; + + TEST_ASSERT_NOT_NULL_MESSAGE(raw, paths[i]); + stripped = strip_c_comments(raw); + TEST_ASSERT_NOT_NULL_MESSAGE(stripped, paths[i]); + TEST_ASSERT_TRUE_MESSAGE(stripped[0] != '\0', paths[i]); + + assert_no_forbidden_includes(stripped, paths[i]); + assert_no_forbidden_symbols(stripped, paths[i]); + + free(raw); + free(stripped); + } +} + /* * test_sim_driver_struct_has_no_forbidden_fields - Req 5 AC 17's * "confirmed by the struct definition itself, not runtime checks alone" @@ -730,9 +777,8 @@ static void test_sim_object_has_no_forbidden_undefined_symbols(void) /* posix format for an undefined symbol: " U" (no * value/size columns). Skip anything that doesn't parse as * exactly that -- e.g. a blank line, or an archive member header - * some nm versions print (this archive has eight member objects, - * sim.c.o, sim_loop.c.o, sim_picker.c.o, sim_record.c.o, repl.c.o, - * repl_break.c.o, repl_info.c.o, and repl_params.c.o). */ + * some nm versions print (this archive has one member object per + * source in sched_sim_isolation_lib, src/scheduler/meson.build). */ if (sscanf(line, "%511s %c", symbol, &type) != 2) { continue; } @@ -779,6 +825,7 @@ int main(void) RUN_TEST(test_sim_source_paths_are_readable); RUN_TEST(test_sim_never_includes_forbidden_headers); RUN_TEST(test_sim_never_calls_forbidden_symbols); + RUN_TEST(test_sim_trace_repl_sources_are_isolated); RUN_TEST(test_sim_driver_struct_has_no_forbidden_fields); RUN_TEST(test_sim_object_has_no_forbidden_undefined_symbols); return UNITY_END(); diff --git a/src/scheduler/testsuite/test_sim_print_decision_gate.c b/src/scheduler/testsuite/test_sim_print_decision_gate.c index 3b9a08f1..5bdabd12 100644 --- a/src/scheduler/testsuite/test_sim_print_decision_gate.c +++ b/src/scheduler/testsuite/test_sim_print_decision_gate.c @@ -120,6 +120,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_sim_reconcile_unaccounted.c b/src/scheduler/testsuite/test_sim_reconcile_unaccounted.c index c5710210..6f5701b8 100644 --- a/src/scheduler/testsuite/test_sim_reconcile_unaccounted.c +++ b/src/scheduler/testsuite/test_sim_reconcile_unaccounted.c @@ -136,6 +136,11 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/resource.c" /* Hooked sources compile SCHED_TRACE bodies (scheduler-sim-decision-trace). */ #include "../src/sched_trace.c" diff --git a/src/scheduler/testsuite/test_sim_record_output.c b/src/scheduler/testsuite/test_sim_record_output.c index f8e4bc94..d010a47a 100644 --- a/src/scheduler/testsuite/test_sim_record_output.c +++ b/src/scheduler/testsuite/test_sim_record_output.c @@ -79,6 +79,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_sim_resource_contention.c b/src/scheduler/testsuite/test_sim_resource_contention.c index 57043281..b8e10bf8 100644 --- a/src/scheduler/testsuite/test_sim_resource_contention.c +++ b/src/scheduler/testsuite/test_sim_resource_contention.c @@ -143,6 +143,11 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/resource.c" /* Hooked sources compile SCHED_TRACE bodies (scheduler-sim-decision-trace). */ #include "../src/sched_trace.c" diff --git a/src/scheduler/testsuite/test_sim_round_boundary_reconciliation.c b/src/scheduler/testsuite/test_sim_round_boundary_reconciliation.c index 7f3ed724..20e3445a 100644 --- a/src/scheduler/testsuite/test_sim_round_boundary_reconciliation.c +++ b/src/scheduler/testsuite/test_sim_round_boundary_reconciliation.c @@ -111,6 +111,11 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/resource.c" /* Hooked sources compile SCHED_TRACE bodies (scheduler-sim-decision-trace). */ #include "../src/sched_trace.c" diff --git a/src/scheduler/testsuite/test_sim_session_ordering.c b/src/scheduler/testsuite/test_sim_session_ordering.c index 7cd21a25..9a75aef4 100644 --- a/src/scheduler/testsuite/test_sim_session_ordering.c +++ b/src/scheduler/testsuite/test_sim_session_ordering.c @@ -149,6 +149,11 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_sim_snapshot_reconcile_gap.c b/src/scheduler/testsuite/test_sim_snapshot_reconcile_gap.c index c4451791..10c6120d 100644 --- a/src/scheduler/testsuite/test_sim_snapshot_reconcile_gap.c +++ b/src/scheduler/testsuite/test_sim_snapshot_reconcile_gap.c @@ -98,6 +98,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */ diff --git a/src/scheduler/testsuite/test_sim_verify.c b/src/scheduler/testsuite/test_sim_verify.c index 3fe74548..9041c297 100644 --- a/src/scheduler/testsuite/test_sim_verify.c +++ b/src/scheduler/testsuite/test_sim_verify.c @@ -101,6 +101,16 @@ #include "../src/repl_break.c" #include "../src/repl_info.c" #include "../src/repl_params.c" +/* 5.1: the REPL trace sources below call the trace model. */ +#include "../src/sched_trace.c" +#include "../src/sched_trace_scan.c" +#include "../src/sched_trace_capture.c" +#include "../src/sched_trace_outcome.c" +#include "../src/repl_trace_render.c" +#include "../src/repl_trace_render_outcome.c" +#include "../src/repl_trace_store.c" +#include "../src/repl_trace.c" +#include "../src/repl_trace_emit.c" #include "../src/sim.c" #include "../src/sim_loop.c" #include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */