blob: a65bfeaf3122da5068d5d37e051995068f94d5a1 [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 Hershbergerc812f722015-05-20 14:27:30 -050019#ifdef CONFIG_UT_TIME
20 U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
21#endif
Joe Hershbergerc617ede2015-05-20 14:27:28 -050022};
23
24static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
25{
26 int i;
27 int retval;
28 int any_fail = 0;
29
30 for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++) {
31 printf("----Running %s tests----\n", cmd_ut_sub[i].name);
32 retval = cmd_ut_sub[i].cmd(cmdtp, flag, 1, &cmd_ut_sub[i].name);
33 if (!any_fail)
34 any_fail = retval;
35 }
36
37 return any_fail;
38}
39
40static int do_ut(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
41{
42 cmd_tbl_t *cp;
43
44 if (argc < 2)
45 return CMD_RET_USAGE;
46
47 /* drop initial "ut" arg */
48 argc--;
49 argv++;
50
51 cp = find_cmd_tbl(argv[0], cmd_ut_sub, ARRAY_SIZE(cmd_ut_sub));
52
53 if (cp)
54 return cp->cmd(cmdtp, flag, argc, argv);
55
56 return CMD_RET_USAGE;
57}
58
59#ifdef CONFIG_SYS_LONGHELP
60static char ut_help_text[] =
61 "all - execute all enabled tests\n"
Joe Hershberger40441e02015-05-20 14:27:29 -050062#ifdef CONFIG_UT_DM
63 "ut dm [test-name]\n"
64#endif
Joe Hershbergerc812f722015-05-20 14:27:30 -050065#ifdef CONFIG_UT_TIME
66 "ut time - Very basic test of time functions\n"
67#endif
Joe Hershbergerc617ede2015-05-20 14:27:28 -050068 ;
69#endif
70
71U_BOOT_CMD(
72 ut, CONFIG_SYS_MAXARGS, 1, do_ut,
73 "unit tests", ut_help_text
74);