test(scheduler): fix wrong resInUse precondition in mem-reservation test (bug-1758)
test_job_rusage_reconciles_mem_reservation_against_usage asserted w->resInUse was already charged 4.0 for a JOBS_PUSH-dispatched RUN job, immediately after the push with no round boundary simulated. That assumption was wrong, not the scheduler: resInUse/sharedInUse is never charged incrementally at JOBS_PUSH/dispatch time. It's fully re-derived once per round by sched_account_jobs() (scheduler.c), which iterates every currently-RUN job and calls sched_charge_account() on each one's accounts -- called by both the real normal-mode driver (driver.c) and the sim driver (sim_loop.c), always before anything else in that round reads resInUse. Confirmed by reading the full JOBS_PUSH handler (core_events.c) and builtin_fcfs_on_job_push(): neither ever charges or uncharges resInUse, by design -- core_session.c's own doc comment on core_begin_session_internal() already documents this "recompute from source of truth each round" architecture. Fix: the test now calls sched_charge_account(&core, tracked->accounts) right after JOBS_PUSH, simulating the one round-boundary reconciliation step sched_account_jobs() would perform for its single RUN job (that function itself lives in scheduler.c, not white-box #included here, so its single-job effect is reproduced directly via the same primitive it calls internally). No production code changed. Full scheduler suite: 77/77 Ok (was 76/77). Full xce-build.sh all asan --incremental: 94/94 Ok, zero regressions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GLfB5uWRdmx2WiZSFC7Fm7
This commit is contained in:
parent
4b20590c80
commit
c832706e0c
1 changed files with 15 additions and 2 deletions
|
|
@ -1357,8 +1357,21 @@ static void test_job_rusage_reconciles_mem_reservation_against_usage(void)
|
|||
TEST_ASSERT_NOT_NULL(tracked);
|
||||
TEST_ASSERT_NOT_NULL(tracked->accounts);
|
||||
|
||||
/* Sanity: the reservation charge landed at dispatch time (before any
|
||||
* rusage tick), matching sched_charge_account()'s existing behavior. */
|
||||
/* bug-1758: JOBS_PUSH itself never charges resInUse -- by design, that
|
||||
* is sched_account_jobs()'s job (scheduler.c), a round-boundary
|
||||
* reconciliation the real normal-mode/sim drivers both call once per
|
||||
* round (driver.c/sim_loop.c), BEFORE anything in that round ever reads
|
||||
* resInUse, re-deriving it from every currently-RUN job's accounts via
|
||||
* sched_charge_account() -- see core.h's own doc comment on
|
||||
* sched_account_jobs(). This test's own JOBS_PUSH call above is not
|
||||
* itself a round boundary, so simulate the one sched_account_jobs()
|
||||
* would perform for this test's single RUN job directly (sched_account_
|
||||
* jobs() itself lives in scheduler.c, not white-box #included here --
|
||||
* this file already pulls in resource.c for sched_charge_account()). */
|
||||
sched_charge_account(&core, tracked->accounts);
|
||||
|
||||
/* Sanity: the reservation charge lands via that reconciliation, before
|
||||
* any rusage tick. */
|
||||
idx[0] = r_mem->idx;
|
||||
get_resvals(&(w->resInUse), 1, idx, val);
|
||||
TEST_ASSERT_EQUAL_FLOAT(4.0f, val[0]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue