feat: drive GC from sched_end_session — live_jobs mark, seq_cst fence, gc_sweep (6-8, 6-12)

This commit is contained in:
Rongsong Shen 2026-04-30 05:44:46 +00:00
parent 8cff4ac889
commit 5267d36a84
2 changed files with 121 additions and 1 deletions

View file

@ -196,6 +196,30 @@ test_meet_host_selection_always_false_fails(void)
sel_optimize_test_reset();
}
static void
test_gc_predicates_idle_invariant(void)
{
xce_scheduler_t sched;
memset(&sched, 0, sizeof(sched));
/* staging_merge_complete=1 means GC is safe to run */
atomic_store(&sched.staging_merge_complete, 1);
sel_optimize_set(1);
sel_node_table_init();
/* Verify the atomic fields are readable — testing the predicate contract */
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.session_active));
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.eval_in_progress));
TEST_ASSERT_EQUAL_INT(1, atomic_load(&sched.staging_merge_complete));
/* GC operations on an empty node table must not crash */
gc_clear_marks();
gc_sweep_select_nodes(NULL, 0);
sel_node_table_fini();
sel_optimize_test_reset();
}
#define TEST(x) \
do { \
if (check_test(&arguments, #x)) { \
@ -215,6 +239,7 @@ int main(int argc, char* argv[])
TEST(test_meet_host_selection_null_select_passes);
TEST(test_meet_host_selection_always_true_passes);
TEST(test_meet_host_selection_always_false_fails);
TEST(test_gc_predicates_idle_invariant);
return UNITY_END();
}