test(scheduler-snapshot-job-allocation): regression test for allocator crash

Task 4.1: new test proving a snapshot-restored PENDING job (valid
resreq) reaches the real, live sched_allocator() thread's
sched_make_allocation() entry point without crashing -- the exact
bug-1569-class failure task 1.2 closed for the snapshot-load path.

New file (not an extension of test_snapshot_save_load.c) since driving
the real allocator needs scheduler.c's full dependency closure, too
heavy for that file's deliberately lean core-only TU. Follows the
already-established pattern from test_scheduler_connect.c /
test_scheduler_backpressure.c / test_scheduler_dispatch_commit.c: link
the real scheduler.c, wrap xcecli_start/xcecli_join, start a real
sched_init(), feed jobs directly into core.jbuf to drive the live
allocator thread. Wired into meson.build as a new executable/test.

Verified with two fault-injection experiments (reverted after):
disabling task 1.2's schedobj construction call makes this test fail
cleanly via its own assertion; going further and removing that
assertion reproduces a genuine ASAN-caught SEGV in the real allocator
path -- concrete proof this test would have caught bug-1569's failure
shape. Both polling loops (jbuf drain, decision wait) are bounded
(2s timeout, 5ms poll) -- no hang risk; confirmed non-flaky across 10
consecutive runs.

Requirements: 2.2, 2.4
This commit is contained in:
Rongsong Shen 2026-08-27 16:31:45 +00:00
parent f0fbebdeab
commit de6ad514e0
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
3 changed files with 487 additions and 1 deletions

View file

@ -53,7 +53,7 @@
- _Depends: 2.2_
- [ ] 4. Validation: close the reported symptom, prove no regressions, and keep documentation current
- [ ] 4.1 (P) Prove a restored pending job with a valid resource request can be evaluated for allocation without crashing
- [x] 4.1 (P) Prove a restored pending job with a valid resource request can be evaluated for allocation without crashing
- Load a saved state containing a pending job whose resource request parses successfully, then run that job through the scheduler's normal allocation-evaluation path.
- Assert no crash and no undefined behavior — this is the direct regression test for the scheduling-representation gap this feature closes. This does not cover a pending job whose resource request itself fails to parse on load — that pre-existing, separate failure path is explicitly out of this feature's boundary (see design.md's Known Limitation) and is not exercised by this test.
- Observable completion: the test passes cleanly under the project's memory-safety build configuration.