Joe Hershberger | c617ede | 2015-05-20 14:27:28 -0500 | [diff] [blame] | 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, "", ""), |
Joe Hershberger | 40441e0 | 2015-05-20 14:27:29 -0500 | [diff] [blame] | 16 | #if defined(CONFIG_UT_DM) |
| 17 | U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""), |
| 18 | #endif |
Joe Hershberger | 421f86f | 2015-05-20 14:27:36 -0500 | [diff] [blame] | 19 | #if defined(CONFIG_UT_ENV) |
| 20 | U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""), |
| 21 | #endif |
Maxime Ripard | f2a9942 | 2016-07-05 10:26:46 +0200 | [diff] [blame] | 22 | #ifdef CONFIG_UT_OVERLAY |
| 23 | U_BOOT_CMD_MKENT(overlay, CONFIG_SYS_MAXARGS, 1, do_ut_overlay, "", ""), |
| 24 | #endif |
Joe Hershberger | c812f72 | 2015-05-20 14:27:30 -0500 | [diff] [blame] | 25 | #ifdef CONFIG_UT_TIME |
| 26 | U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""), |
| 27 | #endif |
Joe Hershberger | c617ede | 2015-05-20 14:27:28 -0500 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 31 | { |
| 32 | int i; |
| 33 | int retval; |
| 34 | int any_fail = 0; |
| 35 | |
| 36 | for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++) { |
| 37 | printf("----Running %s tests----\n", cmd_ut_sub[i].name); |
| 38 | retval = cmd_ut_sub[i].cmd(cmdtp, flag, 1, &cmd_ut_sub[i].name); |
| 39 | if (!any_fail) |
| 40 | any_fail = retval; |
| 41 | } |
| 42 | |
| 43 | return any_fail; |
| 44 | } |
| 45 | |
| 46 | static int do_ut(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 47 | { |
| 48 | cmd_tbl_t *cp; |
| 49 | |
| 50 | if (argc < 2) |
| 51 | return CMD_RET_USAGE; |
| 52 | |
| 53 | /* drop initial "ut" arg */ |
| 54 | argc--; |
| 55 | argv++; |
| 56 | |
| 57 | cp = find_cmd_tbl(argv[0], cmd_ut_sub, ARRAY_SIZE(cmd_ut_sub)); |
| 58 | |
| 59 | if (cp) |
| 60 | return cp->cmd(cmdtp, flag, argc, argv); |
| 61 | |
| 62 | return CMD_RET_USAGE; |
| 63 | } |
| 64 | |
| 65 | #ifdef CONFIG_SYS_LONGHELP |
| 66 | static char ut_help_text[] = |
| 67 | "all - execute all enabled tests\n" |
Joe Hershberger | 40441e0 | 2015-05-20 14:27:29 -0500 | [diff] [blame] | 68 | #ifdef CONFIG_UT_DM |
| 69 | "ut dm [test-name]\n" |
| 70 | #endif |
Joe Hershberger | 421f86f | 2015-05-20 14:27:36 -0500 | [diff] [blame] | 71 | #ifdef CONFIG_UT_ENV |
| 72 | "ut env [test-name]\n" |
| 73 | #endif |
Maxime Ripard | f2a9942 | 2016-07-05 10:26:46 +0200 | [diff] [blame] | 74 | #ifdef CONFIG_UT_OVERLAY |
| 75 | "ut overlay [test-name]\n" |
| 76 | #endif |
Joe Hershberger | c812f72 | 2015-05-20 14:27:30 -0500 | [diff] [blame] | 77 | #ifdef CONFIG_UT_TIME |
| 78 | "ut time - Very basic test of time functions\n" |
| 79 | #endif |
Joe Hershberger | c617ede | 2015-05-20 14:27:28 -0500 | [diff] [blame] | 80 | ; |
| 81 | #endif |
| 82 | |
| 83 | U_BOOT_CMD( |
| 84 | ut, CONFIG_SYS_MAXARGS, 1, do_ut, |
| 85 | "unit tests", ut_help_text |
| 86 | ); |