feat(xce-test-e2e-primitives): add echo command (task 1.2)

This commit is contained in:
Rongsong Shen 2026-06-19 15:38:38 +00:00
parent 481e197928
commit 7ad63e7403
2 changed files with 25 additions and 1 deletions

View file

@ -115,6 +115,7 @@ extern int cmd_qctrl(int, char*[]);
extern int cmd_runtasks(int, char*[]);
extern int cmd_setpend(int, char*[]);
extern int cmd_jobinfo(int, char*[]);
extern int cmd_echo(int, char*[]);
static int worker_house_keeping(void*);
/* Session verdict / loop state (xce-test-e2e-primitives task 1.1).
@ -151,6 +152,7 @@ static command_t top_commands[] = {
{ "scheduler", cmd_scheduler, "In scheduler context" },
{ "client", cmd_client, "In client context" },
{ "set", cmd_set, "Show/Set settings" },
{ "echo", cmd_echo, "Print a message" },
{ "quit", cmd_quit, "Quit xce test" },
{ (char*)NULL, (cmd_func_t)NULL, (char*)NULL }
};
@ -167,6 +169,7 @@ static command_t worker_commands[] = {
{ "join", cmd_join_worker, "Join the cluster" },
{ "jfinish", cmd_jobfinish, "tell controller jobfinish" },
{ "resupdate", cmd_resupdate, "update res vals" },
{ "echo", cmd_echo, "Print a message" },
{ (char*)NULL, (cmd_func_t)NULL, (char*)NULL }
};
@ -191,6 +194,7 @@ static command_t client_commands[] = {
{ "resval", cmd_resval, "get value of res" },
{ "taskrun", cmd_runtasks, "run tasks" },
{ "help", cmd_help, "Display this text" },
{ "echo", cmd_echo, "Print a message" },
{ "quit", cmd_quit, "Quit xce test" },
{ (char*)NULL, (cmd_func_t)NULL, (char*)NULL }
};
@ -207,6 +211,7 @@ static command_t scheduler_commands[] = {
{ "join", cmd_join_sched, "Join the cluster" },
{ "getconf", cmd_getconf, "Get conf of cluster" },
{ "setpend", cmd_setpend, "set job pend reason" },
{ "echo", cmd_echo, "Print a message" },
{ (char*)NULL, (cmd_func_t)NULL, (char*)NULL }
};
@ -473,6 +478,25 @@ int cmd_help(int argc, char* argv[])
return rc;
}
/* echo <message...> — print the remainder of the line (argv[1..] joined by
* single spaces) followed by a newline and succeed (xce-test-e2e-primitives
* task 1.2, Req 6.3). `echo` with no argument prints an empty line and still
* succeeds. Returns 0 always so it never marks the session failed. */
int cmd_echo(int argc, char* argv[])
{
int i;
for (i = 1; i < argc; i++) {
if (i > 1) {
putchar(' ');
}
fputs(argv[i], stdout);
}
putchar('\n');
return 0;
}
int cmd_up(int argc, char* argv[])
{
if (active_ctx->parent != NULL) {