summaryrefslogtreecommitdiff
path: root/test/cmd_ut.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-02-07 11:30:57 -0700
committerTom Rini <trini@konsulko.com>2025-02-11 20:12:36 -0600
commitfa0b68d22add6416fa56a5907c752a9348ae1a45 (patch)
tree01693091e0e01b4f85db6f79e2153bcaf2f35bfa /test/cmd_ut.c
parent32aba887e3d7cbcdf8fd98c107aaa79f3bd44a16 (diff)
test: Allow running a selection of suites
Enhance the ut command to accept a comma-separated list of test suites to run. Report the summary information for these at the end. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/cmd_ut.c')
-rw-r--r--test/cmd_ut.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index b44e60d5a87..3925a391de1 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -218,7 +218,6 @@ static int do_ut_all(struct unit_test_state *uts, struct cmd_tbl *cmdtp,
update_stats(uts, ste);
}
}
- ut_report(&uts->total, uts->run_count);
return any_fail;
}
@@ -282,7 +281,7 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct unit_test_state uts;
struct suite *ste;
- const char *name;
+ char *name;
int ret;
if (argc < 2)
@@ -299,17 +298,26 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
} else if (!strcmp(name, "info")) {
ret = do_ut_info(cmdtp, flag, argc, argv);
} else {
- ste = find_suite(argv[0]);
- if (!ste) {
- printf("Suite '%s' not found\n", argv[0]);
- return CMD_RET_FAILURE;
- } else if (!has_tests(ste)) {
- /* perhaps a Kconfig option needs to be set? */
- printf("Suite '%s' is not enabled\n", argv[0]);
- return CMD_RET_FAILURE;
- }
+ int any_fail = 0;
+ const char *p;
+
+ for (; p = strsep(&name, ","), p; name = NULL) {
+ ste = find_suite(p);
+ if (!ste) {
+ printf("Suite '%s' not found\n", p);
+ return CMD_RET_FAILURE;
+ } else if (!has_tests(ste)) {
+ /* perhaps a Kconfig option needs to be set? */
+ printf("Suite '%s' is not enabled\n", p);
+ return CMD_RET_FAILURE;
+ }
- ret = run_suite(&uts, ste, cmdtp, flag, argc, argv);
+ ret = run_suite(&uts, ste, cmdtp, flag, argc, argv);
+ if (!any_fail)
+ any_fail = ret;
+ update_stats(&uts, ste);
+ }
+ ret = any_fail;
}
show_stats(&uts);
if (ret)