]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - test/cmd_ut.c
test: dm: Move the dm tests over to the ut command
[karo-tx-uboot.git] / test / cmd_ut.c
1 /*
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
12 static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
13
14 static cmd_tbl_t cmd_ut_sub[] = {
15         U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""),
16 #if defined(CONFIG_UT_DM)
17         U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""),
18 #endif
19 };
20
21 static 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
37 static 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
57 static char ut_help_text[] =
58         "all - execute all enabled tests\n"
59 #ifdef CONFIG_UT_DM
60         "ut dm [test-name]\n"
61 #endif
62         ;
63 #endif
64
65 U_BOOT_CMD(
66         ut, CONFIG_SYS_MAXARGS, 1, do_ut,
67         "unit tests", ut_help_text
68 );