
Unify the command for running unit tests further by moving the "dm test" command over to "ut dm".
Signed-off-by: Joe Hershberger joe.hershberger@ni.com ---
Changes in v3: -New for version 3
Changes in v2: None
arch/sandbox/Kconfig | 5 ++++- include/dm/test.h | 11 ----------- include/test/suites.h | 1 + test/cmd_ut.c | 6 ++++++ test/dm/Kconfig | 8 ++++---- test/dm/Makefile | 12 ++++++------ test/dm/cmd_dm.c | 21 --------------------- test/dm/test-dm.sh | 2 +- test/dm/test-main.c | 13 ++++++++++++- 9 files changed, 34 insertions(+), 45 deletions(-)
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 8aac96f..4647d11 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -10,7 +10,10 @@ config SYS_BOARD config SYS_CONFIG_NAME default "sandbox"
-config DM_TEST +config UNIT_TEST + default y + +config UT_DM default y
config PCI diff --git a/include/dm/test.h b/include/dm/test.h index 98f2b9e..a4bc5c8 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -202,15 +202,4 @@ void dm_leak_check_start(struct unit_test_state *uts); * @dms: Overall test state */int dm_leak_check_end(struct unit_test_state *uts);
- -/** - * dm_test_main() - Run all or one of the tests - * - * This runs all available driver model tests, or a selected one - * - * @test_name: Name of test to run, or NULL for all - * @return 0 if OK, -ve on error - */ -int dm_test_main(const char *test_name); - #endif diff --git a/include/test/suites.h b/include/test/suites.h index 3031e17..84d3c67 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -8,6 +8,7 @@ #ifndef __TEST_SUITES_H__ #define __TEST_SUITES_H__
+int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
#endif /* __TEST_SUITES_H__ */ diff --git a/test/cmd_ut.c b/test/cmd_ut.c index ca0417f..a0fe34b 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -13,6 +13,9 @@ static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
static cmd_tbl_t cmd_ut_sub[] = { U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""), +#if defined(CONFIG_UT_DM) + U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""), +#endif #if defined(CONFIG_UT_ENV) U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""), #endif @@ -56,6 +59,9 @@ static int do_ut(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #ifdef CONFIG_SYS_LONGHELP static char ut_help_text[] = "all - execute all enabled tests\n" +#ifdef CONFIG_UT_DM + "ut dm [test-name]\n" +#endif #ifdef CONFIG_UT_ENV "ut env [test-name]\n" #endif diff --git a/test/dm/Kconfig b/test/dm/Kconfig index 71feee8..e5b341e 100644 --- a/test/dm/Kconfig +++ b/test/dm/Kconfig @@ -1,8 +1,8 @@ -config DM_TEST - bool "Enable driver model test command" - depends on SANDBOX && CMD_DM && UNIT_TEST +config UT_DM + bool "Enable driver model unit test command" + depends on SANDBOX && UNIT_TEST help - This enables the 'dm test' command which runs a series of unit + This enables the 'ut dm' command which runs a series of unit tests on the driver model code. Each subsystem (uclass) is tested. If all is well then all tests pass although there will be a few messages printed along the way. diff --git a/test/dm/Makefile b/test/dm/Makefile index bcdd687..f5403d5 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -5,15 +5,15 @@ #
obj-$(CONFIG_CMD_DM) += cmd_dm.o -obj-$(CONFIG_DM_TEST) += bus.o -obj-$(CONFIG_DM_TEST) += test-driver.o -obj-$(CONFIG_DM_TEST) += test-fdt.o -obj-$(CONFIG_DM_TEST) += test-main.o -obj-$(CONFIG_DM_TEST) += test-uclass.o +obj-$(CONFIG_UT_DM) += bus.o +obj-$(CONFIG_UT_DM) += test-driver.o +obj-$(CONFIG_UT_DM) += test-fdt.o +obj-$(CONFIG_UT_DM) += test-main.o +obj-$(CONFIG_UT_DM) += test-uclass.o
# Tests for particular subsystems - when enabling driver model for a new # subsystem you must add sandbox tests here. -obj-$(CONFIG_DM_TEST) += core.o +obj-$(CONFIG_UT_DM) += core.o ifneq ($(CONFIG_SANDBOX),) obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_DM_GPIO) += gpio.o diff --git a/test/dm/cmd_dm.c b/test/dm/cmd_dm.c index 2f527e9..5bb2a99 100644 --- a/test/dm/cmd_dm.c +++ b/test/dm/cmd_dm.c @@ -14,7 +14,6 @@ #include <errno.h> #include <asm/io.h> #include <dm/root.h> -#include <dm/test.h> #include <dm/uclass-internal.h>
static void show_devices(struct udevice *dev, int depth, int last_flag) @@ -109,28 +108,9 @@ static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc, return 0; }
-#ifdef CONFIG_DM_TEST -static int do_dm_test(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) -{ - const char *test_name = NULL; - - if (argc > 0) - test_name = argv[0]; - - return dm_test_main(test_name); -} -#define TEST_HELP "\ndm test Run tests" -#else -#define TEST_HELP -#endif - static cmd_tbl_t test_commands[] = { U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""), U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""), -#ifdef CONFIG_DM_TEST - U_BOOT_CMD_MKENT(test, 1, 1, do_dm_test, "", ""), -#endif };
static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) @@ -157,5 +137,4 @@ U_BOOT_CMD( "Driver model low level access", "tree Dump driver model tree ('*' = activated)\n" "dm uclass Dump list of instances for each uclass" - TEST_HELP ); diff --git a/test/dm/test-dm.sh b/test/dm/test-dm.sh index 6158f68..6c97c86 100755 --- a/test/dm/test-dm.sh +++ b/test/dm/test-dm.sh @@ -12,6 +12,6 @@ make O=sandbox -s -j${NUM_CPUS} || die "Cannot build U-Boot" dd if=/dev/zero of=spi.bin bs=1M count=2 echo -n "this is a test" > testflash.bin dd if=/dev/zero bs=1M count=4 >>testflash.bin -./sandbox/u-boot -d test/dm/test.dtb -c "dm test" +./sandbox/u-boot -d test/dm/test.dtb -c "ut dm" rm spi.bin rm testflash.bin diff --git a/test/dm/test-main.c b/test/dm/test-main.c index bbc008b..fd84060 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -5,6 +5,7 @@ */
#include <common.h> +#include <command.h> #include <dm.h> #include <errno.h> #include <malloc.h> @@ -68,7 +69,7 @@ static int dm_test_destroy(struct unit_test_state *uts) return 0; }
-int dm_test_main(const char *test_name) +static int dm_test_main(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); @@ -118,3 +119,13 @@ int dm_test_main(const char *test_name)
return uts->fail_count ? CMD_RET_FAILURE : 0; } + +int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + const char *test_name = NULL; + + if (argc > 1) + test_name = argv[1]; + + return dm_test_main(test_name); +}