blob: 08001cdbc0f0f0f20b9b0387c2a10c9587c287c2 [file] [log] [blame]
Joe Hershbergerc617ede2015-05-20 14:27:28 -05001/*
2 * (C) Copyright 2015
3 * Joe Hershberger, National Instruments, joe.hershberger@ni.com
4 *
5 * SPDX-License-Identifier: GPL-2.0
6 */
7
8#include <common.h>
9#include <command.h>
10#include <test/suites.h>
11
12static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
13
14static cmd_tbl_t cmd_ut_sub[] = {
15 U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""),
Joe Hershberger40441e02015-05-20 14:27:29 -050016#if defined(CONFIG_UT_DM)
17 U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""),
18#endif
Joe Hershbergerc617ede2015-05-20 14:27:28 -050019};
20
21static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
22{
23 int i;
24 int retval;
25 int any_fail = 0;
26
27 for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++) {
28 printf("----Running %s tests----\n", cmd_ut_sub[i].name);
29 retval = cmd_ut_sub[i].cmd(cmdtp, flag, 1, &cmd_ut_sub[i].name);
30 if (!any_fail)
31 any_fail = retval;
32 }
33
34 return any_fail;
35}
36
37static int do_ut(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
38{
39 cmd_tbl_t *cp;
40
41 if (argc < 2)
42 return CMD_RET_USAGE;
43
44 /* drop initial "ut" arg */
45 argc--;
46 argv++;
47
48 cp = find_cmd_tbl(argv[0], cmd_ut_sub, ARRAY_SIZE(cmd_ut_sub));
49
50 if (cp)
51 return cp->cmd(cmdtp, flag, argc, argv);
52
53 return CMD_RET_USAGE;
54}
55
56#ifdef CONFIG_SYS_LONGHELP
57static char ut_help_text[] =
58 "all - execute all enabled tests\n"
Joe Hershberger40441e02015-05-20 14:27:29 -050059#ifdef CONFIG_UT_DM
60 "ut dm [test-name]\n"
61#endif
Joe Hershbergerc617ede2015-05-20 14:27:28 -050062 ;
63#endif
64
65U_BOOT_CMD(
66 ut, CONFIG_SYS_MAXARGS, 1, do_ut,
67 "unit tests", ut_help_text
68);