From patchwork Wed May 20 19:27:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 474619 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 554DA140293 for ; Thu, 21 May 2015 05:55:38 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1D53D4B639; Wed, 20 May 2015 21:55:36 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9cshjIHTbhUm; Wed, 20 May 2015 21:55:35 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 050A54B62C; Wed, 20 May 2015 21:52:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D8C844B61D for ; Wed, 20 May 2015 21:33:52 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3wNMAg7HadId for ; Wed, 20 May 2015 21:33:45 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by theia.denx.de (Postfix) with ESMTPS id AF9384B64D for ; Wed, 20 May 2015 21:29:52 +0200 (CEST) Received: from us-aus-mgwout1.amer.corp.natinst.com (nb-snip2-1338.natinst.com [130.164.19.135]) by us-aus-skprod2.natinst.com (8.15.0.59/8.15.0.59) with ESMTP id t4KJTjKN016864; Wed, 20 May 2015 14:29:45 -0500 Received: from linux-xvxi.natinst.com ([130.164.14.198]) by us-aus-mgwout1.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP6 HF1218) with ESMTP id 2015052014294583-267330 ; Wed, 20 May 2015 14:29:45 -0500 From: Joe Hershberger To: u-boot@lists.denx.de Date: Wed, 20 May 2015 14:27:29 -0500 Message-Id: <1432150059-24238-17-git-send-email-joe.hershberger@ni.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1432150059-24238-1-git-send-email-joe.hershberger@ni.com> References: <20150520145807.GC5496@bill-the-cat> <1432150059-24238-1-git-send-email-joe.hershberger@ni.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 05/20/2015 02:29:45 PM, Serialize by Router on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 05/20/2015 02:29:45 PM, Serialize complete at 05/20/2015 02:29:45 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2015-05-20_05:, , signatures=0 Cc: Tom Rini , Joe Hershberger Subject: [U-Boot] [PATCH v5 16/26] test: dm: Move the dm tests over to the ut command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Unify the command for running unit tests further by moving the "dm test" command over to "ut dm". Signed-off-by: Joe Hershberger Acked-by: Simon Glass --- Changes in v5: None Changes in v4: None Changes in v3: -New for version 3 Changes in v2: None configs/sandbox_defconfig | 2 +- include/dm/test.h | 11 ----------- include/test/suites.h | 2 ++ 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, 32 insertions(+), 45 deletions(-) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 8e0c4cd..e69f147 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -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 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 eae132e..27813a3 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -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__ */ diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 5d03321..08001cd 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 }; 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 diff --git a/test/dm/Kconfig b/test/dm/Kconfig index 3ca154f..0fa3074 100644 --- a/test/dm/Kconfig +++ b/test/dm/Kconfig @@ -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. diff --git a/test/dm/Makefile b/test/dm/Makefile index 07e782e..19ad2fb 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 #include #include -#include #include 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 5c47ffd..1a0f150 100755 --- a/test/dm/test-dm.sh +++ b/test/dm/test-dm.sh @@ -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 diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 5e36e76..a2fe176 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -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); +}