1 // SPDX-License-Identifier: GPL-2.0
4 * Joe Hershberger, National Instruments, joe.hershberger@ni.com
10 #include <test/suites.h>
11 #include <test/test.h>
14 static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
17 int cmd_ut_category(const char *name, const char *prefix,
18 struct unit_test *tests, int n_ents,
19 int argc, char *const argv[])
23 ret = ut_run_list(name, prefix, tests, n_ents,
24 argc > 1 ? argv[1] : NULL);
26 return ret ? CMD_RET_FAILURE : 0;
29 static struct cmd_tbl cmd_ut_sub[] = {
30 U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""),
32 U_BOOT_CMD_MKENT(bootstd, CONFIG_SYS_MAXARGS, 1, do_ut_bootstd,
35 U_BOOT_CMD_MKENT(common, CONFIG_SYS_MAXARGS, 1, do_ut_common, "", ""),
36 #if defined(CONFIG_UT_DM)
37 U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""),
39 #if defined(CONFIG_UT_ENV)
40 U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""),
42 #ifdef CONFIG_UT_OPTEE
43 U_BOOT_CMD_MKENT(optee, CONFIG_SYS_MAXARGS, 1, do_ut_optee, "", ""),
45 #ifdef CONFIG_UT_OVERLAY
46 U_BOOT_CMD_MKENT(overlay, CONFIG_SYS_MAXARGS, 1, do_ut_overlay, "", ""),
49 U_BOOT_CMD_MKENT(lib, CONFIG_SYS_MAXARGS, 1, do_ut_lib, "", ""),
52 U_BOOT_CMD_MKENT(log, CONFIG_SYS_MAXARGS, 1, do_ut_log, "", ""),
54 U_BOOT_CMD_MKENT(mem, CONFIG_SYS_MAXARGS, 1, do_ut_mem, "", ""),
55 #ifdef CONFIG_CMD_SETEXPR
56 U_BOOT_CMD_MKENT(setexpr, CONFIG_SYS_MAXARGS, 1, do_ut_setexpr, "",
59 U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_ut_print, "", ""),
61 U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
63 #if CONFIG_IS_ENABLED(UT_UNICODE) && !defined(API_BUILD)
64 U_BOOT_CMD_MKENT(unicode, CONFIG_SYS_MAXARGS, 1, do_ut_unicode, "", ""),
67 U_BOOT_CMD_MKENT(compression, CONFIG_SYS_MAXARGS, 1, do_ut_compression,
69 U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist,
71 U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""),
73 U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, "", ""),
74 #ifdef CONFIG_CMD_ADDRMAP
75 U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""),
79 static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
86 for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++) {
87 printf("----Running %s tests----\n", cmd_ut_sub[i].name);
88 retval = cmd_ut_sub[i].cmd(cmdtp, flag, 1, &cmd_ut_sub[i].name);
96 static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
101 return CMD_RET_USAGE;
103 /* drop initial "ut" arg */
107 cp = find_cmd_tbl(argv[0], cmd_ut_sub, ARRAY_SIZE(cmd_ut_sub));
110 return cp->cmd(cmdtp, flag, argc, argv);
112 return CMD_RET_USAGE;
115 #ifdef CONFIG_SYS_LONGHELP
116 static char ut_help_text[] =
117 "all - execute all enabled tests\n"
118 #ifdef CONFIG_SANDBOX
119 "ut bloblist - Test bloblist implementation\n"
120 "ut compression - Test compressors and bootm decompression\n"
122 #ifdef CONFIG_BOOTSTD
123 "ut bootstd - Test standard boot implementation\n"
126 "ut dm [test-name]\n"
129 "ut env [test-name]\n"
132 "ut lib [test-name] - test library functions\n"
135 "ut log [test-name] - test logging functions\n"
137 "ut mem [test-name] - test memory-related commands\n"
138 #ifdef CONFIG_UT_OPTEE
139 "ut optee [test-name]\n"
141 #ifdef CONFIG_UT_OVERLAY
142 "ut overlay [test-name]\n"
144 "ut print [test-name] - test printing\n"
145 "ut setexpr [test-name] - test setexpr command\n"
146 #ifdef CONFIG_SANDBOX
147 "ut str - Basic test of string functions\n"
149 #ifdef CONFIG_UT_TIME
150 "ut time - Very basic test of time functions\n"
152 #if defined(CONFIG_UT_UNICODE) && \
153 !defined(CONFIG_SPL_BUILD) && !defined(API_BUILD)
154 "ut unicode [test-name] - test Unicode functions\n"
156 #ifdef CONFIG_CMD_ADDRMAP
157 "ut addrmap - Very basic test of addrmap command\n"
160 #endif /* CONFIG_SYS_LONGHELP */
163 ut, CONFIG_SYS_MAXARGS, 1, do_ut,
164 "unit tests", ut_help_text