fix(xce-test-cli-ux): fix bug-1711's display and text defects
Eight display/text defects in test.c: worker_status_str's "UNKOWN" typo, cmd_runtasks's "sequentail" typo (display-only, verified inert against the real launch_type consumer), cmd_reslist's right-justified columns and unlabeled hex Flags (now matching workerlist/state_raw's conventions), joblist's raw-epoch timestamps (now via a format_job_time helper delegating to the same formatter ctrlstatus already uses) and combined NTasks column split into MinTasks/MaxTasks, job_state_str's missing raw-state fallback for ambiguous RUN+EXIT (mirroring print_jobinfo's existing pattern), and getconf's no-op group/config list stubs (now genuinely implemented from already-fetched data, matching the three sibling print functions' convention). worker_status_str/job_state_str/format_job_time are pure functions with no networking/REPL/global-state dependency, extracted into a new joblist_display.c/.h module with a permanent 20-test standalone suite -- following this codebase's own resval_typeresolve.c/misc.c precedent for testing functions that would otherwise be stranded inside untестable test.c. cmd_reslist/joblist_query/cmd_getconf's table-printing bodies inline fetch+print and remain untestable without a live cluster. 1348/1348 across the full controller suite (+20), 0 regressions. Task 2.5 of .kiro/specs/xce-test-cli-ux/tasks.md. Requirements: 11.1, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019jaMf9QEwpugH2W9KAuc7f
This commit is contained in:
parent
c709eba813
commit
a8154acb0a
6 changed files with 545 additions and 62 deletions
99
src/controller/testsuite/joblist_display.c
Normal file
99
src/controller/testsuite/joblist_display.c
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/* joblist_display.c -- xce-test-cli-ux task 2.5 remediation (bug-1711 fixes)
|
||||
*
|
||||
* See joblist_display.h for the full rationale. Verbatim extraction of
|
||||
* test.c's worker_status_str()/job_state_str()/format_job_time() -- no
|
||||
* behavior change from the pre-extraction versions.
|
||||
*/
|
||||
#include "joblist_display.h"
|
||||
|
||||
#include <stdio.h> /* snprintf */
|
||||
|
||||
#include "ctrlstatus_fmt.h" /* ctrlstatus_format_time_ms */
|
||||
#include "xce/types.h" /* XCE_WORKER_*, JOB_STAT_* bit definitions */
|
||||
|
||||
char* worker_status_str(uint32_t status)
|
||||
{
|
||||
/* Admin-set CLOSED takes priority over the dynamic UNAVAIL bit: the
|
||||
* config-upgrade-snapshot soak (task 8.6) needs to assert a host's
|
||||
* administratively-set status specifically, and a host closed via
|
||||
* hostctrl that later disconnects (e.g. its xce_test `worker`/`join`
|
||||
* connection exits after the script ends) would otherwise print only
|
||||
* "UNAVAIL", masking the admin bit this check exists to verify. */
|
||||
if ((status & XCE_WORKER_CLOSED) != 0) {
|
||||
return "CLOSED";
|
||||
} else if ((status & XCE_WORKER_UNAVAIL) != 0) {
|
||||
return "UNAVAIL";
|
||||
} else if ((status & XCE_WORKER_LOCKEDU) != 0) {
|
||||
return "LOCKU";
|
||||
} else if ((status & XCE_WORKER_LOCKEDW) != 0) {
|
||||
return "LOCKW";
|
||||
} else if ((status & XCE_WORKER_BUSY) != 0) {
|
||||
return "BUSY";
|
||||
} else if (status == 0) {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
char* job_state_str(int state)
|
||||
{
|
||||
/* bug-1711 (Requirement 11.7): raw-state fallback mirroring
|
||||
* print_jobinfo's existing state_raw guard against the same ambiguity
|
||||
* (see print_jobinfo's comment above its "state_raw: 0x%x" print) -- a
|
||||
* job that is simultaneously RUN and EXIT (e.g. a worker-reported FAIL
|
||||
* received without a prior FINISH; apply_job_fail_transition ORs in
|
||||
* EXIT|PERR without clearing RUN) would otherwise silently print as
|
||||
* plain "RUN" via the if/else-if priority ordering below, hiding the
|
||||
* EXIT bit. Unlike print_jobinfo (which always has room for a separate
|
||||
* state_raw line), job_state_str's result is a single cmd_joblist table
|
||||
* cell, so the raw state is folded into the same string only for this
|
||||
* specific ambiguous case. */
|
||||
static char ambiguous_buf[32];
|
||||
|
||||
if ((state & JOB_STAT_PEND) != 0) {
|
||||
if ((state & JOB_STAT_PSUSP) != 0) {
|
||||
return "PSUSP";
|
||||
}
|
||||
|
||||
return "PEND";
|
||||
} else if ((state & JOB_STAT_RUN) != 0) {
|
||||
if ((state & JOB_STAT_USUSP) != 0) {
|
||||
return "USUSP";
|
||||
} else if ((state & JOB_STAT_SSUSP) != 0) {
|
||||
return "SSUSP";
|
||||
} else if ((state & JOB_STAT_EXIT) != 0) {
|
||||
snprintf(ambiguous_buf, sizeof(ambiguous_buf), "RUN(0x%x)", state);
|
||||
return ambiguous_buf;
|
||||
}
|
||||
return "RUN";
|
||||
} else if ((state & JOB_STAT_EXIT) != 0) {
|
||||
return "EXIT";
|
||||
} else if ((state & JOB_STAT_DONE) != 0) {
|
||||
return "DONE";
|
||||
} else if ((state & JOB_STAT_ERR) != 0) {
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
/* bug-1711 (Requirement 11.5): format a job time_t field (epoch seconds) using
|
||||
* ctrlstatus_fmt.h's ctrlstatus_format_time_ms human-readable formatter
|
||||
* (which takes epoch milliseconds), instead of printing the raw epoch-seconds
|
||||
* value directly as cmd_joblist did before. A job time of 0 means the
|
||||
* corresponding event has not happened yet (e.g. an unstarted job's
|
||||
* start_time/finish_time) -- print "-" rather than a misleading 1970-01-01
|
||||
* epoch date. */
|
||||
const char* format_job_time(time_t t, char* buf, size_t bufsize)
|
||||
{
|
||||
if (t == 0) {
|
||||
return "-";
|
||||
}
|
||||
|
||||
if (ctrlstatus_format_time_ms((uint64_t)t * 1000u, buf, bufsize) == NULL) {
|
||||
return "-";
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue