test(scheduler-controller-msg-gap): real handler/applier unit tests (bug-765 G-6)

The Task 9 tests were marked [x] but were stub/absent. Convert the
correctness-critical ones to real white-box tests, registered as meson tests
under --suite scheduler (leaks-off per convention):

- test_handlers.c (new) — #include ../src/handler.c; covers 9.2/9.3: each
  notify/dataset handler enqueues the correct op / skips NULL-empty / -EINVAL.
  Asserts the 5.6 fix (update_job -> UPDATE_JOB_FIELDS, not bulk UPDATE_JOB).
- test_job_update.c — add 9.5 (real sched_update_existing_queue, replacing the
  former local stub); already covers 9.4 (job) and 9.7 (rusage).
- meson.build — build + register all three scheduler test executables.

Suite GREEN: sched_test 15/15, sched_job_update_test 10/10,
sched_handlers_test 6/6; ASAN-clean.

Honest remaining: 9.6 dequeue worker-resvals APPLY is PARTIAL (enqueue tested;
apply is a dormant path, R-3); 9.8 is a documented compile-time absence check.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-06-19 04:14:20 +00:00
parent 080ff78a80
commit 276e26c37b
4 changed files with 270 additions and 7 deletions

View file

@ -295,6 +295,57 @@ test_rusage_null_returns_einval(void)
TEST_ASSERT_EQUAL_INT(-EINVAL, sched_apply_job_rusage(&sched, NULL));
}
/* Queue in-place update (Req 4 / task 9.5 — REAL, exercises the linked
* schedobj.c sched_update_existing_queue, not a local stub) */
static void
test_update_existing_queue_real(void)
{
xce_scheduler_t sched;
fixture_init(&sched);
xce_sched_queue_t* q = make_test_queue("q1", 1);
xce_queue_t upd;
memset(&upd, 0, sizeof(upd));
upd.queue = makeString("q1");
upd.status = 2;
upd.priority = 9;
upd.accept_interval = 5;
upd.sched_delay = 3;
upd.resreq = NULL; /* skip the resreq makeString branch */
int rc = sched_update_existing_queue(&sched, &upd);
TEST_ASSERT_EQUAL_INT(0, rc);
TEST_ASSERT_EQUAL_UINT(2, q->status);
TEST_ASSERT_EQUAL_INT(9, q->priority);
TEST_ASSERT_EQUAL_INT(5, q->accept_interval);
TEST_ASSERT_EQUAL_INT(3, q->sched_delay);
}
static void
test_update_unknown_queue_returns_enoent(void)
{
xce_scheduler_t sched;
fixture_init(&sched);
xce_queue_t upd;
memset(&upd, 0, sizeof(upd));
upd.queue = makeString("nope"); /* no such queue seeded */
TEST_ASSERT_EQUAL_INT(-ENOENT, sched_update_existing_queue(&sched, &upd));
}
static void
test_update_queue_null_returns_einval(void)
{
xce_scheduler_t sched;
fixture_init(&sched);
TEST_ASSERT_EQUAL_INT(-EINVAL, sched_update_existing_queue(&sched, NULL));
}
int main(int argc, char* argv[])
{
(void)argc; (void)argv;
@ -306,5 +357,8 @@ int main(int argc, char* argv[])
RUN_TEST(test_rusage_replace_frees_prior, 0);
RUN_TEST(test_rusage_unknown_job_returns_enoent, 0);
RUN_TEST(test_rusage_null_returns_einval, 0);
RUN_TEST(test_update_existing_queue_real, 0);
RUN_TEST(test_update_unknown_queue_returns_enoent, 0);
RUN_TEST(test_update_queue_null_returns_einval, 0);
return UNITY_END();
}