feat(scheduler-core): extract xce_sched_core_t from monolithic scheduler struct (task 4.1)
Splits xce_scheduler_t along the controller-I/O seam: xce_sched_core_t
(new core.h/core.c) now holds all scheduling state (jobs/queues/workers/
users/projects/resource managers/plugins/three-thread-cbuf pipeline),
while xce_scheduler_t shrinks to {core; apictx; cluster_cfg}. Proven via
an nm-based link-time isolation test (zero netio/xcecli/idgen/delaymgr
symbols reachable from core.c) plus a reproducible wall-clock-call guard.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019dw5WnN3DXStaEaPYfACU1
This commit is contained in:
parent
604a564904
commit
7c229284e2
26 changed files with 1233 additions and 661 deletions
|
|
@ -175,6 +175,34 @@ sched_pendreason_factory_audit_test = executable(
|
|||
+ '"'],
|
||||
install: false)
|
||||
|
||||
# Regression guard for task 4.1's Observable (scheduler-core spec, Req
|
||||
# 5.1/5.2): "the core structure compiles and links with zero symbols from
|
||||
# the networking/API libraries ... a build-time or link-time check
|
||||
# confirms this." Same source-text-scan genre as
|
||||
# sched_picker_core_loop_boundary_test / sched_pendreason_factory_audit_test
|
||||
# above, PLUS a genuine link-time proof: it inspects the undefined-symbol
|
||||
# table (via nm(1)) of sched_core_isolation_lib (defined in the parent
|
||||
# meson.build -- core.c compiled alone, isolated from the rest of the
|
||||
# scheduler). link_with establishes the build-order dependency so that
|
||||
# archive exists before this test runs; XCE_CORE_LIB_PATH bakes in its
|
||||
# absolute path the same way XCE_SCHEDULER_C_PATH does above.
|
||||
sched_core_isolation_test = executable(
|
||||
'sched_core_isolation_test',
|
||||
['test_core_isolation.c'],
|
||||
include_directories:[incdir],
|
||||
dependencies: [scheduler_test_deps],
|
||||
link_with: [sched_core_isolation_lib],
|
||||
c_args: ['-DXCE_CORE_H_PATH="'
|
||||
+ (meson.current_source_dir() / '..' / 'include' / 'core.h')
|
||||
+ '"',
|
||||
'-DXCE_CORE_C_PATH="'
|
||||
+ (meson.current_source_dir() / '..' / 'src' / 'core.c')
|
||||
+ '"',
|
||||
'-DXCE_CORE_LIB_PATH="'
|
||||
+ sched_core_isolation_lib.full_path()
|
||||
+ '"'],
|
||||
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',
|
||||
|
|
@ -205,3 +233,6 @@ test('scheduler picker core loop boundary test',
|
|||
test('scheduler pendreason factory audit test',
|
||||
sched_pendreason_factory_audit_test, suite: 'scheduler',
|
||||
env: ['ASAN_OPTIONS=detect_leaks=0'])
|
||||
test('scheduler core isolation test',
|
||||
sched_core_isolation_test, suite: 'scheduler',
|
||||
env: ['ASAN_OPTIONS=detect_leaks=0'])
|
||||
|
|
|
|||
|
|
@ -12,12 +12,25 @@
|
|||
* This also brings in scheduler.h (with the real xce_scheduler_t) and all deps. */
|
||||
#include "../src/resource.c"
|
||||
|
||||
/* Stubs for symbols used by resource.c functions not under test */
|
||||
xce_sched_worker_t* sched_get_worker(xce_scheduler_t* s, char* n) { (void)s; (void)n; return NULL; }
|
||||
/* Stubs for symbols used by resource.c functions not under test.
|
||||
* sched_get_worker/sched_get_queue relocated to core.h (scheduler-core
|
||||
* spec, task 4.1) -- now operate on xce_sched_core_t*, not
|
||||
* xce_scheduler_t*. */
|
||||
xce_sched_worker_t* sched_get_worker(xce_sched_core_t* s, char* n)
|
||||
{
|
||||
(void)s;
|
||||
(void)n;
|
||||
return NULL;
|
||||
}
|
||||
int plugin_prepare_allocation(void* s, xce_sched_ctx_t* c) { (void)s; (void)c; return 0; }
|
||||
int sched_ctx_get_uncomit_host(xvec_t** v, xce_sched_ctx_t* c, int i) { (void)v; (void)c; (void)i; return 0; }
|
||||
int plugin_queue_update(void* s, xce_sched_queue_t* q) { (void)s; (void)q; return 0; }
|
||||
xce_sched_queue_t* sched_get_queue(xce_scheduler_t* s, char* n) { (void)s; (void)n; return NULL; }
|
||||
xce_sched_queue_t* sched_get_queue(xce_sched_core_t* s, char* n)
|
||||
{
|
||||
(void)s;
|
||||
(void)n;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Stub: sched_update_existing_queue returns -EINVAL when updated is NULL,
|
||||
* -ENOENT when queue not found (sched_get_queue stub returns NULL).
|
||||
|
|
@ -27,7 +40,7 @@ int sched_update_existing_queue(xce_scheduler_t* sched, xce_queue_t* updated)
|
|||
if (updated == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sched_get_queue(sched, updated->queue) == NULL) {
|
||||
if (sched_get_queue(&(sched->core), updated->queue) == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -127,9 +140,9 @@ test_scheduler_t_has_atomic_gc_fields(void)
|
|||
xce_scheduler_t sched;
|
||||
memset(&sched, 0, sizeof(sched));
|
||||
|
||||
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(0, atomic_load(&sched.staging_merge_complete));
|
||||
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.core.session_active));
|
||||
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.core.eval_in_progress));
|
||||
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.core.staging_merge_complete));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -222,15 +235,15 @@ 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);
|
||||
atomic_store(&sched.core.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));
|
||||
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.core.session_active));
|
||||
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.core.eval_in_progress));
|
||||
TEST_ASSERT_EQUAL_INT(1, atomic_load(&sched.core.staging_merge_complete));
|
||||
|
||||
/* GC operations on an empty node table must not crash */
|
||||
gc_clear_marks();
|
||||
|
|
@ -256,19 +269,20 @@ test_staging_merge_complete_gc_guard(void)
|
|||
memset(&sched, 0, sizeof(sched));
|
||||
|
||||
/* Simulate the post-begin_session state the fix produces */
|
||||
atomic_store(&sched.session_active, 0); /* session ended */
|
||||
atomic_store(&sched.eval_in_progress, 0);
|
||||
atomic_store(&sched.staging_merge_complete, 1); /* fix: begin_session sets this */
|
||||
atomic_store(&sched.core.session_active, 0); /* session ended */
|
||||
atomic_store(&sched.core.eval_in_progress, 0);
|
||||
atomic_store(&sched.core.staging_merge_complete,
|
||||
1); /* fix: begin_session sets this */
|
||||
|
||||
/* The GC guard in sched_end_session: must NOT fire */
|
||||
int guard_fires = atomic_load(&sched.eval_in_progress)
|
||||
|| !atomic_load(&sched.staging_merge_complete);
|
||||
int guard_fires = atomic_load(&sched.core.eval_in_progress)
|
||||
|| !atomic_load(&sched.core.staging_merge_complete);
|
||||
TEST_ASSERT_EQUAL_INT(0, guard_fires);
|
||||
|
||||
/* Confirm the unfixed state (staging=0) would block GC */
|
||||
atomic_store(&sched.staging_merge_complete, 0);
|
||||
int guard_fires_unfixed = atomic_load(&sched.eval_in_progress)
|
||||
|| !atomic_load(&sched.staging_merge_complete);
|
||||
atomic_store(&sched.core.staging_merge_complete, 0);
|
||||
int guard_fires_unfixed = atomic_load(&sched.core.eval_in_progress)
|
||||
|| !atomic_load(&sched.core.staging_merge_complete);
|
||||
TEST_ASSERT_EQUAL_INT(1, guard_fires_unfixed);
|
||||
}
|
||||
|
||||
|
|
|
|||
315
src/scheduler/testsuite/test_core_isolation.c
Normal file
315
src/scheduler/testsuite/test_core_isolation.c
Normal file
|
|
@ -0,0 +1,315 @@
|
|||
/*
|
||||
* test_core_isolation.c - regression guard for task 4.1's Observable
|
||||
* (scheduler-core spec, Req 5.1/5.2): "the core structure compiles and
|
||||
* links with zero symbols from the networking/API libraries; a build-time
|
||||
* or link-time check confirms this" -- and the accompanying constraint
|
||||
* "no wall-clock time call appears anywhere in the extracted core's
|
||||
* source."
|
||||
*
|
||||
* Two layers, same genre as test_picker_core_loop_boundary.c /
|
||||
* test_picker_pendreason_factory_audit.c (source-text scans of the real,
|
||||
* current on-disk files, not a frozen snapshot):
|
||||
*
|
||||
* 1. Source-text scan of core.h/core.c: no #include of client.h,
|
||||
* netio.h, xceapi.h, delay.h, idgen.h, or xce/cluster.h (the
|
||||
* "Allowed Dependencies" list in design.md names exactly these as
|
||||
* forbidden); no call-site substring matching a symbol exported only
|
||||
* by those libraries; no wall-clock call (time()/clock_gettime()/
|
||||
* gettimeofday()) anywhere in core.c.
|
||||
*
|
||||
* 2. The literal build-time/link-time proof the Observable asks for,
|
||||
* not achievable by a text scan alone: core.c is compiled in
|
||||
* isolation into its own static library (meson.build's
|
||||
* sched_core_isolation_lib, this test's XCE_CORE_LIB_PATH), and this
|
||||
* test inspects that archive's UNDEFINED SYMBOL TABLE via nm(1) --
|
||||
* proving what core.c's *compiled code actually calls*, independent
|
||||
* of what any header happens to transitively declare (xce/types.h,
|
||||
* used by literally every file in this directory, itself includes
|
||||
* netio.h for unrelated reasons -- so a "no forbidden #include"
|
||||
* check alone would either false-positive on that pre-existing,
|
||||
* harmless transitive include, or have to special-case it; the nm
|
||||
* check sidesteps that entirely by checking *usage*, not
|
||||
* *visibility*).
|
||||
*
|
||||
* Why nm on a static_library() rather than the full xce_scheduler
|
||||
* executable: the executable links the whole monolithic libxce_dep, so
|
||||
* every symbol from netio/xceapi/client/delay/idgen would appear in ITS
|
||||
* undefined-symbol table regardless of whether core.c itself ever calls
|
||||
* one -- that would prove nothing. Compiling core.c alone into its own
|
||||
* archive (sched_core_isolation_lib, meson.build) and inspecting THAT
|
||||
* object's undefined symbols isolates exactly what this one translation
|
||||
* unit references.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <unity/unity.h>
|
||||
|
||||
#ifndef XCE_CORE_H_PATH
|
||||
#error \
|
||||
"XCE_CORE_H_PATH must be defined by meson.build to core.h's absolute path"
|
||||
#endif
|
||||
#ifndef XCE_CORE_C_PATH
|
||||
#error \
|
||||
"XCE_CORE_C_PATH must be defined by meson.build to core.c's absolute path"
|
||||
#endif
|
||||
#ifndef XCE_CORE_LIB_PATH
|
||||
#error \
|
||||
"XCE_CORE_LIB_PATH must be defined by meson.build to the absolute path of core.c's isolated static_library() archive"
|
||||
#endif
|
||||
|
||||
/* Forbidden headers (design.md "Allowed Dependencies", Req 5 AC 3): the
|
||||
* core must never directly include any of these. */
|
||||
static const char* const FORBIDDEN_INCLUDES[] = {
|
||||
"#include \"client.h\"", "#include \"netio.h\"",
|
||||
"#include \"xceapi.h\"", "#include \"delay.h\"",
|
||||
"#include \"idgen.h\"", "#include \"xce/cluster.h\"",
|
||||
"#include <client.h>", "#include <netio.h>",
|
||||
"#include <xceapi.h>", "#include <delay.h>",
|
||||
"#include <idgen.h>", "#include <xce/cluster.h>",
|
||||
};
|
||||
#define NUM_FORBIDDEN_INCLUDES \
|
||||
(sizeof(FORBIDDEN_INCLUDES) / sizeof(FORBIDDEN_INCLUDES[0]))
|
||||
|
||||
/* Forbidden call-site symbols: exported only by netio.c/xceapi.c/client.c/
|
||||
* delay.c/idgen.c (verified against those headers' own extern lists) --
|
||||
* none of these are legitimately callable from a core with zero controller
|
||||
* I/O, network, or timer dependency. */
|
||||
static const char* const FORBIDDEN_SYMBOLS[] = {
|
||||
"xcecli_",
|
||||
"endpoint_",
|
||||
"iomgr_",
|
||||
"idgen_",
|
||||
"delaymgr_",
|
||||
"delay_task",
|
||||
"xce_connect_cluster",
|
||||
"xce_reconnect_",
|
||||
"xce_parse_peers",
|
||||
"xce_cluster_config_validate",
|
||||
"socket_connect",
|
||||
"create_ssl_context",
|
||||
"initialize_openssl",
|
||||
"cleanup_openssl",
|
||||
"io_fsm_start",
|
||||
};
|
||||
#define NUM_FORBIDDEN_SYMBOLS \
|
||||
(sizeof(FORBIDDEN_SYMBOLS) / sizeof(FORBIDDEN_SYMBOLS[0]))
|
||||
|
||||
/* Wall-clock calls (Req 5 AC "no wall-clock time call appears anywhere in
|
||||
* the extracted core's source"). */
|
||||
static const char* const FORBIDDEN_WALLCLOCK[] = {
|
||||
"time(",
|
||||
"clock_gettime(",
|
||||
"gettimeofday(",
|
||||
};
|
||||
#define NUM_FORBIDDEN_WALLCLOCK \
|
||||
(sizeof(FORBIDDEN_WALLCLOCK) / sizeof(FORBIDDEN_WALLCLOCK[0]))
|
||||
|
||||
static char* read_whole_file(const char* path)
|
||||
{
|
||||
FILE* f = fopen(path, "rb");
|
||||
if (f == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fseek(f, 0, SEEK_END) != 0) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
long len = ftell(f);
|
||||
if (len < 0) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
rewind(f);
|
||||
|
||||
char* buf = (char*)malloc((size_t)len + 1);
|
||||
if (buf == NULL) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t nread = fread(buf, 1, (size_t)len, f);
|
||||
fclose(f);
|
||||
buf[nread] = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void setUp(void) { return; }
|
||||
void tearDown(void) { return; }
|
||||
|
||||
/* Sanity check: both source paths baked in by meson.build must actually be
|
||||
* readable -- without this, a stale path would make every scan below
|
||||
* silently pass on zero bytes of text (the exact false-confidence failure
|
||||
* mode this whole test exists to avoid). */
|
||||
static void test_core_source_paths_are_readable(void)
|
||||
{
|
||||
char* h = read_whole_file(XCE_CORE_H_PATH);
|
||||
char* c = read_whole_file(XCE_CORE_C_PATH);
|
||||
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(h, XCE_CORE_H_PATH);
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(c, XCE_CORE_C_PATH);
|
||||
|
||||
free(h);
|
||||
free(c);
|
||||
}
|
||||
|
||||
static void test_core_never_includes_forbidden_headers(void)
|
||||
{
|
||||
char* h = read_whole_file(XCE_CORE_H_PATH);
|
||||
char* c = read_whole_file(XCE_CORE_C_PATH);
|
||||
size_t i;
|
||||
|
||||
TEST_ASSERT_NOT_NULL(h);
|
||||
TEST_ASSERT_NOT_NULL(c);
|
||||
|
||||
for (i = 0; i < NUM_FORBIDDEN_INCLUDES; i++) {
|
||||
char msg[256];
|
||||
|
||||
snprintf(msg, sizeof(msg),
|
||||
"core.h directly includes forbidden header '%s'",
|
||||
FORBIDDEN_INCLUDES[i]);
|
||||
TEST_ASSERT_NULL_MESSAGE(strstr(h, FORBIDDEN_INCLUDES[i]), msg);
|
||||
|
||||
snprintf(msg, sizeof(msg),
|
||||
"core.c directly includes forbidden header '%s'",
|
||||
FORBIDDEN_INCLUDES[i]);
|
||||
TEST_ASSERT_NULL_MESSAGE(strstr(c, FORBIDDEN_INCLUDES[i]), msg);
|
||||
}
|
||||
|
||||
free(h);
|
||||
free(c);
|
||||
}
|
||||
|
||||
static void test_core_never_calls_forbidden_symbols(void)
|
||||
{
|
||||
char* h = read_whole_file(XCE_CORE_H_PATH);
|
||||
char* c = read_whole_file(XCE_CORE_C_PATH);
|
||||
size_t i;
|
||||
|
||||
TEST_ASSERT_NOT_NULL(h);
|
||||
TEST_ASSERT_NOT_NULL(c);
|
||||
|
||||
for (i = 0; i < NUM_FORBIDDEN_SYMBOLS; i++) {
|
||||
char msg[256];
|
||||
|
||||
snprintf(msg, sizeof(msg),
|
||||
"core.h references forbidden networking/API symbol '%s'",
|
||||
FORBIDDEN_SYMBOLS[i]);
|
||||
TEST_ASSERT_NULL_MESSAGE(strstr(h, FORBIDDEN_SYMBOLS[i]), msg);
|
||||
|
||||
snprintf(msg, sizeof(msg),
|
||||
"core.c references forbidden networking/API symbol '%s'",
|
||||
FORBIDDEN_SYMBOLS[i]);
|
||||
TEST_ASSERT_NULL_MESSAGE(strstr(c, FORBIDDEN_SYMBOLS[i]), msg);
|
||||
}
|
||||
|
||||
free(h);
|
||||
free(c);
|
||||
}
|
||||
|
||||
static void test_core_never_calls_wallclock_functions(void)
|
||||
{
|
||||
char* c = read_whole_file(XCE_CORE_C_PATH);
|
||||
size_t i;
|
||||
|
||||
TEST_ASSERT_NOT_NULL(c);
|
||||
|
||||
for (i = 0; i < NUM_FORBIDDEN_WALLCLOCK; i++) {
|
||||
char msg[256];
|
||||
|
||||
snprintf(msg, sizeof(msg),
|
||||
"core.c calls wall-clock function '%s' -- the core must "
|
||||
"access time exclusively through a future xce_core_now() "
|
||||
"(scheduler-core spec, task 4.5)",
|
||||
FORBIDDEN_WALLCLOCK[i]);
|
||||
TEST_ASSERT_NULL_MESSAGE(strstr(c, FORBIDDEN_WALLCLOCK[i]), msg);
|
||||
}
|
||||
|
||||
free(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* test_core_object_has_no_forbidden_undefined_symbols - the literal
|
||||
* build-time/link-time proof: core.c, compiled in isolation into
|
||||
* sched_core_isolation_lib (meson.build), must not reference (as an
|
||||
* undefined external symbol in the compiled object) anything matching the
|
||||
* forbidden prefixes above. This is independent of what any header
|
||||
* transitively declares -- it reflects only what core.c's compiled code
|
||||
* actually calls.
|
||||
*/
|
||||
static void test_core_object_has_no_forbidden_undefined_symbols(void)
|
||||
{
|
||||
char cmd[4096];
|
||||
char line[1024];
|
||||
FILE* p;
|
||||
int any_undefined_seen = 0;
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "nm --format=posix -u \"%s\" 2>&1",
|
||||
XCE_CORE_LIB_PATH);
|
||||
|
||||
p = popen(cmd, "r");
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(p, "failed to popen() nm(1)");
|
||||
|
||||
while (fgets(line, sizeof(line), p) != NULL) {
|
||||
char symbol[512];
|
||||
char type;
|
||||
size_t i;
|
||||
|
||||
/* posix format for an undefined symbol: "<name> U" (no
|
||||
* value/size columns). Skip anything that doesn't parse as
|
||||
* exactly that -- e.g. a blank line or an archive member header
|
||||
* some nm versions print. */
|
||||
if (sscanf(line, "%511s %c", symbol, &type) != 2) {
|
||||
continue;
|
||||
}
|
||||
if (type != 'U') {
|
||||
continue;
|
||||
}
|
||||
|
||||
any_undefined_seen = 1;
|
||||
|
||||
for (i = 0; i < NUM_FORBIDDEN_SYMBOLS; i++) {
|
||||
if (strncmp(symbol, FORBIDDEN_SYMBOLS[i],
|
||||
strlen(FORBIDDEN_SYMBOLS[i]))
|
||||
== 0) {
|
||||
char msg[768];
|
||||
|
||||
snprintf(msg, sizeof(msg),
|
||||
"core.c's compiled object has an undefined "
|
||||
"reference to '%s', matching forbidden "
|
||||
"networking/API prefix '%s' -- core.c must never "
|
||||
"link networking/API library symbols (Req 5.1/"
|
||||
"5.2)",
|
||||
symbol, FORBIDDEN_SYMBOLS[i]);
|
||||
pclose(p);
|
||||
TEST_FAIL_MESSAGE(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pclose(p);
|
||||
|
||||
/* If nm produced no undefined symbols at all, either the archive path
|
||||
* is wrong or nm itself failed silently -- either way this test would
|
||||
* be vacuously passing without having checked anything real. */
|
||||
TEST_ASSERT_TRUE_MESSAGE(
|
||||
any_undefined_seen,
|
||||
"nm reported zero undefined symbols for XCE_CORE_LIB_PATH -- "
|
||||
"the archive path is likely wrong (this test would otherwise pass "
|
||||
"vacuously)");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_core_source_paths_are_readable);
|
||||
RUN_TEST(test_core_never_includes_forbidden_headers);
|
||||
RUN_TEST(test_core_never_calls_forbidden_symbols);
|
||||
RUN_TEST(test_core_never_calls_wallclock_functions);
|
||||
RUN_TEST(test_core_object_has_no_forbidden_undefined_symbols);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
@ -30,7 +30,9 @@ int sched_init_config(xce_scheduler_t* s, xce_conf4sched_t* c)
|
|||
(void)s; (void)c; return 0;
|
||||
}
|
||||
|
||||
xce_sched_job_t* sched_get_job(xce_scheduler_t* sched, uint64_t jobid)
|
||||
/* sched_get_job relocated to core.h (scheduler-core spec, task 4.1) -- now
|
||||
* operates on xce_sched_core_t*, not xce_scheduler_t*. */
|
||||
xce_sched_job_t* sched_get_job(xce_sched_core_t* sched, uint64_t jobid)
|
||||
{
|
||||
(void)sched; (void)jobid; return NULL;
|
||||
}
|
||||
|
|
@ -47,11 +49,11 @@ void tearDown(void)
|
|||
static void fixture_init(xce_scheduler_t* sched)
|
||||
{
|
||||
memset(sched, 0, sizeof(*sched));
|
||||
mylock_init(&(sched->lock));
|
||||
sched->pend_updates[0] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->pend_updates[0], NULL);
|
||||
sched->pend_updates[1] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->pend_updates[1], NULL);
|
||||
mylock_init(&(sched->core.lock));
|
||||
sched->core.pend_updates[0] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->core.pend_updates[0], NULL);
|
||||
sched->core.pend_updates[1] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->core.pend_updates[1], NULL);
|
||||
}
|
||||
|
||||
/* Dequeue one pending request (NULL if the queue is empty) and return its op
|
||||
|
|
@ -59,7 +61,7 @@ static void fixture_init(xce_scheduler_t* sched)
|
|||
* the suite's leaks-off convention). Returns 1 if an item was present. */
|
||||
static int pop_op(xce_scheduler_t* sched, xce_sched_op_t* op_out)
|
||||
{
|
||||
data_item_t* it = dataq_deq(sched->pend_updates[0], NULL);
|
||||
data_item_t* it = dataq_deq(sched->core.pend_updates[0], NULL);
|
||||
xce_sched_update_request_t* req;
|
||||
|
||||
if (it == NULL) {
|
||||
|
|
|
|||
|
|
@ -33,23 +33,25 @@ int sched_init_config(xce_scheduler_t* s, xce_conf4sched_t* c)
|
|||
}
|
||||
|
||||
/* REAL kvmgr-backed job add/get -- same rtti path production uses (mirrors
|
||||
* test_job_update.c's precedent for exercising sched_get_job "for real"). */
|
||||
int sched_add_job(xce_scheduler_t* sched, xce_sched_job_t* j)
|
||||
* test_job_update.c's precedent for exercising sched_get_job "for real").
|
||||
* Relocated to core.h (scheduler-core spec, task 4.1) -- now operate on
|
||||
* xce_sched_core_t*, not xce_scheduler_t*. */
|
||||
int sched_add_job(xce_sched_core_t* core, xce_sched_job_t* j)
|
||||
{
|
||||
int rc;
|
||||
lock(sched->jobs, RTTI_LOCK_WRITE);
|
||||
rc = key_add(sched->jobs, (void*)j->jobid, j);
|
||||
unlock(sched->jobs);
|
||||
lock(core->jobs, RTTI_LOCK_WRITE);
|
||||
rc = key_add(core->jobs, (void*)j->jobid, j);
|
||||
unlock(core->jobs);
|
||||
return rc;
|
||||
}
|
||||
|
||||
xce_sched_job_t* sched_get_job(xce_scheduler_t* sched, uint64_t jobid)
|
||||
xce_sched_job_t* sched_get_job(xce_sched_core_t* core, uint64_t jobid)
|
||||
{
|
||||
int rc;
|
||||
xce_sched_job_t* job = NULL;
|
||||
lock(sched->jobs, RTTI_LOCK_READ);
|
||||
rc = key_find(sched->jobs, (void*)jobid, (void**)&job);
|
||||
unlock(sched->jobs);
|
||||
lock(core->jobs, RTTI_LOCK_READ);
|
||||
rc = key_find(core->jobs, (void*)jobid, (void**)&job);
|
||||
unlock(core->jobs);
|
||||
if (rc <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -71,19 +73,19 @@ static void fixture_init(xce_scheduler_t* sched)
|
|||
.datakiller = NULL };
|
||||
|
||||
memset(sched, 0, sizeof(*sched));
|
||||
mylock_init(&(sched->lock));
|
||||
sched->pend_updates[0] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->pend_updates[0], NULL);
|
||||
sched->pend_updates[1] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->pend_updates[1], NULL);
|
||||
sched->jobs = makeInstance(&xkvmgr_type, &jobs_params);
|
||||
mylock_init(&(sched->core.lock));
|
||||
sched->core.pend_updates[0] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->core.pend_updates[0], NULL);
|
||||
sched->core.pend_updates[1] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->core.pend_updates[1], NULL);
|
||||
sched->core.jobs = makeInstance(&xkvmgr_type, &jobs_params);
|
||||
}
|
||||
|
||||
static void seed_existing_job(xce_scheduler_t* sched, uint64_t jobid)
|
||||
{
|
||||
xce_sched_job_t* job = (xce_sched_job_t*)calloc(1, sizeof(*job));
|
||||
job->jobid = jobid;
|
||||
sched_add_job(sched, job);
|
||||
sched_add_job(&(sched->core), job);
|
||||
}
|
||||
|
||||
/* Builds a heap-allocated, heap-owned-strings (jobArray, submit) pair -- the
|
||||
|
|
@ -119,7 +121,7 @@ static xce_job_submit_t* init_job_array(uint64_t base_jobid,
|
|||
* mirror sched_pend_update_killer). Returns -1 if the queue is empty. */
|
||||
static int pop_job_update(xce_scheduler_t* sched, xce_job_t*** jobs_out)
|
||||
{
|
||||
data_item_t* it = dataq_deq(sched->pend_updates[0], NULL);
|
||||
data_item_t* it = dataq_deq(sched->core.pend_updates[0], NULL);
|
||||
xce_sched_update_request_t* req;
|
||||
int njobs;
|
||||
|
||||
|
|
|
|||
|
|
@ -81,24 +81,26 @@ int sched_init_config(xce_scheduler_t* s, xce_conf4sched_t* c)
|
|||
|
||||
/* REAL kvmgr-backed job add/get -- same rtti path production uses (mirrors
|
||||
* test_job_array_expand.c's precedent), needed so sched_on_job_array()'s
|
||||
* per-element dedup check (sched_get_job) is exercised for real. */
|
||||
int sched_add_job(xce_scheduler_t* sched, xce_sched_job_t* j)
|
||||
* per-element dedup check (sched_get_job) is exercised for real. Relocated
|
||||
* to core.h (scheduler-core spec, task 4.1) -- now operate on
|
||||
* xce_sched_core_t*, not xce_scheduler_t*. */
|
||||
int sched_add_job(xce_sched_core_t* core, xce_sched_job_t* j)
|
||||
{
|
||||
int rc;
|
||||
lock(sched->jobs, RTTI_LOCK_WRITE);
|
||||
rc = key_add(sched->jobs, (void*)j->jobid, j);
|
||||
unlock(sched->jobs);
|
||||
lock(core->jobs, RTTI_LOCK_WRITE);
|
||||
rc = key_add(core->jobs, (void*)j->jobid, j);
|
||||
unlock(core->jobs);
|
||||
return rc;
|
||||
}
|
||||
|
||||
xce_sched_job_t* sched_get_job(xce_scheduler_t* sched, uint64_t jobid)
|
||||
xce_sched_job_t* sched_get_job(xce_sched_core_t* core, uint64_t jobid)
|
||||
{
|
||||
int rc;
|
||||
xce_sched_job_t* job = NULL;
|
||||
|
||||
lock(sched->jobs, RTTI_LOCK_READ);
|
||||
rc = key_find(sched->jobs, (void*)jobid, (void**)&job);
|
||||
unlock(sched->jobs);
|
||||
lock(core->jobs, RTTI_LOCK_READ);
|
||||
rc = key_find(core->jobs, (void*)jobid, (void**)&job);
|
||||
unlock(core->jobs);
|
||||
|
||||
if (rc <= 0) {
|
||||
return NULL;
|
||||
|
|
@ -118,12 +120,12 @@ static void fixture_init(xce_scheduler_t* sched)
|
|||
.datakiller = NULL };
|
||||
|
||||
memset(sched, 0, sizeof(*sched));
|
||||
mylock_init(&(sched->lock));
|
||||
sched->pend_updates[0] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->pend_updates[0], NULL);
|
||||
sched->pend_updates[1] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->pend_updates[1], NULL);
|
||||
sched->jobs = makeInstance(&xkvmgr_type, &jobs_params);
|
||||
mylock_init(&(sched->core.lock));
|
||||
sched->core.pend_updates[0] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->core.pend_updates[0], NULL);
|
||||
sched->core.pend_updates[1] = (dataq_t*)calloc(1, sizeof(dataq_t));
|
||||
dataq_init(sched->core.pend_updates[1], NULL);
|
||||
sched->core.jobs = makeInstance(&xkvmgr_type, &jobs_params);
|
||||
}
|
||||
|
||||
/* Pop one pending update request, asserting it is an UPDATE_JOB op; hands
|
||||
|
|
@ -132,7 +134,7 @@ static void fixture_init(xce_scheduler_t* sched)
|
|||
* test_job_array_expand.c's identical helper. */
|
||||
static int pop_job_update(xce_scheduler_t* sched, xce_job_t*** jobs_out)
|
||||
{
|
||||
data_item_t* it = dataq_deq(sched->pend_updates[0], NULL);
|
||||
data_item_t* it = dataq_deq(sched->core.pend_updates[0], NULL);
|
||||
xce_sched_update_request_t* req;
|
||||
int njobs;
|
||||
|
||||
|
|
@ -168,7 +170,7 @@ static void materialize_popped_jobs(xce_scheduler_t* sched, xce_job_t** jobs,
|
|||
for (i = 0; i < njobs; i++) {
|
||||
xce_sched_job_t* job = (xce_sched_job_t*)calloc(1, sizeof(*job));
|
||||
job->jobid = jobs[i]->jobid;
|
||||
sched_add_job(sched, job);
|
||||
sched_add_job(&(sched->core), job);
|
||||
free_Job_ptr(&jobs[i]);
|
||||
}
|
||||
free(jobs);
|
||||
|
|
|
|||
|
|
@ -31,12 +31,16 @@
|
|||
|
||||
/* Stubs for scheduler-internal externs schedobj.c references but which are
|
||||
* defined in other .c files not linked into this test. (make_sched_obj and
|
||||
* kill_sched_job are static in schedobj.c and come in via the #include.) */
|
||||
xce_sched_user_t* sched_get_user(xce_scheduler_t* s, char* n)
|
||||
* kill_sched_job are static in schedobj.c and come in via the #include.)
|
||||
* sched_get_user/sched_get_project/sched_get_queue/sched_add_user/
|
||||
* sched_add_project/sched_add_job/sched_get_job relocated to core.h
|
||||
* (scheduler-core spec, task 4.1) -- now operate on xce_sched_core_t*, not
|
||||
* xce_scheduler_t*. */
|
||||
xce_sched_user_t* sched_get_user(xce_sched_core_t* s, char* n)
|
||||
{
|
||||
(void)s; (void)n; return NULL;
|
||||
}
|
||||
xce_sched_project_t* sched_get_project(xce_scheduler_t* s, char* n)
|
||||
xce_sched_project_t* sched_get_project(xce_sched_core_t* s, char* n)
|
||||
{
|
||||
(void)s; (void)n; return NULL;
|
||||
}
|
||||
|
|
@ -48,8 +52,18 @@ int plugin_job_rusage_update(void* s, xce_sched_job_t* j, xce_job_rusages_t* r)
|
|||
}
|
||||
xce_job_account_t* make_job_account(xce_job_alloc_t* a) { (void)a; return NULL; }
|
||||
void free_job_account(xce_job_account_t* a) { (void)a; }
|
||||
int sched_add_user(xce_scheduler_t* s, xce_sched_user_t* u) { (void)s; (void)u; return 0; }
|
||||
int sched_add_project(xce_scheduler_t* s, xce_sched_project_t* p) { (void)s; (void)p; return 0; }
|
||||
int sched_add_user(xce_sched_core_t* s, xce_sched_user_t* u)
|
||||
{
|
||||
(void)s;
|
||||
(void)u;
|
||||
return 0;
|
||||
}
|
||||
int sched_add_project(xce_sched_core_t* s, xce_sched_project_t* p)
|
||||
{
|
||||
(void)s;
|
||||
(void)p;
|
||||
return 0;
|
||||
}
|
||||
void sched_worker_release_host_ctx(xce_sched_worker_t* w) { (void)w; }
|
||||
int plugin_prepare_allocation(void* s, xce_sched_ctx_t* c) { (void)s; (void)c; return 0; }
|
||||
|
||||
|
|
@ -57,7 +71,7 @@ int plugin_prepare_allocation(void* s, xce_sched_ctx_t* c) { (void)s; (void)c; r
|
|||
static xce_sched_queue_t* g_test_queues[8];
|
||||
static int g_test_nqueues;
|
||||
|
||||
xce_sched_queue_t* sched_get_queue(xce_scheduler_t* s, char* name)
|
||||
xce_sched_queue_t* sched_get_queue(xce_sched_core_t* s, char* name)
|
||||
{
|
||||
int i;
|
||||
(void)s;
|
||||
|
|
@ -74,22 +88,22 @@ xce_sched_queue_t* sched_get_queue(xce_scheduler_t* s, char* name)
|
|||
}
|
||||
|
||||
/* REAL kvmgr-backed job add/get - same rtti path the production code uses. */
|
||||
int sched_add_job(xce_scheduler_t* sched, xce_sched_job_t* j)
|
||||
int sched_add_job(xce_sched_core_t* core, xce_sched_job_t* j)
|
||||
{
|
||||
int rc;
|
||||
lock(sched->jobs, RTTI_LOCK_WRITE);
|
||||
rc = key_add(sched->jobs, (void*)j->jobid, j);
|
||||
unlock(sched->jobs);
|
||||
lock(core->jobs, RTTI_LOCK_WRITE);
|
||||
rc = key_add(core->jobs, (void*)j->jobid, j);
|
||||
unlock(core->jobs);
|
||||
return rc;
|
||||
}
|
||||
|
||||
xce_sched_job_t* sched_get_job(xce_scheduler_t* sched, uint64_t jobid)
|
||||
xce_sched_job_t* sched_get_job(xce_sched_core_t* core, uint64_t jobid)
|
||||
{
|
||||
int rc;
|
||||
xce_sched_job_t* job = NULL;
|
||||
lock(sched->jobs, RTTI_LOCK_READ);
|
||||
rc = key_find(sched->jobs, (void*)jobid, (void**)&job);
|
||||
unlock(sched->jobs);
|
||||
lock(core->jobs, RTTI_LOCK_READ);
|
||||
rc = key_find(core->jobs, (void*)jobid, (void**)&job);
|
||||
unlock(core->jobs);
|
||||
if (rc <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -120,8 +134,8 @@ static void fixture_init(xce_scheduler_t* sched)
|
|||
resreq_init(1);
|
||||
xstring_table_init(1024 * 16);
|
||||
|
||||
sched->jobs = makeInstance(&xkvmgr_type, &jobs_params);
|
||||
sched->resmgr = makeInstance(&xkvmgr_type, &res_params);
|
||||
sched->core.jobs = makeInstance(&xkvmgr_type, &jobs_params);
|
||||
sched->core.resmgr = makeInstance(&xkvmgr_type, &res_params);
|
||||
|
||||
g_test_nqueues = 0;
|
||||
memset(g_test_queues, 0, sizeof(g_test_queues));
|
||||
|
|
@ -146,7 +160,7 @@ static xce_sched_job_t* seed_job(xce_scheduler_t* sched, uint64_t jobid)
|
|||
job->resreq = (xce_resreq_t*)calloc(1, sizeof(*job->resreq));
|
||||
/* schedobj is live runtime state that MUST survive an in-place update */
|
||||
job->schedobj = (xce_sched_obj_t*)calloc(1, sizeof(*job->schedobj));
|
||||
sched_add_job(sched, job);
|
||||
sched_add_job(&(sched->core), job);
|
||||
return job;
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +196,7 @@ test_update_existing_job_mutates_in_place(void)
|
|||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
|
||||
/* SAME object mutated in place, not replaced */
|
||||
TEST_ASSERT_EQUAL_PTR(job, sched_get_job(&sched, 42));
|
||||
TEST_ASSERT_EQUAL_PTR(job, sched_get_job(&sched.core, 42));
|
||||
/* mutable fields updated */
|
||||
TEST_ASSERT_EQUAL_UINT(JOB_STAT_RUN, job->state);
|
||||
TEST_ASSERT_EQUAL_PTR(g_test_queues[0], job->queue);
|
||||
|
|
@ -209,7 +223,7 @@ test_update_unknown_job_returns_enoent_no_create(void)
|
|||
|
||||
TEST_ASSERT_EQUAL_INT(-ENOENT, rc);
|
||||
/* And NO job was created via the update path */
|
||||
TEST_ASSERT_NULL(sched_get_job(&sched, 999));
|
||||
TEST_ASSERT_NULL(sched_get_job(&sched.core, 999));
|
||||
|
||||
free(upd->submit);
|
||||
free(upd);
|
||||
|
|
@ -250,7 +264,7 @@ test_rusage_stored_on_existing_job(void)
|
|||
/* stored ON the job (ownership transferred to the job) */
|
||||
TEST_ASSERT_EQUAL_PTR(ru, job->rusages);
|
||||
/* the job object itself is unchanged identity */
|
||||
TEST_ASSERT_EQUAL_PTR(job, sched_get_job(&sched, 42));
|
||||
TEST_ASSERT_EQUAL_PTR(job, sched_get_job(&sched.core, 42));
|
||||
/* job owns ru now; kill_sched_job/free_job_rusages will release it */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,29 +48,22 @@
|
|||
#include "scheduler.h"
|
||||
#include "xstring.h"
|
||||
|
||||
/* Pull the real implementation under test into this TU. */
|
||||
/* Pull the real implementations under test into this TU. sched_get_user/
|
||||
* sched_get_project/sched_get_queue/sched_get_job/sched_add_user/
|
||||
* sched_add_project/make_sched_user/make_sched_project relocated to core.c
|
||||
* (scheduler-core spec, task 4.1) -- pulling core.c in alongside schedobj.c
|
||||
* (rather than re-stubbing them) is what lets this file keep exercising the
|
||||
* REAL make_sched_project, per this file's own header comment. */
|
||||
#include "../src/core.c"
|
||||
#include "../src/schedobj.c"
|
||||
|
||||
/* Stubs for scheduler-internal externs schedobj.c references but which are
|
||||
* defined in other .c files not linked into this test (same set as
|
||||
* test_job_update.c). Not exercised by the tests below -- present only to
|
||||
* satisfy the linker for this whole-file #include. */
|
||||
xce_sched_user_t* sched_get_user(xce_scheduler_t* s, char* n)
|
||||
{
|
||||
(void)s; (void)n; return NULL;
|
||||
}
|
||||
xce_sched_project_t* sched_get_project(xce_scheduler_t* s, char* n)
|
||||
{
|
||||
(void)s; (void)n; return NULL;
|
||||
}
|
||||
xce_sched_queue_t* sched_get_queue(xce_scheduler_t* s, char* n)
|
||||
{
|
||||
(void)s; (void)n; return NULL;
|
||||
}
|
||||
xce_sched_job_t* sched_get_job(xce_scheduler_t* s, uint64_t jobid)
|
||||
{
|
||||
(void)s; (void)jobid; return NULL;
|
||||
}
|
||||
/* Stubs for scheduler-internal externs schedobj.c/core.c reference but
|
||||
* which are defined in other .c files not linked into this test. Not
|
||||
* exercised by the tests below -- present only to satisfy the linker for
|
||||
* this whole-file #include. plugin_unregister is core.c's kvmgr datakiller
|
||||
* for the (never-called-in-this-test) plugins kvmgr inside
|
||||
* xce_sched_core_init() -- still needs a resolvable address even though
|
||||
* that code path never runs here. */
|
||||
int plugin_job_update(void* s, xce_sched_job_t* j) { (void)s; (void)j; return 0; }
|
||||
int plugin_queue_update(void* s, xce_sched_queue_t* q) { (void)s; (void)q; return 0; }
|
||||
int plugin_job_rusage_update(void* s, xce_sched_job_t* j, xce_job_rusages_t* r)
|
||||
|
|
@ -78,11 +71,10 @@ int plugin_job_rusage_update(void* s, xce_sched_job_t* j, xce_job_rusages_t* r)
|
|||
(void)s; (void)j; (void)r; return 0;
|
||||
}
|
||||
xce_job_account_t* make_job_account(xce_job_alloc_t* a) { (void)a; return NULL; }
|
||||
void free_job_account(xce_job_account_t* a) { (void)a; }
|
||||
int sched_add_user(xce_scheduler_t* s, xce_sched_user_t* u) { (void)s; (void)u; return 0; }
|
||||
int sched_add_project(xce_scheduler_t* s, xce_sched_project_t* p) { (void)s; (void)p; return 0; }
|
||||
void free_job_account(xce_job_account_t* a) { (void)a; }
|
||||
void sched_worker_release_host_ctx(xce_sched_worker_t* w) { (void)w; }
|
||||
int plugin_prepare_allocation(void* s, xce_sched_ctx_t* c) { (void)s; (void)c; return 0; }
|
||||
void plugin_unregister(void* arg) { (void)arg; }
|
||||
|
||||
void setUp(void) { return; }
|
||||
void tearDown(void) { return; }
|
||||
|
|
@ -117,12 +109,12 @@ static void test_scheduler_job_pick_plugin_field_is_char_star_and_unset_by_defau
|
|||
xce_scheduler_t sched;
|
||||
|
||||
fixture_init(&sched);
|
||||
TEST_ASSERT_NULL(sched.job_pick_plugin);
|
||||
TEST_ASSERT_NULL(sched.core.job_pick_plugin);
|
||||
|
||||
/* Type check: assigning a char* literal must compile without a cast --
|
||||
* this is a compile-time proof of the declared field type. */
|
||||
sched.job_pick_plugin = "some_name";
|
||||
TEST_ASSERT_EQUAL_STRING("some_name", sched.job_pick_plugin);
|
||||
sched.core.job_pick_plugin = "some_name";
|
||||
TEST_ASSERT_EQUAL_STRING("some_name", sched.core.job_pick_plugin);
|
||||
}
|
||||
|
||||
/* Req 2 AC 1's literal wording: "defaulting to builtin_fcfs when unset". */
|
||||
|
|
@ -131,12 +123,12 @@ static void test_sched_set_default_job_pick_plugin_applies_builtin_fcfs_when_uns
|
|||
xce_scheduler_t sched;
|
||||
|
||||
fixture_init(&sched);
|
||||
TEST_ASSERT_NULL(sched.job_pick_plugin);
|
||||
TEST_ASSERT_NULL(sched.core.job_pick_plugin);
|
||||
|
||||
sched_set_default_job_pick_plugin(&sched);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(sched.job_pick_plugin);
|
||||
TEST_ASSERT_EQUAL_STRING("builtin_fcfs", sched.job_pick_plugin);
|
||||
TEST_ASSERT_NOT_NULL(sched.core.job_pick_plugin);
|
||||
TEST_ASSERT_EQUAL_STRING("builtin_fcfs", sched.core.job_pick_plugin);
|
||||
}
|
||||
|
||||
/* "...when unset" implies idempotence: an already-configured name (however
|
||||
|
|
@ -147,11 +139,11 @@ test_sched_set_default_job_pick_plugin_does_not_clobber_configured_value(void)
|
|||
xce_scheduler_t sched;
|
||||
|
||||
fixture_init(&sched);
|
||||
sched.job_pick_plugin = makeString("priority_picker");
|
||||
sched.core.job_pick_plugin = makeString("priority_picker");
|
||||
|
||||
sched_set_default_job_pick_plugin(&sched);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("priority_picker", sched.job_pick_plugin);
|
||||
TEST_ASSERT_EQUAL_STRING("priority_picker", sched.core.job_pick_plugin);
|
||||
}
|
||||
|
||||
static void test_sched_set_default_job_pick_plugin_is_null_safe(void)
|
||||
|
|
@ -201,7 +193,7 @@ static void test_queue_with_no_override_inherits_global_picker_name(void)
|
|||
|
||||
TEST_ASSERT_NOT_NULL(queue);
|
||||
TEST_ASSERT_NULL(queue->job_pick_plugin);
|
||||
TEST_ASSERT_EQUAL_STRING("builtin_fcfs", sched.job_pick_plugin);
|
||||
TEST_ASSERT_EQUAL_STRING("builtin_fcfs", sched.core.job_pick_plugin);
|
||||
}
|
||||
|
||||
/* tasks.md Observable, half 2: "a queue config with an override reports
|
||||
|
|
@ -228,8 +220,9 @@ test_queue_with_override_reports_its_own_override_not_global_default(void)
|
|||
TEST_ASSERT_NOT_NULL(queue->job_pick_plugin);
|
||||
TEST_ASSERT_EQUAL_STRING("priority_picker", queue->job_pick_plugin);
|
||||
/* The override is reported, NOT the global default. */
|
||||
TEST_ASSERT_TRUE(strcmp(queue->job_pick_plugin, sched.job_pick_plugin) != 0);
|
||||
TEST_ASSERT_EQUAL_STRING("builtin_fcfs", sched.job_pick_plugin);
|
||||
TEST_ASSERT_TRUE(strcmp(queue->job_pick_plugin, sched.core.job_pick_plugin)
|
||||
!= 0);
|
||||
TEST_ASSERT_EQUAL_STRING("builtin_fcfs", sched.core.job_pick_plugin);
|
||||
}
|
||||
|
||||
/* project_name is independently settable/readable (structural field check
|
||||
|
|
@ -263,7 +256,7 @@ static void test_make_sched_project_priority_field_defaults_to_zero(void)
|
|||
|
||||
fixture_init(&sched);
|
||||
|
||||
project = make_sched_project(&sched, "acct-42");
|
||||
project = make_sched_project(&sched.core, "acct-42");
|
||||
|
||||
TEST_ASSERT_NOT_NULL(project);
|
||||
TEST_ASSERT_EQUAL_STRING("acct-42", project->name);
|
||||
|
|
@ -281,7 +274,7 @@ static void test_project_priority_field_is_int32_and_independently_settable(void
|
|||
|
||||
fixture_init(&sched);
|
||||
|
||||
project = make_sched_project(&sched, "acct-7");
|
||||
project = make_sched_project(&sched.core, "acct-7");
|
||||
project->priority = 7;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT32(7, project->priority);
|
||||
|
|
|
|||
|
|
@ -56,10 +56,12 @@
|
|||
#endif
|
||||
|
||||
static const char* const SCANNED_RELATIVE_PATHS[] = {
|
||||
"include/core.h",
|
||||
"include/decision.h",
|
||||
"include/plugin.h",
|
||||
"include/scheduler.h",
|
||||
"include/sched/types.h",
|
||||
"src/core.c",
|
||||
"src/decision.c",
|
||||
"src/handler.c",
|
||||
"src/main.c",
|
||||
|
|
|
|||
|
|
@ -67,25 +67,31 @@
|
|||
* which the REAL plugin.c now provides in this TU) as
|
||||
* test_picker_config_fields.c uses for its own schedobj.c-only include.
|
||||
* ---------------------------------------------------------------------- */
|
||||
xce_sched_user_t* sched_get_user(xce_scheduler_t* s, char* n)
|
||||
/* sched_get_user/sched_get_project/sched_get_queue/sched_get_job/
|
||||
* sched_add_user/sched_add_project relocated to core.h (scheduler-core
|
||||
* spec, task 4.1) -- now operate on xce_sched_core_t*, not
|
||||
* xce_scheduler_t*. Kept as stubs here (not pulling in core.c's real
|
||||
* implementations): this file never exercises make_sched_job/queue
|
||||
* lookup, only picker registration/resolution. */
|
||||
xce_sched_user_t* sched_get_user(xce_sched_core_t* s, char* n)
|
||||
{
|
||||
(void)s;
|
||||
(void)n;
|
||||
return NULL;
|
||||
}
|
||||
xce_sched_project_t* sched_get_project(xce_scheduler_t* s, char* n)
|
||||
xce_sched_project_t* sched_get_project(xce_sched_core_t* s, char* n)
|
||||
{
|
||||
(void)s;
|
||||
(void)n;
|
||||
return NULL;
|
||||
}
|
||||
xce_sched_queue_t* sched_get_queue(xce_scheduler_t* s, char* n)
|
||||
xce_sched_queue_t* sched_get_queue(xce_sched_core_t* s, char* n)
|
||||
{
|
||||
(void)s;
|
||||
(void)n;
|
||||
return NULL;
|
||||
}
|
||||
xce_sched_job_t* sched_get_job(xce_scheduler_t* s, uint64_t jobid)
|
||||
xce_sched_job_t* sched_get_job(xce_sched_core_t* s, uint64_t jobid)
|
||||
{
|
||||
(void)s;
|
||||
(void)jobid;
|
||||
|
|
@ -97,13 +103,13 @@ xce_job_account_t* make_job_account(xce_job_alloc_t* a)
|
|||
return NULL;
|
||||
}
|
||||
void free_job_account(xce_job_account_t* a) { (void)a; }
|
||||
int sched_add_user(xce_scheduler_t* s, xce_sched_user_t* u)
|
||||
int sched_add_user(xce_sched_core_t* s, xce_sched_user_t* u)
|
||||
{
|
||||
(void)s;
|
||||
(void)u;
|
||||
return 0;
|
||||
}
|
||||
int sched_add_project(xce_scheduler_t* s, xce_sched_project_t* p)
|
||||
int sched_add_project(xce_sched_core_t* s, xce_sched_project_t* p)
|
||||
{
|
||||
(void)s;
|
||||
(void)p;
|
||||
|
|
@ -146,7 +152,7 @@ void setUp(void) { return; }
|
|||
void tearDown(void) { return; }
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Fixture: a real sched->plugins kvmgr (same setup scheduler.c's
|
||||
/* Fixture: a real sched->core.plugins kvmgr (same setup scheduler.c's
|
||||
* sched_plugin_init() uses) plus the xstring/CSE intern tables
|
||||
* sched_set_default_job_pick_plugin()'s makeString() call needs. Nothing is
|
||||
* torn down between tests (suite convention, ASAN_OPTIONS=detect_leaks=0). */
|
||||
|
|
@ -161,8 +167,8 @@ static void fixture_init(xce_scheduler_t* sched)
|
|||
memset(sched, 0, sizeof(*sched));
|
||||
resreq_init(1);
|
||||
xstring_table_init(1024 * 16);
|
||||
sched->plugins = makeInstance(&xkvmgr_type, ¶ms);
|
||||
TEST_ASSERT_NOT_NULL(sched->plugins);
|
||||
sched->core.plugins = makeInstance(&xkvmgr_type, ¶ms);
|
||||
TEST_ASSERT_NOT_NULL(sched->core.plugins);
|
||||
}
|
||||
|
||||
/* Minimal legacy (job_elect_fn-only) plugin, mirroring
|
||||
|
|
@ -202,9 +208,9 @@ static void test_register_builtin_fcfs_registers_under_name_builtin_fcfs(void)
|
|||
rc = register_builtin_fcfs(&sched);
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(0, rc);
|
||||
|
||||
lock(sched.plugins, RTTI_LOCK_READ);
|
||||
rc = key_find(sched.plugins, "builtin_fcfs", (void**)&found);
|
||||
unlock(sched.plugins);
|
||||
lock(sched.core.plugins, RTTI_LOCK_READ);
|
||||
rc = key_find(sched.core.plugins, "builtin_fcfs", (void**)&found);
|
||||
unlock(sched.core.plugins);
|
||||
|
||||
TEST_ASSERT_GREATER_THAN(0, rc);
|
||||
TEST_ASSERT_NOT_NULL(found);
|
||||
|
|
@ -224,9 +230,9 @@ static void test_register_builtin_fcfs_is_native_not_legacy(void)
|
|||
fixture_init(&sched);
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(0, register_builtin_fcfs(&sched));
|
||||
|
||||
lock(sched.plugins, RTTI_LOCK_READ);
|
||||
key_find(sched.plugins, "builtin_fcfs", (void**)&found);
|
||||
unlock(sched.plugins);
|
||||
lock(sched.core.plugins, RTTI_LOCK_READ);
|
||||
key_find(sched.core.plugins, "builtin_fcfs", (void**)&found);
|
||||
unlock(sched.core.plugins);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(found);
|
||||
TEST_ASSERT_NULL(found->job_elect_fn);
|
||||
|
|
@ -264,9 +270,9 @@ static void test_register_builtin_fcfs_runs_init_via_init_fn_adapter(void)
|
|||
fixture_init(&sched);
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(0, register_builtin_fcfs(&sched));
|
||||
|
||||
lock(sched.plugins, RTTI_LOCK_READ);
|
||||
key_find(sched.plugins, "builtin_fcfs", (void**)&found);
|
||||
unlock(sched.plugins);
|
||||
lock(sched.core.plugins, RTTI_LOCK_READ);
|
||||
key_find(sched.core.plugins, "builtin_fcfs", (void**)&found);
|
||||
unlock(sched.core.plugins);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(found);
|
||||
TEST_ASSERT_NOT_NULL(found->data);
|
||||
|
|
@ -286,10 +292,10 @@ static void test_unset_job_pick_plugin_resolves_to_builtin_fcfs_by_default(void)
|
|||
|
||||
fixture_init(&sched);
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(0, register_builtin_fcfs(&sched));
|
||||
TEST_ASSERT_NULL(sched.job_pick_plugin);
|
||||
TEST_ASSERT_NULL(sched.core.job_pick_plugin);
|
||||
|
||||
sched_set_default_job_pick_plugin(&sched);
|
||||
TEST_ASSERT_EQUAL_STRING("builtin_fcfs", sched.job_pick_plugin);
|
||||
TEST_ASSERT_EQUAL_STRING("builtin_fcfs", sched.core.job_pick_plugin);
|
||||
|
||||
rc = sched_resolve_job_picker(&sched, &resolved);
|
||||
|
||||
|
|
@ -316,7 +322,7 @@ test_unregistered_configured_name_fails_with_enoent_not_silent_fallback(void)
|
|||
fixture_init(&sched);
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(0, register_builtin_fcfs(&sched));
|
||||
|
||||
sched.job_pick_plugin = "totally_unregistered_picker_name";
|
||||
sched.core.job_pick_plugin = "totally_unregistered_picker_name";
|
||||
|
||||
rc = sched_resolve_job_picker(&sched, &resolved);
|
||||
|
||||
|
|
@ -350,7 +356,7 @@ static void test_registered_but_not_a_picker_fails_with_einval_not_enoent(void)
|
|||
* categories), which plugin_register() leaves untouched (task 1.2). */
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(0, plugin_register(&sched, non_picker));
|
||||
|
||||
sched.job_pick_plugin = "not_a_picker";
|
||||
sched.core.job_pick_plugin = "not_a_picker";
|
||||
|
||||
rc = sched_resolve_job_picker(&sched, &resolved);
|
||||
|
||||
|
|
@ -369,7 +375,7 @@ test_unset_job_pick_plugin_without_defaulting_fails_with_einval(void)
|
|||
int rc;
|
||||
|
||||
fixture_init(&sched);
|
||||
TEST_ASSERT_NULL(sched.job_pick_plugin);
|
||||
TEST_ASSERT_NULL(sched.core.job_pick_plugin);
|
||||
|
||||
rc = sched_resolve_job_picker(&sched, &resolved);
|
||||
|
||||
|
|
@ -403,7 +409,7 @@ test_resolved_legacy_plugin_has_job_elect_fn_set_selecting_legacy_branch(void)
|
|||
legacy = make_legacy_plugin("test_legacy_picker_for_wiring");
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(0, plugin_register(&sched, legacy));
|
||||
|
||||
sched.job_pick_plugin = "test_legacy_picker_for_wiring";
|
||||
sched.core.job_pick_plugin = "test_legacy_picker_for_wiring";
|
||||
|
||||
rc = sched_resolve_job_picker(&sched, &resolved);
|
||||
|
||||
|
|
@ -429,7 +435,7 @@ test_resolved_builtin_fcfs_has_job_elect_fn_null_selecting_native_branch(void)
|
|||
fixture_init(&sched);
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(0, register_builtin_fcfs(&sched));
|
||||
|
||||
sched.job_pick_plugin = "builtin_fcfs"; /* explicit, not defaulted */
|
||||
sched.core.job_pick_plugin = "builtin_fcfs"; /* explicit, not defaulted */
|
||||
|
||||
rc = sched_resolve_job_picker(&sched, &resolved);
|
||||
|
||||
|
|
@ -460,12 +466,12 @@ test_legacy_and_native_pickers_coexist_and_resolve_independently(void)
|
|||
TEST_ASSERT_GREATER_OR_EQUAL(0, plugin_register(&sched, legacy));
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(0, register_builtin_fcfs(&sched));
|
||||
|
||||
sched.job_pick_plugin = "xce_sched_fcfs_stub";
|
||||
sched.core.job_pick_plugin = "xce_sched_fcfs_stub";
|
||||
rc = sched_resolve_job_picker(&sched, &resolved);
|
||||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
TEST_ASSERT_NOT_NULL(resolved->job_elect_fn);
|
||||
|
||||
sched.job_pick_plugin = "builtin_fcfs";
|
||||
sched.core.job_pick_plugin = "builtin_fcfs";
|
||||
rc = sched_resolve_job_picker(&sched, &resolved);
|
||||
TEST_ASSERT_EQUAL_INT(0, rc);
|
||||
TEST_ASSERT_NULL(resolved->job_elect_fn);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ static void start_log_capture(void)
|
|||
static void stop_log_capture(void) { tlog_reg_early_printf_callback(NULL); }
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Fixture: a real sched->plugins kvmgr -- same setup as scheduler.c's
|
||||
/* Fixture: a real sched->core.plugins kvmgr -- same setup as scheduler.c's
|
||||
* (static, so not reusable) sched_plugin_init(). Each test gets its own
|
||||
* fresh instance; nothing is torn down (suite convention, see meson.build:
|
||||
* ASAN_OPTIONS=detect_leaks=0). */
|
||||
|
|
@ -106,8 +106,8 @@ static void fixture_init(xce_scheduler_t* sched)
|
|||
.datakiller = plugin_unregister };
|
||||
|
||||
memset(sched, 0, sizeof(*sched));
|
||||
sched->plugins = makeInstance(&xkvmgr_type, ¶ms);
|
||||
TEST_ASSERT_NOT_NULL(sched->plugins);
|
||||
sched->core.plugins = makeInstance(&xkvmgr_type, ¶ms);
|
||||
TEST_ASSERT_NOT_NULL(sched->core.plugins);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue