From patchwork Tue Dec 17 18:07:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe REYNES X-Patchwork-Id: 1211614 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=softathome.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47cmLz2MWPz9sR8 for ; Wed, 18 Dec 2019 05:07:23 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 92D0C814DE; Tue, 17 Dec 2019 19:07:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id C0F96814E1; Tue, 17 Dec 2019 19:07:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: ** X-Spam-Status: No, score=2.9 required=5.0 tests=KHOP_HELO_FCRDNS, SPF_HELO_NONE, SUBJ_OBFU_PUNCT_FEW,SUBJ_OBFU_PUNCT_MANY,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from vrout10.yaziba.net (vrout10-bl2.yaziba.net [185.56.204.56]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C5B87808A1 for ; Tue, 17 Dec 2019 19:07:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=philippe.reynes@softathome.com Received: from mtaout10.int.yaziba.net (mtaout10.int.yaziba.net [10.4.20.36]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout10.yaziba.net (mx10.yaziba.net) with ESMTPS id 420D151F31; Tue, 17 Dec 2019 19:07:06 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mtaout10.int.yaziba.net (Postfix) with ESMTP id 6349E1602BE; Tue, 17 Dec 2019 19:07:06 +0100 (CET) Received: from mtaout10.int.yaziba.net ([127.0.0.1]) by localhost (mtaout10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id n4xC-EvmWxvD; Tue, 17 Dec 2019 19:07:06 +0100 (CET) Received: from sahnlpt0333.softathome.com (unknown [149.6.166.170]) by mtaout10.int.yaziba.net (Postfix) with ESMTPSA id 485311602B8; Tue, 17 Dec 2019 19:07:06 +0100 (CET) From: Philippe Reynes To: joe.hershberger@ni.com, wd@denx.de, xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, heiko.stuebner@theobroma-systems.com, simon.k.r.goldschmidt@gmail.com, jwerner@chromium.org Subject: [PATCH] cmd_ut: add a parameter prefix to the function cmd_ut_category Date: Tue, 17 Dec 2019 19:07:04 +0100 Message-Id: <1576606024-5164-1-git-send-email-philippe.reynes@softathome.com> X-Mailer: git-send-email 2.7.4 X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: 0 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrvddtjedguddtkecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofestddtredtredttdenucfhrhhomheprfhhihhlihhpphgvucftvgihnhgvshcuoehphhhilhhiphhpvgdrrhgvhihnvghssehsohhfthgrthhhohhmvgdrtghomheqnecukfhppedugeelrdeirdduieeirddujedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean There is black magic in the file conftest.py that list all the test unit. Then, all those test unit are called in pytest. This call is done with the end of the name (for example checksum if the full name is bloblist_test_checksum). The result is that only test for dm are really executed. by pytest, all others tests are listed but never executed. This behaviour happens because the dm test unit only check the end of the name and others tests checks the full name. To fix this issue, I've added a prefix to the function cmd_ut_category, and this prefix is removed when looking for the unit test. Signed-off-by: Philippe Reynes Tested-by: Heinrich Schuchardt --- include/test/suites.h | 4 +++- test/bloblist.c | 3 ++- test/cmd_ut.c | 12 ++++++++++-- test/compression.c | 3 ++- test/env/cmd_ut_env.c | 3 ++- test/lib/cmd_ut_lib.c | 2 +- test/optee/cmd_ut_optee.c | 6 +++--- test/overlay/cmd_ut_overlay.c | 2 +- test/unicode_ut.c | 3 ++- 9 files changed, 26 insertions(+), 12 deletions(-) diff --git a/include/test/suites.h b/include/test/suites.h index 20970f0..0748185 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -13,6 +13,7 @@ struct unit_test; * cmd_ut_category() - Run a category of unit tests * * @name: Category name + * @prefix: Prefix of test name * @tests: List of tests to run * @n_ents: Number of tests in @tests * @argc: Argument count provided. Must be >= 1. If this is 1 then all @@ -20,7 +21,8 @@ struct unit_test; * @argv: Arguments: argv[1] is the test to run (if @argc >= 2) * @return 0 if OK, CMD_RET_FAILURE on failure */ -int cmd_ut_category(const char *name, struct unit_test *tests, int n_ents, +int cmd_ut_category(const char *name, const char *prefix, + struct unit_test *tests, int n_ents, int argc, char * const argv[]); int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/bloblist.c b/test/bloblist.c index 89bdb01..d0f7296 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -183,5 +183,6 @@ int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) bloblist_test); const int n_ents = ll_entry_count(struct unit_test, bloblist_test); - return cmd_ut_category("bloblist", tests, n_ents, argc, argv); + return cmd_ut_category("bloblist", "bloblist_test_", + tests, n_ents, argc, argv); } diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 2781f8b..400719e 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -11,17 +11,25 @@ static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); -int cmd_ut_category(const char *name, struct unit_test *tests, int n_ents, +int cmd_ut_category(const char *name, const char *prefix, + struct unit_test *tests, int n_ents, int argc, char * const argv[]) { struct unit_test_state uts = { .fail_count = 0 }; struct unit_test *test; + int prefix_len = prefix ? strlen(prefix) : 0; if (argc == 1) printf("Running %d %s tests\n", n_ents, name); for (test = tests; test < tests + n_ents; test++) { - if (argc > 1 && strcmp(argv[1], test->name)) + const char *test_name = test->name; + + /* Remove the prefix */ + if (!strncmp(test_name, prefix, prefix_len)) + test_name += prefix_len; + + if (argc > 1 && strcmp(argv[1], test_name)) continue; printf("Test: %s\n", test->name); diff --git a/test/compression.c b/test/compression.c index 48dccc0..cf040d7 100644 --- a/test/compression.c +++ b/test/compression.c @@ -540,5 +540,6 @@ int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) compression_test); const int n_ents = ll_entry_count(struct unit_test, compression_test); - return cmd_ut_category("compression", tests, n_ents, argc, argv); + return cmd_ut_category("compression", "compression_test_", + tests, n_ents, argc, argv); } diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c index 54041a0..ad67dbe 100644 --- a/test/env/cmd_ut_env.c +++ b/test/env/cmd_ut_env.c @@ -15,5 +15,6 @@ int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct unit_test *tests = ll_entry_start(struct unit_test, env_test); const int n_ents = ll_entry_count(struct unit_test, env_test); - return cmd_ut_category("environment", tests, n_ents, argc, argv); + return cmd_ut_category("environment", "env_test_", + tests, n_ents, argc, argv); } diff --git a/test/lib/cmd_ut_lib.c b/test/lib/cmd_ut_lib.c index eb90e53..c73e8d7 100644 --- a/test/lib/cmd_ut_lib.c +++ b/test/lib/cmd_ut_lib.c @@ -16,5 +16,5 @@ int do_ut_lib(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct unit_test *tests = ll_entry_start(struct unit_test, lib_test); const int n_ents = ll_entry_count(struct unit_test, lib_test); - return cmd_ut_category("lib", tests, n_ents, argc, argv); + return cmd_ut_category("lib", "lib_test_", tests, n_ents, argc, argv); } diff --git a/test/optee/cmd_ut_optee.c b/test/optee/cmd_ut_optee.c index 670682f..0927103 100644 --- a/test/optee/cmd_ut_optee.c +++ b/test/optee/cmd_ut_optee.c @@ -129,20 +129,20 @@ int do_ut_optee(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ut_assertok(optee_copy_fdt_nodes(fdt_no_optee, fdt)); expect_success = false; - ret = cmd_ut_category("optee", tests, n_ents, argc, argv); + ret = cmd_ut_category("optee", "", tests, n_ents, argc, argv); /* (2) Try to copy optee nodes from prefilled dt */ ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt)); expect_success = true; - ret = cmd_ut_category("optee", tests, n_ents, argc, argv); + ret = cmd_ut_category("optee", "", tests, n_ents, argc, argv); /* (3) Try to copy OP-TEE nodes into a already filled DT */ ut_assertok(fdt_open_into(fdt_optee, fdt, FDT_COPY_SIZE)); ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt)); expect_success = true; - ret = cmd_ut_category("optee", tests, n_ents, argc, argv); + ret = cmd_ut_category("optee", "", tests, n_ents, argc, argv); free(fdt); return ret; diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c index fc2491d..d0083fd6b 100644 --- a/test/overlay/cmd_ut_overlay.c +++ b/test/overlay/cmd_ut_overlay.c @@ -272,7 +272,7 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* Apply the stacked overlay */ ut_assertok(fdt_overlay_apply(fdt, fdt_overlay_stacked_copy)); - ret = cmd_ut_category("overlay", tests, n_ents, argc, argv); + ret = cmd_ut_category("overlay", "", tests, n_ents, argc, argv); free(fdt_overlay_stacked_copy); err3: diff --git a/test/unicode_ut.c b/test/unicode_ut.c index 8875cdc..47532a6 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -585,5 +585,6 @@ int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct unit_test *tests = ll_entry_start(struct unit_test, unicode_test); const int n_ents = ll_entry_count(struct unit_test, unicode_test); - return cmd_ut_category("Unicode", tests, n_ents, argc, argv); + return cmd_ut_category("Unicode", "unicode_test_", + tests, n_ents, argc, argv); }