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

@ -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);