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[])
21 int runs_per_text = 1;
24 if (argc > 1 && !strncmp("-r", argv[1], 2)) {
25 runs_per_text = dectoul(argv[1] + 2, NULL);
30 ret = ut_run_list(name, prefix, tests, n_ents,
31 argc > 1 ? argv[1] : NULL, runs_per_text);
33 return ret ? CMD_RET_FAILURE : 0;
36 static struct cmd_tbl cmd_ut_sub[] = {
37 U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""),
39 U_BOOT_CMD_MKENT(bootstd, CONFIG_SYS_MAXARGS, 1, do_ut_bootstd,
42 U_BOOT_CMD_MKENT(common, CONFIG_SYS_MAXARGS, 1, do_ut_common, "", ""),
43 #if defined(CONFIG_UT_DM)
44 U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""),
46 #if defined(CONFIG_UT_ENV)
47 U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""),
50 U_BOOT_CMD_MKENT(fdt, CONFIG_SYS_MAXARGS, 1, do_ut_fdt, "", ""),
52 #ifdef CONFIG_CONSOLE_TRUETYPE
53 U_BOOT_CMD_MKENT(font, CONFIG_SYS_MAXARGS, 1, do_ut_font, "", ""),
55 #ifdef CONFIG_UT_OPTEE
56 U_BOOT_CMD_MKENT(optee, CONFIG_SYS_MAXARGS, 1, do_ut_optee, "", ""),
58 #ifdef CONFIG_UT_OVERLAY
59 U_BOOT_CMD_MKENT(overlay, CONFIG_SYS_MAXARGS, 1, do_ut_overlay, "", ""),
62 U_BOOT_CMD_MKENT(lib, CONFIG_SYS_MAXARGS, 1, do_ut_lib, "", ""),
65 U_BOOT_CMD_MKENT(log, CONFIG_SYS_MAXARGS, 1, do_ut_log, "", ""),
67 U_BOOT_CMD_MKENT(mem, CONFIG_SYS_MAXARGS, 1, do_ut_mem, "", ""),
68 #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR)
69 U_BOOT_CMD_MKENT(setexpr, CONFIG_SYS_MAXARGS, 1, do_ut_setexpr, "",
72 U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_ut_print, "", ""),
74 U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
76 #if CONFIG_IS_ENABLED(UT_UNICODE) && !defined(API_BUILD)
77 U_BOOT_CMD_MKENT(unicode, CONFIG_SYS_MAXARGS, 1, do_ut_unicode, "", ""),
80 U_BOOT_CMD_MKENT(compression, CONFIG_SYS_MAXARGS, 1, do_ut_compression,
82 U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist,
84 U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""),
86 U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, "", ""),
87 #ifdef CONFIG_CMD_ADDRMAP
88 U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""),
90 #ifdef CONFIG_CMD_LOADM
91 U_BOOT_CMD_MKENT(loadm, CONFIG_SYS_MAXARGS, 1, do_ut_loadm, "", ""),
95 static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
102 for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++) {
103 printf("----Running %s tests----\n", cmd_ut_sub[i].name);
104 retval = cmd_ut_sub[i].cmd(cmdtp, flag, 1, &cmd_ut_sub[i].name);
112 static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
117 return CMD_RET_USAGE;
119 /* drop initial "ut" arg */
123 cp = find_cmd_tbl(argv[0], cmd_ut_sub, ARRAY_SIZE(cmd_ut_sub));
126 return cp->cmd(cmdtp, flag, argc, argv);
128 return CMD_RET_USAGE;
131 #ifdef CONFIG_SYS_LONGHELP
132 static char ut_help_text[] =
133 "all - execute all enabled tests\n"
134 #ifdef CONFIG_SANDBOX
135 "ut bloblist - Test bloblist implementation\n"
136 "ut compression - Test compressors and bootm decompression\n"
138 #ifdef CONFIG_BOOTSTD
139 "ut bootstd - Test standard boot implementation\n"
142 "ut dm [test-name]\n"
145 "ut env [test-name]\n"
147 #ifdef CONFIG_CMD_FDT
148 "ut fdt [test-name] - test of the fdt command\n"
150 #ifdef CONFIG_CONSOLE_TRUETYPE
151 "ut font [test-name] - test of the font command\n"
154 "ut lib [test-name] - test library functions\n"
157 "ut log [test-name] - test logging functions\n"
159 "ut mem [test-name] - test memory-related commands\n"
160 #ifdef CONFIG_UT_OPTEE
161 "ut optee [test-name]\n"
163 #ifdef CONFIG_UT_OVERLAY
164 "ut overlay [test-name]\n"
166 "ut print [test-name] - test printing\n"
167 "ut setexpr [test-name] - test setexpr command\n"
168 #ifdef CONFIG_SANDBOX
169 "ut str - Basic test of string functions\n"
171 #ifdef CONFIG_UT_TIME
172 "ut time - Very basic test of time functions\n"
174 #if defined(CONFIG_UT_UNICODE) && \
175 !defined(CONFIG_SPL_BUILD) && !defined(API_BUILD)
176 "ut unicode [test-name] - test Unicode functions\n"
178 #ifdef CONFIG_CMD_ADDRMAP
179 "ut addrmap - Very basic test of addrmap command\n"
181 #ifdef CONFIG_CMD_LOADM
182 "ut loadm [test-name]- test of parameters and load memory blob\n"
184 "All commands accept an optional [-r<runs>] flag before [test-name], to\n"
185 "run each test multiple times (<runs> is in decimal)";
186 #endif /* CONFIG_SYS_LONGHELP */
189 ut, CONFIG_SYS_MAXARGS, 1, do_ut,
190 "unit tests", ut_help_text