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