]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
test: dm: Move the dm tests over to the ut command
authorJoe Hershberger <joe.hershberger@ni.com>
Wed, 20 May 2015 19:27:29 +0000 (14:27 -0500)
committerTom Rini <trini@konsulko.com>
Thu, 21 May 2015 13:16:17 +0000 (09:16 -0400)
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>
Acked-by: Simon Glass <sjg@chromium.org>
configs/sandbox_defconfig
include/dm/test.h
include/test/suites.h
test/cmd_ut.c
test/dm/Kconfig
test/dm/Makefile
test/dm/cmd_dm.c
test/dm/test-dm.sh
test/dm/test-main.c

index 8e0c4cd5fe4215c4bc1ef4e6a87d296ea12a3692..e69f1475c4b0cc3a24c39cd616d368b42fa2c652 100644 (file)
@@ -38,4 +38,4 @@ CONFIG_USB_STORAGE=y
 CONFIG_DM_RTC=y
 CONFIG_ERRNO_STR=y
 CONFIG_CMD_UT_TIME=y
-CONFIG_DM_TEST=y
+CONFIG_UT_DM=y
index 98f2b9e996317fbc26917e69d3f5da808fbecd75..a4bc5c8404aef87a6ec04a05f319d76d6f7c1eed 100644 (file)
@@ -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
index eae132ec2ffc1d47e51ce85a11b155f9725467a1..27813a362ec1a8d2386485db0960b9208af5ec9d 100644 (file)
@@ -8,4 +8,6 @@
 #ifndef __TEST_SUITES_H__
 #define __TEST_SUITES_H__
 
+int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+
 #endif /* __TEST_SUITES_H__ */
index 5d03321efedbac5c8388577b89d83582d3fa61ef..08001cdbc0f0f0f20b9b0387c2a10c9587c287c2 100644 (file)
@@ -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
 };
 
 static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -53,6 +56,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
        ;
 #endif
 
index 3ca154fcc56bcb7cbc2701e9e7d60b30b56df9dc..0fa3074e9df1e66468e6a081ca4d4a58fe90ed1b 100644 (file)
@@ -1,9 +1,9 @@
-config DM_TEST
-       bool "Enable driver model test command"
-       depends on SANDBOX && CMD_DM
+config UT_DM
+       bool "Enable driver model unit test command"
+       depends on SANDBOX
        select 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.
index 07e782e7ce12a27708a2ca735e935c88f498d208..19ad2fb99f660ec25c622d4447d44f1b07adf039 100644 (file)
@@ -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
index 2f527e959b57e3e819e25efc240663922f267d4d..5bb2a99c8f0b5f207e61aea6ae990b2902eff524 100644 (file)
@@ -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
 );
index 5c47ffd5d23c74321c92d04c00b16120f4339165..1a0f1509b4156408453b089cf3e975a5e775f5e7 100755 (executable)
@@ -11,6 +11,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 ./sandbox/arch/sandbox/dts/test.dtb -c "dm test"
+./sandbox/u-boot -d ./sandbox/arch/sandbox/dts/test.dtb -c "ut dm"
 rm spi.bin
 rm testflash.bin
index 5e36e7654319c61be4dad5b2a4538c94e9e08762..a2fe1765791191b9cd96281b9dc64962b06711bb 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <command.h>
 #include <dm.h>
 #include <errno.h>
 #include <malloc.h>
@@ -70,7 +71,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);
@@ -115,3 +116,13 @@ int dm_test_main(const char *test_name)
 
        return 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);
+}