test(scheduler-core): normal-mode <-> simulation decision equivalence (task 11.6)

Chain the already-shipped recording (task 9.2) and sim-output (tasks
11.1-11.5) pipelines: record a synthetic multi-queue session through the
normal-mode driver, replay it through the simulation driver with
--sim-output, and assert the two .replay files' decisions match in full
structural content. This is the spec's central validation contract (Req 5
AC 7.1) -- if normal and simulation modes diverge, the core/driver
separation is broken.

Honestly scoped to PEND-only decisions: sim_loop.c's picker thread
(task 11.2) has no code path that can emit a live DISPATCH today, a
pre-existing gap that belongs to the not-yet-designed scheduler-allocation
spec, not something this task can close.
This commit is contained in:
Rongsong Shen 2026-08-07 03:28:29 +00:00
parent 564408e967
commit de00ccff37
Signed by: rshen
SSH key fingerprint: SHA256:8Vf2pZ3h6rJa7EhGK+WaAQ9Mta/apZvteW6g9U/WKKk
3 changed files with 771 additions and 1 deletions

View file

@ -610,6 +610,32 @@ sched_sim_record_output_test = executable(
dependencies: [scheduler_test_deps],
install: false)
# Contract test for deterministic replay and normal-to-simulation
# equivalence (scheduler-core spec, task 11.6, Req 5 AC 7.1) -- the spec's
# own central regression test: a synthetic scheduling session recorded
# through the REAL normal-mode driver (real builtin_fcfs picker + a
# stand-in allocator producing real PEND decisions via the same
# make_pend_decision()/make_pendreason() production constructors) is
# replayed through the REAL, unmodified simulation driver, and the two
# resulting `.replay` files' ReplaySession.decisions lists are asserted to
# match identically (same jobid, same pend reason content, per decision),
# while never comparing ReplayHeader or SessionSummary fields (AC 7.1's own
# "only non-decision metadata may differ" carve-out). First test file in
# this directory to combine BOTH the normal-mode driver stack and the full
# simulation stack in one TU -- see the test's own header comment for the
# combined white-box #include set (test_record_lifecycle.c's own set union
# test_sim_record_output.c's own set), the full stub surface, and why every
# decision in this fixture is PEND rather than a DISPATCH/PEND mix
# (sim_loop.c's sim_picker_thread_fn() can never emit a live DISPATCH today
# -- a documented, out-of-this-task's-scope gap, not a weakening of this
# test).
sched_sim_equivalence_test = executable(
'sched_sim_equivalence_test',
['test_sim_equivalence.c'],
include_directories:[incdir],
dependencies: [scheduler_test_deps],
install: false)
# Register as meson tests so `meson test --suite scheduler` runs them all.
# detect_leaks=0 matches the suite convention (fixtures are not torn down).
test('scheduler test', scheduler_test, suite: 'scheduler',
@ -697,3 +723,6 @@ test('scheduler sim alt events test',
test('scheduler sim record output test',
sched_sim_record_output_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler sim equivalence test',
sched_sim_equivalence_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])