fix(scheduler): "info resource all" printed nothing when no global/shared resources exist

Correct filtering (bug-1593: only XCE_RESF_GLOBAL/XCE_RESF_SHARED
resources list under "all") but confusing UX: a session with only
host-based resources (e.g. just "slots") produced zero output lines,
indistinguishable from a REPL/dispatch bug. Now prints an explicit
"no global/shared resources defined" message when the count is zero.
This commit is contained in:
Rongsong Shen 2026-08-20 03:03:00 +00:00
parent 8cb304d29a
commit 185feca2c8
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
2 changed files with 59 additions and 2 deletions

View file

@ -574,8 +574,9 @@ static void repl_info_resource(xce_sched_sim_driver_t* sim, const char* arg)
{
if (strcmp(arg, "all") == 0) {
iterator_t it;
xce_resource_t* r = NULL;
int rc = iter_make(&it, sim->core.resmgr);
xce_resource_t* r = NULL;
int n_shown = 0;
int rc = iter_make(&it, sim->core.resmgr);
if (rc < 0) {
return;
@ -589,8 +590,20 @@ static void repl_info_resource(xce_sched_sim_driver_t* sim, const char* arg)
continue;
}
repl_info_resource_one(sim, r);
n_shown++;
}
iter_destroy(&it);
/* Every resource in this session was host-based (e.g. only 'slots'/
* 'mem'/'cpus'-style consumables, no GLOBAL/SHARED resource at
* all) -- say so explicitly rather than silently printing nothing,
* which reads identically to a REPL/dispatch bug from the
* operator's side. */
if (n_shown == 0) {
fprintf(stdout,
"[sim] info resource: no global/shared resources defined "
"(host-based resources are 'info worker <name>''s job)\n");
}
return;
}

View file

@ -1020,6 +1020,49 @@ static void test_info_resource_named_lookup_reports_host_based_note(void)
"PASS\n");
}
/*
* 2026-08-20 (live-deployment finding): `info resource all` printed
* literally nothing when every registered resource was host-based (no
* GLOBAL/SHARED resource defined at all) -- correct per bug-1593's own
* filtering rule, but indistinguishable from a REPL/dispatch bug from the
* operator's side with no output at all. Must say so explicitly.
*/
static void test_info_resource_all_reports_when_none_are_global_shared(void)
{
xce_sched_sim_driver_t sim;
xce_resource_t wire_resource;
char* captured;
int rc;
memset(&sim, 0, sizeof(sim));
rc = xce_sched_core_init(&(sim.core));
TEST_ASSERT_EQUAL_INT(0, rc);
memset(&wire_resource, 0, sizeof(wire_resource));
wire_resource.name = "slots";
wire_resource.valtype = XCE_VAL_NUMERIC;
/* flags left 0 -- host-based, no GLOBAL/SHARED bit, same as
* test_info_resource_all_lists_only_global_shared_resources()'s own
* "mem" fixture above -- but here it is the ONLY resource registered. */
TEST_ASSERT_NOT_NULL(makeResource(sim.core.resmgr, &wire_resource));
captured = capture_dispatch(&sim, "info resource all");
TEST_ASSERT_NULL_MESSAGE(
strstr(captured, "resource slots:"),
"a host-based resource must never appear in 'info resource all' "
"(bug-1593, unchanged)");
TEST_ASSERT_NOT_NULL_MESSAGE(
strstr(captured, "no global/shared resources defined"),
"'info resource all' must say something when zero resources "
"qualify, not print nothing at all");
free(captured);
printf("test_info_resource_all_reports_when_none_are_global_shared: "
"PASS\n");
}
/*
* bug-1596 (task 12.5): repl_split_tokens() must strip one matching pair
* of surrounding quote characters -- an operator quoting an argument out
@ -1622,6 +1665,7 @@ int main(void)
RUN_TEST(test_info_resource_reports_string_value);
RUN_TEST(test_info_resource_all_lists_only_global_shared_resources);
RUN_TEST(test_info_resource_named_lookup_reports_host_based_note);
RUN_TEST(test_info_resource_all_reports_when_none_are_global_shared);
RUN_TEST(test_info_job_accepts_quoted_jobid_argument);
RUN_TEST(test_info_summary_reports_counts);
RUN_TEST(test_info_session_reports_position_after_synthetic_events);