From 08a22b2cc44414f3de70e829bf83e67888bd7196 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:23 -0700 Subject: test: Drop unused suite prototypes Drop some the prototypes for functions which were removed in earlier series. Signed-off-by: Simon Glass --- include/test/suites.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 2ceef577f7f..e40ad634702 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -36,8 +36,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); @@ -55,14 +53,9 @@ int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_print(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_time(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); #endif /* __TEST_SUITES_H__ */ -- cgit v1.3.1 From 238ba333c369b6cc521527e0783e6ac24368569f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:24 -0700 Subject: test: Rename test_get_state() to ut_get_state() Rename this function and test_set_state() so use the same ut_ prefix as other functions in ut.h Signed-off-by: Simon Glass --- include/test/ut.h | 8 ++++---- test/dm/test-driver.c | 10 +++++----- test/dm/test-uclass.c | 8 ++++---- test/test-main.c | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/test/ut.h b/include/test/ut.h index c8838dad096..2e4d8edf826 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -466,18 +466,18 @@ void ut_unsilence_console(struct unit_test_state *uts); void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays); /** - * test_get_state() - Get the active test state + * ut_state_get() - Get the active test state * * Return: the currently active test state, or NULL if none */ -struct unit_test_state *test_get_state(void); +struct unit_test_state *ut_get_state(void); /** - * test_set_state() - Set the active test state + * ut_set_state() - Set the active test state * * @uts: Test state to use as currently active test state, or NULL if none */ -void test_set_state(struct unit_test_state *uts); +void ut_set_state(struct unit_test_state *uts); /** * ut_run_tests() - Run a set of tests diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c index 851177c3018..759de3a5f77 100644 --- a/test/dm/test-driver.c +++ b/test/dm/test-driver.c @@ -35,7 +35,7 @@ static const struct test_ops test_ops = { static int test_bind(struct udevice *dev) { - struct unit_test_state *uts = test_get_state(); + struct unit_test_state *uts = ut_get_state(); /* Private data should not be allocated */ ut_assert(!dev_get_priv(dev)); @@ -46,7 +46,7 @@ static int test_bind(struct udevice *dev) static int test_probe(struct udevice *dev) { - struct unit_test_state *uts = test_get_state(); + struct unit_test_state *uts = ut_get_state(); struct dm_test_priv *priv = dev_get_priv(dev); /* Private data should be allocated */ @@ -59,7 +59,7 @@ static int test_probe(struct udevice *dev) static int test_remove(struct udevice *dev) { - struct unit_test_state *uts = test_get_state(); + struct unit_test_state *uts = ut_get_state(); /* Private data should still be allocated */ ut_assert(dev_get_priv(dev)); @@ -70,7 +70,7 @@ static int test_remove(struct udevice *dev) static int test_unbind(struct udevice *dev) { - struct unit_test_state *uts = test_get_state(); + struct unit_test_state *uts = ut_get_state(); /* Private data should not be allocated */ ut_assert(!dev_get_priv(dev)); @@ -121,7 +121,7 @@ static int test_manual_bind(struct udevice *dev) static int test_manual_probe(struct udevice *dev) { - struct unit_test_state *uts = test_get_state(); + struct unit_test_state *uts = ut_get_state(); dm_testdrv_op_count[DM_TEST_OP_PROBE]++; if (!uts->force_fail_alloc) diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c index 9a80cc63667..be4108bbecb 100644 --- a/test/dm/test-uclass.c +++ b/test/dm/test-uclass.c @@ -28,7 +28,7 @@ int test_ping(struct udevice *dev, int pingval, int *pingret) static int test_post_bind(struct udevice *dev) { - struct unit_test_state *uts = test_get_state(); + struct unit_test_state *uts = ut_get_state(); struct dm_test_perdev_uc_pdata *uc_pdata; dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++; @@ -54,7 +54,7 @@ static int test_pre_unbind(struct udevice *dev) static int test_pre_probe(struct udevice *dev) { struct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev); - struct unit_test_state *uts = test_get_state(); + struct unit_test_state *uts = ut_get_state(); dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE]++; ut_assert(priv); @@ -65,7 +65,7 @@ static int test_pre_probe(struct udevice *dev) static int test_post_probe(struct udevice *dev) { - struct unit_test_state *uts = test_get_state(); + struct unit_test_state *uts = ut_get_state(); struct udevice *prev = list_entry(dev->uclass_node.prev, struct udevice, uclass_node); @@ -100,7 +100,7 @@ static int test_pre_remove(struct udevice *dev) static int test_init(struct uclass *uc) { - struct unit_test_state *uts = test_get_state(); + struct unit_test_state *uts = ut_get_state(); dm_testdrv_op_count[DM_TEST_OP_INIT]++; ut_assert(uclass_get_priv(uc)); diff --git a/test/test-main.c b/test/test-main.c index 8d764892fa6..cfb3504941d 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -63,12 +63,12 @@ static enum fdtchk_t fdt_action(void) /* This is valid when a test is running, NULL otherwise */ static struct unit_test_state *cur_test_state; -struct unit_test_state *test_get_state(void) +struct unit_test_state *ut_get_state(void) { return cur_test_state; } -void test_set_state(struct unit_test_state *uts) +void ut_set_state(struct unit_test_state *uts) { cur_test_state = uts; } @@ -466,7 +466,7 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test, printf("Test: %s: %s%s\n", test_name, fname, note); /* Allow access to test state from drivers */ - test_set_state(uts); + ut_set_state(uts); ret = test_pre_run(uts, test); if (ret == -EAGAIN) @@ -482,7 +482,7 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test, if (ret) return ret; - test_set_state( NULL); + ut_set_state(NULL); return 0; } -- cgit v1.3.1 From 94b5284398e52c44bde977aa8b1fa1f5992955a2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:26 -0700 Subject: test: Pass the test-state into ut_run_list() Pass this into the function so that callers can inspect the state afterwards. Signed-off-by: Simon Glass --- arch/sandbox/cpu/spl.c | 5 ++++- include/test/ut.h | 29 ++++++++++++++++++++++++++--- test/cmd_ut.c | 5 ++++- test/test-main.c | 35 +++++++++++++++++------------------ 4 files changed, 51 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 7056cfd0180..0ad23e4ba95 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -147,10 +147,13 @@ void spl_board_init(void) if (state->run_unittests) { struct unit_test *tests = UNIT_TEST_ALL_START(); const int count = UNIT_TEST_ALL_COUNT(); + struct unit_test_state uts; int ret; - ret = ut_run_list("spl", NULL, tests, count, + ut_init_state(&uts); + ret = ut_run_list(&uts, "spl", NULL, tests, count, state->select_unittests, 1, false, NULL); + ut_uninit_state(&uts); /* continue execution into U-Boot */ } } diff --git a/include/test/ut.h b/include/test/ut.h index 2e4d8edf826..a51defc3b90 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -479,12 +479,34 @@ struct unit_test_state *ut_get_state(void); */ void ut_set_state(struct unit_test_state *uts); +/** + * ut_init_state() - Set up a new test state + * + * This must be called before using the test state with ut_run_tests() + * + * @uts: Test state to init + */ +void ut_init_state(struct unit_test_state *uts); + +/** + * ut_uninit_state() - Free memory used by test state + * + * This must be called before after the test state with ut_run_tests(). To later + * reuse the test state to run more tests, call test_state_init() first + * + * @uts: Test state to uninit + */ +void ut_uninit_state(struct unit_test_state *uts); + /** * ut_run_tests() - Run a set of tests * * This runs the test, handling any preparation and clean-up needed. It prints * the name of each test before running it. * + * @uts: Unit-test state, which must be ready for use, i.e. ut_init_state() + * has been called. The caller is responsible for calling + * ut_uninit_state() after this function returns * @category: Category of these tests. This is a string printed at the start to * announce the the number of tests * @prefix: String prefix for the tests. Any tests that have this prefix will be @@ -503,8 +525,9 @@ void ut_set_state(struct unit_test_state *uts); * Pass NULL to disable this * Return: 0 if all tests passed, -1 if any failed */ -int ut_run_list(const char *name, const char *prefix, struct unit_test *tests, - int count, const char *select_name, int runs_per_test, - bool force_run, const char *test_insert); +int ut_run_list(struct unit_test_state *uts, const char *category, + const char *prefix, struct unit_test *tests, int count, + const char *select_name, int runs_per_test, bool force_run, + const char *test_insert); #endif diff --git a/test/cmd_ut.c b/test/cmd_ut.c index a14dbf4ca5e..69f0230e556 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -21,6 +21,7 @@ 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; const char *test_insert = NULL; int runs_per_text = 1; bool force_run = false; @@ -44,9 +45,11 @@ int cmd_ut_category(const char *name, const char *prefix, argc--; } - ret = ut_run_list(name, prefix, tests, n_ents, + ut_init_state(&uts); + ret = ut_run_list(&uts, name, prefix, tests, n_ents, cmd_arg1(argc, argv), runs_per_text, force_run, test_insert); + ut_uninit_state(&uts); return ret ? CMD_RET_FAILURE : 0; } diff --git a/test/test-main.c b/test/test-main.c index 871fc1f22b4..e12c5a95e45 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -673,15 +673,15 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix, return uts->fail_count ? -EBADF : 0; } -int ut_run_list(const char *category, const char *prefix, - struct unit_test *tests, int count, const char *select_name, - int runs_per_test, bool force_run, const char *test_insert) +int ut_run_list(struct unit_test_state *uts, const char *category, + const char *prefix, struct unit_test *tests, int count, + const char *select_name, int runs_per_test, bool force_run, + const char *test_insert) { - struct unit_test_state uts; + ; bool has_dm_tests = false; int ret; - ut_init_state(&uts); if (!CONFIG_IS_ENABLED(OF_PLATDATA) && ut_list_has_dm_tests(tests, count, prefix, select_name)) { has_dm_tests = true; @@ -699,32 +699,31 @@ int ut_run_list(const char *category, const char *prefix, if (!select_name) printf("Running %d %s tests\n", count, category); - uts.of_root = gd_of_root(); - uts.runs_per_test = runs_per_test; + uts->of_root = gd_of_root(); + uts->runs_per_test = runs_per_test; if (fdt_action() == FDTCHK_COPY && gd->fdt_blob) { - uts.fdt_size = fdt_totalsize(gd->fdt_blob); - uts.fdt_copy = os_malloc(uts.fdt_size); - if (!uts.fdt_copy) { + uts->fdt_size = fdt_totalsize(gd->fdt_blob); + uts->fdt_copy = os_malloc(uts->fdt_size); + if (!uts->fdt_copy) { printf("Out of memory for device tree copy\n"); return -ENOMEM; } - memcpy(uts.fdt_copy, gd->fdt_blob, uts.fdt_size); + memcpy(uts->fdt_copy, gd->fdt_blob, uts->fdt_size); } - uts.force_run = force_run; - ret = ut_run_tests(&uts, prefix, tests, count, select_name, + uts->force_run = force_run; + ret = ut_run_tests(uts, prefix, tests, count, select_name, test_insert); /* Best efforts only...ignore errors */ if (has_dm_tests) - dm_test_restore(uts.of_root); + dm_test_restore(uts->of_root); - if (uts.skip_count) - printf("Skipped: %d, ", uts.skip_count); + if (uts->skip_count) + printf("Skipped: %d, ", uts->skip_count); if (ret == -ENOENT) printf("Test '%s' not found\n", select_name); else - printf("Failures: %d\n", uts.fail_count); - ut_uninit_state(&uts); + printf("Failures: %d\n", uts->fail_count); return ret; } -- cgit v1.3.1 From f0781acc37fe91eebc8ff5b882503ecd6174af5a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:27 -0700 Subject: Improve support for linker lists in data structures A limitation of most linker_list macros is that they cannot easily be used in data structures. This is because they include code inside their expressions. Provide a way to support this, with new ll_start_decl() and ll_end_decl() macros. Signed-off-by: Simon Glass --- include/linker_lists.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'include') diff --git a/include/linker_lists.h b/include/linker_lists.h index f9a2ee0c762..0f4a2d686e2 100644 --- a/include/linker_lists.h +++ b/include/linker_lists.h @@ -186,6 +186,63 @@ _ll_result; \ }) +/** + * Declares a symbol that points to the start/end of the list. + * + * @_sym: Arbitrary name for the symbol (to use later in the file) + * @_type: Data type of the entry + * @_list: Name of the list in which this entry is placed + * + * The name of the (new) symbol is arbitrary and can be anything that is not + * already declared in the file where it appears. It is provided in _sym and + * can then be used (later in the same file) within a data structure. + * The _type and _list arguments must match those passed to ll_entry_start/end() + * + * Example: + * + * Here we want to record the start of each sub-command in a list. We have two + * sub-commands, 'bob' and 'mary'. + * + * In bob.c:: + * + * ll_entry_declare(struct my_sub_cmd, bob_cmd, cmd_sub) = {...}; + * + * In mary.c:: + * + * ll_entry_declare(struct my_sub_cmd, mary_cmd, cmd_sub) = {...}; + * + * In a different file where we want a list the start of all sub-commands. + * It is not possible to use ll_entry_start() in a data structure, due to its + * use of code inside expressions - ({ ... }) - so this fails to compile: + * + * In sub_cmds.c:: + * + * struct cmd_sub *my_list[] = { + * ll_entry_start(cmd_sub, bob), + * ll_entry_start(cmd_sub, bob), + * }; + * + * Instead, we can use:: + * + * ll_start_decl(bob, struct my_sub_cmd, cmd_sub); + * ll_start_decl(mary, struct my_sub_cmd, cmd_sub); + * + * struct cmd_sub *my_list[] = { + * bob, + * mary, + * }; + * + * So 'bob' is declared as symbol, a struct my_list * which points to the + * start of the bob sub-commands. It is then used in my_list[] + */ +#define ll_start_decl(_sym, _type, _list) \ + static _type _sym[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ + __maybe_unused __section("__u_boot_list_2_" #_list "_1") + +#define ll_end_decl(_sym, _type, _list) \ + static _type _sym[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ + __maybe_unused __section("__u_boot_list_2_" #_list "_3") + /** * ll_entry_get() - Retrieve entry from linker-generated array by name * @_type: Data type of the entry -- cgit v1.3.1 From 4d31a3bd3370f8fc9d1a484129770a4de4a15d70 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:29 -0700 Subject: test: Rename test suites to match their linker-list name Some suites have a different name from that used in the linker list. That makes it hard to programmatically match the name printed when the suite runs to the linker-list name it has. Update the names so they are the same. Signed-off-by: Simon Glass --- include/test/cmd.h | 2 +- test/boot/upl.c | 3 +-- test/cmd/addrmap.c | 2 +- test/cmd/cmd_ut_cmd.c | 4 ++-- test/cmd/exit.c | 2 +- test/cmd/mem.c | 2 +- test/cmd/pci_mps.c | 2 +- test/cmd/setexpr.c | 2 +- test/dm/test-dm.c | 3 +-- test/env/cmd_ut_env.c | 3 +-- 10 files changed, 11 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/test/cmd.h b/include/test/cmd.h index c200570e423..3d1e3e3bddb 100644 --- a/include/test/cmd.h +++ b/include/test/cmd.h @@ -10,6 +10,6 @@ #include /* Declare a new command test */ -#define CMD_TEST(_name, _flags) UNIT_TEST(_name, _flags, cmd_test) +#define CMD_TEST(_name, _flags) UNIT_TEST(_name, _flags, cmd) #endif /* __TEST_CMD_H__ */ diff --git a/test/boot/upl.c b/test/boot/upl.c index 99f02b7951b..ef65cf34055 100644 --- a/test/boot/upl.c +++ b/test/boot/upl.c @@ -432,6 +432,5 @@ int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct unit_test *tests = UNIT_TEST_SUITE_START(upl_test); const int n_ents = UNIT_TEST_SUITE_COUNT(upl_test); - return cmd_ut_category("cmd_upl", "cmd_upl_", tests, n_ents, argc, - argv); + return cmd_ut_category("upl", "cmd_upl_", tests, n_ents, argc, argv); } diff --git a/test/cmd/addrmap.c b/test/cmd/addrmap.c index b34be895f5d..43897615aa9 100644 --- a/test/cmd/addrmap.c +++ b/test/cmd/addrmap.c @@ -30,6 +30,6 @@ int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct unit_test *tests = UNIT_TEST_SUITE_START(addrmap_test); const int n_ents = UNIT_TEST_SUITE_COUNT(addrmap_test); - return cmd_ut_category("cmd_addrmap", "cmd_addrmap_", tests, n_ents, + return cmd_ut_category("addrmap", "cmd_addrmap_", tests, n_ents, argc, argv); } diff --git a/test/cmd/cmd_ut_cmd.c b/test/cmd/cmd_ut_cmd.c index e77fa1c7f01..ad192563c5a 100644 --- a/test/cmd/cmd_ut_cmd.c +++ b/test/cmd/cmd_ut_cmd.c @@ -13,8 +13,8 @@ int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(cmd_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(cmd_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(cmd); + const int n_ents = UNIT_TEST_SUITE_COUNT(cmd); return cmd_ut_category("cmd", "cmd_test_", tests, n_ents, argc, argv); } diff --git a/test/cmd/exit.c b/test/cmd/exit.c index af58a57fca7..cf65c05e283 100644 --- a/test/cmd/exit.c +++ b/test/cmd/exit.c @@ -116,6 +116,6 @@ int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct unit_test *tests = UNIT_TEST_SUITE_START(exit_test); const int n_ents = UNIT_TEST_SUITE_COUNT(exit_test); - return cmd_ut_category("cmd_exit", "exit_test_", tests, n_ents, + return cmd_ut_category("exit", "exit_test_", tests, n_ents, argc, argv); } diff --git a/test/cmd/mem.c b/test/cmd/mem.c index f1bbab6055b..d6f2544a4e9 100644 --- a/test/cmd/mem.c +++ b/test/cmd/mem.c @@ -14,6 +14,6 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct unit_test *tests = UNIT_TEST_SUITE_START(mem_test); const int n_ents = UNIT_TEST_SUITE_COUNT(mem_test); - return cmd_ut_category("cmd_mem", "mem_test_", tests, n_ents, argc, + return cmd_ut_category("mem", "mem_test_", tests, n_ents, argc, argv); } diff --git a/test/cmd/pci_mps.c b/test/cmd/pci_mps.c index a265105600c..0c57d15d636 100644 --- a/test/cmd/pci_mps.c +++ b/test/cmd/pci_mps.c @@ -35,6 +35,6 @@ int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc, struct unit_test *tests = UNIT_TEST_SUITE_START(pci_mps_test); const int n = UNIT_TEST_SUITE_COUNT(pci_mps_test); - return cmd_ut_category("cmd_pci_mps", "pci_mps_test_", tests, n, + return cmd_ut_category("pci_mps", "pci_mps_test_", tests, n, argc, argv); } diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index 21a3268bd81..9b3277f2ad9 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -485,6 +485,6 @@ int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct unit_test *tests = UNIT_TEST_SUITE_START(setexpr_test); const int n_ents = UNIT_TEST_SUITE_COUNT(setexpr_test); - return cmd_ut_category("cmd_setexpr", "setexpr_test_", tests, n_ents, + return cmd_ut_category("setexpr", "setexpr_test_", tests, n_ents, argc, argv); } diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 4bc2c45db61..7cfbefe02da 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -11,6 +11,5 @@ int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct unit_test *tests = UNIT_TEST_SUITE_START(dm_test); const int n_ents = UNIT_TEST_SUITE_COUNT(dm_test); - return cmd_ut_category("driver model", "dm_test_", tests, n_ents, argc, - argv); + return cmd_ut_category("dm", "dm_test_", tests, n_ents, argc, argv); } diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c index 9f16a978f2a..494b5db395b 100644 --- a/test/env/cmd_ut_env.c +++ b/test/env/cmd_ut_env.c @@ -80,6 +80,5 @@ int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct unit_test *tests = UNIT_TEST_SUITE_START(env_test); const int n_ents = UNIT_TEST_SUITE_COUNT(env_test); - return cmd_ut_category("environment", "env_test_", - tests, n_ents, argc, argv); + return cmd_ut_category("env", "env_test_", tests, n_ents, argc, argv); } -- cgit v1.3.1 From 4ba3ab4901c564725c37e927e2ba29595712cd9d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:32 -0700 Subject: test: Drop the _test suffix on linker lists Most test suites have a _test suffix. This is not necessary as there is also a ut_ prefix. Drop the suffix so that (with future work) the suite name can be used as the linker-list name. Remove the suffix from the pytest regex as well, moving it to the top of the file, as it is a constant. Signed-off-by: Simon Glass --- include/dm/test.h | 2 +- include/test/common.h | 2 +- include/test/env.h | 2 +- include/test/hush.h | 2 +- include/test/lib.h | 2 +- include/test/log.h | 4 ++-- include/test/optee.h | 2 +- include/test/overlay.h | 2 +- test/boot/bootm.c | 6 +++--- test/boot/bootstd_common.c | 8 ++++---- test/boot/bootstd_common.h | 3 +-- test/boot/measurement.c | 6 +++--- test/boot/upl.c | 6 +++--- test/cmd/addrmap.c | 6 +++--- test/cmd/bdinfo.c | 6 +++--- test/cmd/exit.c | 6 +++--- test/cmd/fdt.c | 6 +++--- test/cmd/font.c | 6 +++--- test/cmd/loadm.c | 6 +++--- test/cmd/mbr.c | 6 +++--- test/cmd/mem.c | 4 ++-- test/cmd/mem_copy.c | 2 +- test/cmd/mem_search.c | 2 +- test/cmd/pci_mps.c | 6 +++--- test/cmd/seama.c | 6 +++--- test/cmd/setexpr.c | 6 +++--- test/common/bloblist.c | 6 +++--- test/common/cmd_ut_common.c | 4 ++-- test/dm/test-dm.c | 4 ++-- test/env/cmd_ut_env.c | 4 ++-- test/hush/cmd_ut_hush.c | 4 ++-- test/lib/cmd_ut_lib.c | 4 ++-- test/log/log_ut.c | 4 ++-- test/optee/cmd_ut_optee.c | 4 ++-- test/overlay/cmd_ut_overlay.c | 4 ++-- test/py/conftest.py | 7 +++++-- 36 files changed, 81 insertions(+), 79 deletions(-) (limited to 'include') diff --git a/include/dm/test.h b/include/dm/test.h index 3cbf2c740d4..4aabb4603b9 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -143,7 +143,7 @@ extern struct unit_test_state global_dm_test_state; /* Declare a new driver model test */ #define DM_TEST(_name, _flags) \ - UNIT_TEST(_name, UTF_DM | UTF_CONSOLE | (_flags), dm_test) + UNIT_TEST(_name, UTF_DM | UTF_CONSOLE | (_flags), dm) /* * struct sandbox_sdl_plat - Platform data for the SDL video driver diff --git a/include/test/common.h b/include/test/common.h index 81260d06ad6..d5a65d5b50b 100644 --- a/include/test/common.h +++ b/include/test/common.h @@ -10,6 +10,6 @@ #include /* Declare a new common function test */ -#define COMMON_TEST(_name, _flags) UNIT_TEST(_name, _flags, common_test) +#define COMMON_TEST(_name, _flags) UNIT_TEST(_name, _flags, common) #endif /* __TEST_COMMON_H__ */ diff --git a/include/test/env.h b/include/test/env.h index f45e33d71a4..6a63cc972e9 100644 --- a/include/test/env.h +++ b/include/test/env.h @@ -10,6 +10,6 @@ #include /* Declare a new environment test */ -#define ENV_TEST(_name, _flags) UNIT_TEST(_name, _flags, env_test) +#define ENV_TEST(_name, _flags) UNIT_TEST(_name, _flags, env) #endif /* __TEST_ENV_H__ */ diff --git a/include/test/hush.h b/include/test/hush.h index cca66544a06..e57bf13ea61 100644 --- a/include/test/hush.h +++ b/include/test/hush.h @@ -10,6 +10,6 @@ #include /* Declare a new environment test */ -#define HUSH_TEST(_name, _flags) UNIT_TEST(_name, _flags, hush_test) +#define HUSH_TEST(_name, _flags) UNIT_TEST(_name, _flags, hush) #endif /* __TEST_HUSH_H__ */ diff --git a/include/test/lib.h b/include/test/lib.h index 04b6241e54a..b19eb863a33 100644 --- a/include/test/lib.h +++ b/include/test/lib.h @@ -9,6 +9,6 @@ #include /* Declare a new library function test */ -#define LIB_TEST(_name, _flags) UNIT_TEST(_name, _flags, lib_test) +#define LIB_TEST(_name, _flags) UNIT_TEST(_name, _flags, lib) #endif /* __TEST_LIB_H__ */ diff --git a/include/test/log.h b/include/test/log.h index e3362b85e99..0921c0c1cbc 100644 --- a/include/test/log.h +++ b/include/test/log.h @@ -13,8 +13,8 @@ #define LOGF_TEST (BIT(LOGF_FUNC) | BIT(LOGF_MSG)) /* Declare a new logging test */ -#define LOG_TEST(_name) UNIT_TEST(_name, UTF_CONSOLE, log_test) +#define LOG_TEST(_name) UNIT_TEST(_name, UTF_CONSOLE, log) #define LOG_TEST_FLAGS(_name, _flags) \ - UNIT_TEST(_name, _flags | UTF_CONSOLE, log_test) + UNIT_TEST(_name, _flags | UTF_CONSOLE, log) #endif /* __TEST_LOG_H__ */ diff --git a/include/test/optee.h b/include/test/optee.h index a8c6e6395f5..f4255b39ee3 100644 --- a/include/test/optee.h +++ b/include/test/optee.h @@ -9,6 +9,6 @@ #include /* Declare a new environment test */ -#define OPTEE_TEST(_name, _flags) UNIT_TEST(_name, _flags, optee_test) +#define OPTEE_TEST(_name, _flags) UNIT_TEST(_name, _flags, optee) #endif /* __TEST_OPTEE_H__ */ diff --git a/include/test/overlay.h b/include/test/overlay.h index c13f4d66e09..5dc98399ce7 100644 --- a/include/test/overlay.h +++ b/include/test/overlay.h @@ -10,6 +10,6 @@ #include /* Declare a new environment test */ -#define OVERLAY_TEST(_name, _flags) UNIT_TEST(_name, _flags, overlay_test) +#define OVERLAY_TEST(_name, _flags) UNIT_TEST(_name, _flags, overlay) #endif /* __TEST_OVERLAY_H__ */ diff --git a/test/boot/bootm.c b/test/boot/bootm.c index 9455f44884c..6e78c3ef9ac 100644 --- a/test/boot/bootm.c +++ b/test/boot/bootm.c @@ -13,7 +13,7 @@ DECLARE_GLOBAL_DATA_PTR; -#define BOOTM_TEST(_name, _flags) UNIT_TEST(_name, _flags, bootm_test) +#define BOOTM_TEST(_name, _flags) UNIT_TEST(_name, _flags, bootm) enum { BUF_SIZE = 1024, @@ -252,8 +252,8 @@ BOOTM_TEST(bootm_test_subst_both, 0); int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(bootm_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(bootm_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(bootm); + const int n_ents = UNIT_TEST_SUITE_COUNT(bootm); return cmd_ut_category("bootm", "bootm_test_", tests, n_ents, argc, argv); diff --git a/test/boot/bootstd_common.c b/test/boot/bootstd_common.c index ff8ed2303b3..6bd9bb65a40 100644 --- a/test/boot/bootstd_common.c +++ b/test/boot/bootstd_common.c @@ -96,8 +96,8 @@ void bootstd_reset_usb(void) int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(bootstd_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd); + const int n_ents = UNIT_TEST_SUITE_COUNT(bootstd); int ret; ret = bootstd_setup_for_tests(); @@ -106,6 +106,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_FAILURE; } - return cmd_ut_category("bootstd", "bootstd_test_", - tests, n_ents, argc, argv); + return cmd_ut_category("bootstd", "bootstd_", tests, n_ents, + argc, argv); } diff --git a/test/boot/bootstd_common.h b/test/boot/bootstd_common.h index e29036c897c..ea3ecd1166c 100644 --- a/test/boot/bootstd_common.h +++ b/test/boot/bootstd_common.h @@ -12,8 +12,7 @@ #include /* Declare a new bootdev test */ -#define BOOTSTD_TEST(_name, _flags) \ - UNIT_TEST(_name, _flags, bootstd_test) +#define BOOTSTD_TEST(_name, _flags) UNIT_TEST(_name, _flags, bootstd) #define NVDATA_START_BLK ((0x400 + 0x400) / MMC_MAX_BLOCK_LEN) #define VERSION_START_BLK ((0x400 + 0x800) / MMC_MAX_BLOCK_LEN) diff --git a/test/boot/measurement.c b/test/boot/measurement.c index 29be495412d..018e8af45f0 100644 --- a/test/boot/measurement.c +++ b/test/boot/measurement.c @@ -14,7 +14,7 @@ #include #define MEASUREMENT_TEST(_name, _flags) \ - UNIT_TEST(_name, _flags, measurement_test) + UNIT_TEST(_name, _flags, measurement) static int measure(struct unit_test_state *uts) { @@ -57,8 +57,8 @@ MEASUREMENT_TEST(measure, 0); int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(measurement_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(measurement_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(measurement); + const int n_ents = UNIT_TEST_SUITE_COUNT(measurement); return cmd_ut_category("measurement", "measurement_test_", tests, n_ents, argc, argv); diff --git a/test/boot/upl.c b/test/boot/upl.c index ef65cf34055..2c9b8bc8bc0 100644 --- a/test/boot/upl.c +++ b/test/boot/upl.c @@ -16,7 +16,7 @@ #include "bootstd_common.h" /* Declare a new upl test */ -#define UPL_TEST(_name, _flags) UNIT_TEST(_name, _flags, upl_test) +#define UPL_TEST(_name, _flags) UNIT_TEST(_name, _flags, upl) static int add_region(struct unit_test_state *uts, struct alist *lst, ulong base, ulong size) @@ -429,8 +429,8 @@ UPL_TEST(upl_test_info_norun, UTF_CONSOLE | UTF_MANUAL); int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(upl_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(upl_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(upl); + const int n_ents = UNIT_TEST_SUITE_COUNT(upl); return cmd_ut_category("upl", "cmd_upl_", tests, n_ents, argc, argv); } diff --git a/test/cmd/addrmap.c b/test/cmd/addrmap.c index 43897615aa9..fd0117102e2 100644 --- a/test/cmd/addrmap.c +++ b/test/cmd/addrmap.c @@ -10,7 +10,7 @@ #include /* Declare a new addrmap test */ -#define ADDRMAP_TEST(_name, _flags) UNIT_TEST(_name, _flags, addrmap_test) +#define ADDRMAP_TEST(_name, _flags) UNIT_TEST(_name, _flags, addrmap) /* Test 'addrmap' command output */ static int addrmap_test_basic(struct unit_test_state *uts) @@ -27,8 +27,8 @@ ADDRMAP_TEST(addrmap_test_basic, UTF_CONSOLE); int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(addrmap_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(addrmap_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(addrmap); + const int n_ents = UNIT_TEST_SUITE_COUNT(addrmap); return cmd_ut_category("addrmap", "cmd_addrmap_", tests, n_ents, argc, argv); diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 76429485708..b0b24bcb5a7 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -26,7 +26,7 @@ DECLARE_GLOBAL_DATA_PTR; /* Declare a new bdinfo test */ -#define BDINFO_TEST(_name, _flags) UNIT_TEST(_name, _flags, bdinfo_test) +#define BDINFO_TEST(_name, _flags) UNIT_TEST(_name, _flags, bdinfo) static int test_num_l(struct unit_test_state *uts, const char *name, ulong value) @@ -285,8 +285,8 @@ BDINFO_TEST(bdinfo_test_eth, UTF_CONSOLE); int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(bdinfo_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo); + const int n_ents = UNIT_TEST_SUITE_COUNT(bdinfo); return cmd_ut_category("bdinfo", "bdinfo_test_", tests, n_ents, argc, argv); } diff --git a/test/cmd/exit.c b/test/cmd/exit.c index cf65c05e283..d1eacdc36c2 100644 --- a/test/cmd/exit.c +++ b/test/cmd/exit.c @@ -14,7 +14,7 @@ DECLARE_GLOBAL_DATA_PTR; /* Declare a new exit test */ -#define EXIT_TEST(_name, _flags) UNIT_TEST(_name, _flags, exit_test) +#define EXIT_TEST(_name, _flags) UNIT_TEST(_name, _flags, exit) /* Test 'exit addr' getting/setting address */ static int cmd_exit_test(struct unit_test_state *uts) @@ -113,8 +113,8 @@ EXIT_TEST(cmd_exit_test, UTF_CONSOLE); int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(exit_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(exit_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(exit); + const int n_ents = UNIT_TEST_SUITE_COUNT(exit); return cmd_ut_category("exit", "exit_test_", tests, n_ents, argc, argv); diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index e64785101cd..74fd603bb02 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR; */ /* Declare a new fdt test */ -#define FDT_TEST(_name, _flags) UNIT_TEST(_name, _flags, fdt_test) +#define FDT_TEST(_name, _flags) UNIT_TEST(_name, _flags, fdt) /** * make_test_fdt() - Create an FDT with just a root node @@ -1465,8 +1465,8 @@ FDT_TEST(fdt_test_apply, UTF_CONSOLE); int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(fdt_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(fdt); + const int n_ents = UNIT_TEST_SUITE_COUNT(fdt); return cmd_ut_category("fdt", "fdt_test_", tests, n_ents, argc, argv); } diff --git a/test/cmd/font.c b/test/cmd/font.c index 3335dd65bea..d860efe8ce5 100644 --- a/test/cmd/font.c +++ b/test/cmd/font.c @@ -12,7 +12,7 @@ #include /* Declare a new fdt test */ -#define FONT_TEST(_name, _flags) UNIT_TEST(_name, _flags, font_test) +#define FONT_TEST(_name, _flags) UNIT_TEST(_name, _flags, font) /* Test 'fdt addr' resizing an fdt */ static int font_test_base(struct unit_test_state *uts) @@ -88,8 +88,8 @@ FONT_TEST(font_test_base, UTF_SCAN_PDATA | UTF_SCAN_FDT | UTF_CONSOLE | int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(font_Test); - const int n_ents = UNIT_TEST_SUITE_COUNT(font_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(font); + const int n_ents = UNIT_TEST_SUITE_COUNT(font); return cmd_ut_category("font", "font_test_", tests, n_ents, argc, argv); } diff --git a/test/cmd/loadm.c b/test/cmd/loadm.c index dedb4f7683e..78bb12ce88c 100644 --- a/test/cmd/loadm.c +++ b/test/cmd/loadm.c @@ -19,7 +19,7 @@ #define BUF_SIZE 0x100 -#define LOADM_TEST(_name, _flags) UNIT_TEST(_name, _flags, loadm_test) +#define LOADM_TEST(_name, _flags) UNIT_TEST(_name, _flags, loadm) static int loadm_test_params(struct unit_test_state *uts) { @@ -61,8 +61,8 @@ LOADM_TEST(loadm_test_load, UTF_CONSOLE); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(loadm_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(loadm_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(loadm); + const int n_ents = UNIT_TEST_SUITE_COUNT(loadm); return cmd_ut_category("loadm", "loadm_test_", tests, n_ents, argc, argv); diff --git a/test/cmd/mbr.c b/test/cmd/mbr.c index d137378a3be..ad859921ce5 100644 --- a/test/cmd/mbr.c +++ b/test/cmd/mbr.c @@ -470,12 +470,12 @@ static int mbr_test_run(struct unit_test_state *uts) } /* Declare mbr test */ -UNIT_TEST(mbr_test_run, UTF_CONSOLE, mbr_test); +UNIT_TEST(mbr_test_run, UTF_CONSOLE, mbr); int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(mbr_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(mbr_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(mbr); + const int n_ents = UNIT_TEST_SUITE_COUNT(mbr); return cmd_ut_category("mbr", "mbr_test_", tests, n_ents, argc, argv); } diff --git a/test/cmd/mem.c b/test/cmd/mem.c index d6f2544a4e9..2b78e421a9c 100644 --- a/test/cmd/mem.c +++ b/test/cmd/mem.c @@ -11,8 +11,8 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(mem_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(mem_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(mem); + const int n_ents = UNIT_TEST_SUITE_COUNT(mem); return cmd_ut_category("mem", "mem_test_", tests, n_ents, argc, argv); diff --git a/test/cmd/mem_copy.c b/test/cmd/mem_copy.c index 67eca328777..3e904fc4e4b 100644 --- a/test/cmd/mem_copy.c +++ b/test/cmd/mem_copy.c @@ -12,7 +12,7 @@ #define BUF_SIZE 256 /* Declare a new mem test */ -#define MEM_TEST(_name) UNIT_TEST(_name, 0, mem_test) +#define MEM_TEST(_name) UNIT_TEST(_name, 0, mem) struct param { int d, s, count; diff --git a/test/cmd/mem_search.c b/test/cmd/mem_search.c index 3a031eed7ed..df8938bdb6c 100644 --- a/test/cmd/mem_search.c +++ b/test/cmd/mem_search.c @@ -14,7 +14,7 @@ #define BUF_SIZE 0x100 /* Declare a new mem test */ -#define MEM_TEST(_name, _flags) UNIT_TEST(_name, _flags, mem_test) +#define MEM_TEST(_name, _flags) UNIT_TEST(_name, _flags, mem) /* Test 'ms' command with bytes */ static int mem_test_ms_b(struct unit_test_state *uts) diff --git a/test/cmd/pci_mps.c b/test/cmd/pci_mps.c index 0c57d15d636..2595ea103ff 100644 --- a/test/cmd/pci_mps.c +++ b/test/cmd/pci_mps.c @@ -11,7 +11,7 @@ #include #include -#define PCI_MPS_TEST(_name, _flags) UNIT_TEST(_name, _flags, pci_mps_test) +#define PCI_MPS_TEST(_name, _flags) UNIT_TEST(_name, _flags, pci_mps) /* Test "pci_mps" command in safe "s" mode */ static int test_pci_mps_safe(struct unit_test_state *uts) @@ -32,8 +32,8 @@ PCI_MPS_TEST(test_pci_mps_safe, UTF_CONSOLE); int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(pci_mps_test); - const int n = UNIT_TEST_SUITE_COUNT(pci_mps_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(pci_mps); + const int n = UNIT_TEST_SUITE_COUNT(pci_mps); return cmd_ut_category("pci_mps", "pci_mps_test_", tests, n, argc, argv); diff --git a/test/cmd/seama.c b/test/cmd/seama.c index 28d6b9ab517..39590d162ac 100644 --- a/test/cmd/seama.c +++ b/test/cmd/seama.c @@ -11,7 +11,7 @@ #include #include -#define SEAMA_TEST(_name, _flags) UNIT_TEST(_name, _flags, seama_test) +#define SEAMA_TEST(_name, _flags) UNIT_TEST(_name, _flags, seama) static int seama_test_noargs(struct unit_test_state *uts) { @@ -59,8 +59,8 @@ SEAMA_TEST(seama_test_index, UTF_CONSOLE); int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(seama_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(seama_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(seama); + const int n_ents = UNIT_TEST_SUITE_COUNT(seama); return cmd_ut_category("seama", "seama_test_", tests, n_ents, argc, argv); diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index 9b3277f2ad9..49eac5890aa 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -15,7 +15,7 @@ #define BUF_SIZE 0x100 /* Declare a new setexpr test */ -#define SETEXPR_TEST(_name, _flags) UNIT_TEST(_name, _flags, setexpr_test) +#define SETEXPR_TEST(_name, _flags) UNIT_TEST(_name, _flags, setexpr) /* Test 'setexpr' command with simply setting integers */ static int setexpr_test_int(struct unit_test_state *uts) @@ -482,8 +482,8 @@ SETEXPR_TEST(setexpr_test_fmt, UTF_CONSOLE); int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(setexpr_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(setexpr_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(setexpr); + const int n_ents = UNIT_TEST_SUITE_COUNT(setexpr); return cmd_ut_category("setexpr", "setexpr_test_", tests, n_ents, argc, argv); diff --git a/test/common/bloblist.c b/test/common/bloblist.c index 4bca62110a5..f5d98774862 100644 --- a/test/common/bloblist.c +++ b/test/common/bloblist.c @@ -12,7 +12,7 @@ /* Declare a new bloblist test */ #define BLOBLIST_TEST(_name, _flags) \ - UNIT_TEST(_name, _flags, bloblist_test) + UNIT_TEST(_name, _flags, bloblist) enum { TEST_TAG = BLOBLISTT_U_BOOT_SPL_HANDOFF, @@ -606,8 +606,8 @@ BLOBLIST_TEST(bloblist_test_blob_maxsize, UFT_BLOBLIST); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(bloblist_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(bloblist_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(bloblist); + const int n_ents = UNIT_TEST_SUITE_COUNT(bloblist); return cmd_ut_category("bloblist", "bloblist_test_", tests, n_ents, argc, argv); diff --git a/test/common/cmd_ut_common.c b/test/common/cmd_ut_common.c index 2f03a58af47..0724c9361b8 100644 --- a/test/common/cmd_ut_common.c +++ b/test/common/cmd_ut_common.c @@ -13,8 +13,8 @@ int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(common_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(common_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(common); + const int n_ents = UNIT_TEST_SUITE_COUNT(common); return cmd_ut_category("common", "common_test_", tests, n_ents, argc, argv); diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index 7cfbefe02da..8f83110163a 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -8,8 +8,8 @@ int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(dm_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(dm_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(dm); + const int n_ents = UNIT_TEST_SUITE_COUNT(dm); return cmd_ut_category("dm", "dm_test_", tests, n_ents, argc, argv); } diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c index 494b5db395b..332139bb803 100644 --- a/test/env/cmd_ut_env.c +++ b/test/env/cmd_ut_env.c @@ -77,8 +77,8 @@ ENV_TEST(env_test_env_cmd, UTF_CONSOLE); int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(env_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(env_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(env); + const int n_ents = UNIT_TEST_SUITE_COUNT(env); return cmd_ut_category("env", "env_test_", tests, n_ents, argc, argv); } diff --git a/test/hush/cmd_ut_hush.c b/test/hush/cmd_ut_hush.c index abad44f3216..141203d766b 100644 --- a/test/hush/cmd_ut_hush.c +++ b/test/hush/cmd_ut_hush.c @@ -11,8 +11,8 @@ int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(hush_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(hush_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(hush); + const int n_ents = UNIT_TEST_SUITE_COUNT(hush); return cmd_ut_category("hush", "hush_test_", tests, n_ents, argc, argv); diff --git a/test/lib/cmd_ut_lib.c b/test/lib/cmd_ut_lib.c index f98cb9b3c57..90a8c0728b7 100644 --- a/test/lib/cmd_ut_lib.c +++ b/test/lib/cmd_ut_lib.c @@ -12,8 +12,8 @@ int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(lib_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(lib_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(lib); + const int n_ents = UNIT_TEST_SUITE_COUNT(lib); return cmd_ut_category("lib", "lib_test_", tests, n_ents, argc, argv); } diff --git a/test/log/log_ut.c b/test/log/log_ut.c index 6617ed8b152..2aa3afe286a 100644 --- a/test/log/log_ut.c +++ b/test/log/log_ut.c @@ -12,8 +12,8 @@ int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(log_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(log_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(log); + const int n_ents = UNIT_TEST_SUITE_COUNT(log); return cmd_ut_category("log", "log_test_", tests, n_ents, argc, argv); diff --git a/test/optee/cmd_ut_optee.c b/test/optee/cmd_ut_optee.c index c6f50e0995a..fc6674764f9 100644 --- a/test/optee/cmd_ut_optee.c +++ b/test/optee/cmd_ut_optee.c @@ -93,8 +93,8 @@ OPTEE_TEST(optee_fdt_protected_memory, 0); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(optee_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(optee_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(optee); + const int n_ents = UNIT_TEST_SUITE_COUNT(optee); struct unit_test_state *uts; void *fdt_optee = &__dtb_test_optee_optee_begin; void *fdt_no_optee = &__dtb_test_optee_no_optee_begin; diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c index 256afd115d2..e0483afc31d 100644 --- a/test/overlay/cmd_ut_overlay.c +++ b/test/overlay/cmd_ut_overlay.c @@ -212,8 +212,8 @@ OVERLAY_TEST(fdt_overlay_stacked, 0); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = UNIT_TEST_SUITE_START(overlay_test); - const int n_ents = UNIT_TEST_SUITE_COUNT(overlay_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(overlay); + const int n_ents = UNIT_TEST_SUITE_COUNT(overlay); struct unit_test_state *uts; void *fdt_base = &__dtb_test_fdt_base_begin; void *fdt_overlay = &__dtbo_test_fdt_overlay_begin; diff --git a/test/py/conftest.py b/test/py/conftest.py index 509d19b449d..6b7ed0586e2 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -33,6 +33,9 @@ console = None TEST_PY_DIR = os.path.dirname(os.path.abspath(__file__)) +# Regex for test-function symbols +RE_UT_TEST_LIST = re.compile(r'[^a-zA-Z0-9_]_u_boot_list_2_ut_(.*)_2_(.*)\s*$') + def mkdir_p(path): """Create a directory path. @@ -336,7 +339,7 @@ def pytest_configure(config): import u_boot_console_exec_attach console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig) -re_ut_test_list = re.compile(r'[^a-zA-Z0-9_]_u_boot_list_2_ut_(.*)_test_2_(.*)\s*$') + def generate_ut_subtest(metafunc, fixture_name, sym_path): """Provide parametrization for a ut_subtest fixture. @@ -363,7 +366,7 @@ def generate_ut_subtest(metafunc, fixture_name, sym_path): vals = [] for l in lines: - m = re_ut_test_list.search(l) + m = RE_UT_TEST_LIST.search(l) if not m: continue suite, name = m.groups() -- cgit v1.3.1 From 7bbf2f7983c9ba5b8588ed86777b4b0b21eb542a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:33 -0700 Subject: test: Introduce a better array of test suites The current cmd_ut_sub[] array was fine when there were only a few test suites. But is quite unwieldy now: - it requires a separate do_ut_xxx for each suite, even though the code for most is almost identical - running more than one suite requires running multiple commands, and there is no record of which suites passed or failed - 'ut all' runs all suites but reports their results individually - we need lots of #ifdefs in the array, mirroring those in the makefile but maintained in a separate place In fact the tests are all in the same linker list. The suites are grouped, so it is possible to access the information without a command. Introduce a 'suite' array, which holds the cmd_ut_...() function to call, but can also support running a suite without that function. This means that the array of struct cmd_tbl is transformed into an array of 'struct suite'. This will allow removal of many of the functions, particularly those without test-specific init. Signed-off-by: Simon Glass --- include/test/suites.h | 4 + test/cmd_ut.c | 205 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 166 insertions(+), 43 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index e40ad634702..c1119e44999 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -10,6 +10,10 @@ struct cmd_tbl; struct unit_test; +/* 'command' functions normally called do_xxx where xxx is the command name */ +typedef int (*ut_cmd_func)(struct cmd_tbl *cmd, int flags, int argc, + char *const argv[]); + /** * cmd_ut_category() - Run a category of unit tests * diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 978974e6687..c5df8b397b3 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -11,6 +11,24 @@ #include #include +/** + * struct suite - A set of tests for a certain topic + * + * All tests end up in a single 'struct unit_test' linker-list array, in order + * of the suite they are in + * + * @name: Name of suite + * @start: First test in suite + * @end: End test in suite (points to the first test in the next suite) + * @cmd: Command to use to run the suite + */ +struct suite { + const char *name; + struct unit_test *start; + struct unit_test *end; + ut_cmd_func cmd; +}; + static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); @@ -54,85 +72,149 @@ int cmd_ut_category(const char *name, const char *prefix, return ret ? CMD_RET_FAILURE : 0; } -static struct cmd_tbl cmd_ut_sub[] = { - U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""), - U_BOOT_CMD_MKENT(info, 1, 1, do_ut_info, "", ""), +/* declare linker-list symbols for the start and end of a suite */ +#define SUITE_DECL(_name) \ + ll_start_decl(suite_start_ ## _name, struct unit_test, ut_ ## _name); \ + ll_end_decl(suite_end_ ## _name, struct unit_test, ut_ ## _name) + +/* declare a test suite which uses a subcommand to run */ +#define SUITE_CMD(_name, _cmd_func) { \ + #_name, \ + suite_start_ ## _name, \ + suite_end_ ## _name, \ + _cmd_func, \ + } + +/* declare a test suite which can be run directly without a subcommand */ +#define SUITE(_name) { \ + #_name, \ + suite_start_ ## _name, \ + suite_end_ ## _name, \ + NULL, \ + } + +SUITE_DECL(info); +SUITE_DECL(bdinfo); +SUITE_DECL(bootstd); +SUITE_DECL(cmd); +SUITE_DECL(common); +SUITE_DECL(dm); +SUITE_DECL(env); +SUITE_DECL(exit); +SUITE_DECL(fdt); +SUITE_DECL(font); +SUITE_DECL(optee); +SUITE_DECL(overlay); +SUITE_DECL(lib); +SUITE_DECL(log); +SUITE_DECL(mbr); +SUITE_DECL(mem); +SUITE_DECL(setexpr); +SUITE_DECL(measurement); +SUITE_DECL(bloblist); +SUITE_DECL(bootm); +SUITE_DECL(addrmap); +SUITE_DECL(hush); +SUITE_DECL(loadm); +SUITE_DECL(pci_mps); +SUITE_DECL(seama); +SUITE_DECL(upl); + +static struct suite suites[] = { + SUITE_CMD(info, do_ut_info), #ifdef CONFIG_CMD_BDI - U_BOOT_CMD_MKENT(bdinfo, CONFIG_SYS_MAXARGS, 1, do_ut_bdinfo, "", ""), + SUITE_CMD(bdinfo, do_ut_bdinfo), #endif #ifdef CONFIG_UT_BOOTSTD - U_BOOT_CMD_MKENT(bootstd, CONFIG_SYS_MAXARGS, 1, do_ut_bootstd, - "", ""), + SUITE_CMD(bootstd, do_ut_bootstd), #endif #ifdef CONFIG_CMDLINE - U_BOOT_CMD_MKENT(cmd, CONFIG_SYS_MAXARGS, 1, do_ut_cmd, "", ""), + SUITE_CMD(cmd, do_ut_cmd), #endif - U_BOOT_CMD_MKENT(common, CONFIG_SYS_MAXARGS, 1, do_ut_common, "", ""), + SUITE_CMD(common, do_ut_common), #if defined(CONFIG_UT_DM) - U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""), + SUITE_CMD(dm, do_ut_dm), #endif #if defined(CONFIG_UT_ENV) - U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""), + SUITE_CMD(env, do_ut_env), #endif - U_BOOT_CMD_MKENT(exit, CONFIG_SYS_MAXARGS, 1, do_ut_exit, "", ""), + SUITE_CMD(exit, do_ut_exit), #ifdef CONFIG_CMD_FDT - U_BOOT_CMD_MKENT(fdt, CONFIG_SYS_MAXARGS, 1, do_ut_fdt, "", ""), + SUITE_CMD(fdt, do_ut_fdt), #endif #ifdef CONFIG_CONSOLE_TRUETYPE - U_BOOT_CMD_MKENT(font, CONFIG_SYS_MAXARGS, 1, do_ut_font, "", ""), + SUITE_CMD(font, do_ut_font), #endif #ifdef CONFIG_UT_OPTEE - U_BOOT_CMD_MKENT(optee, CONFIG_SYS_MAXARGS, 1, do_ut_optee, "", ""), + SUITE_CMD(optee, do_ut_optee), #endif #ifdef CONFIG_UT_OVERLAY - U_BOOT_CMD_MKENT(overlay, CONFIG_SYS_MAXARGS, 1, do_ut_overlay, "", ""), + SUITE_CMD(overlay, do_ut_overlay), #endif #ifdef CONFIG_UT_LIB - U_BOOT_CMD_MKENT(lib, CONFIG_SYS_MAXARGS, 1, do_ut_lib, "", ""), + SUITE_CMD(lib, do_ut_lib), #endif #ifdef CONFIG_UT_LOG - U_BOOT_CMD_MKENT(log, CONFIG_SYS_MAXARGS, 1, do_ut_log, "", ""), + SUITE_CMD(log, do_ut_log), #endif #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_MBR) && defined(CONFIG_CMD_MMC) \ && defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE) - U_BOOT_CMD_MKENT(mbr, CONFIG_SYS_MAXARGS, 1, do_ut_mbr, "", ""), + SUITE_CMD(mbr, do_ut_mbr), #endif - U_BOOT_CMD_MKENT(mem, CONFIG_SYS_MAXARGS, 1, do_ut_mem, "", ""), + SUITE_CMD(mem, do_ut_mem), #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR) - U_BOOT_CMD_MKENT(setexpr, CONFIG_SYS_MAXARGS, 1, do_ut_setexpr, "", - ""), + SUITE_CMD(setexpr, do_ut_setexpr), #endif #ifdef CONFIG_MEASURED_BOOT - U_BOOT_CMD_MKENT(measurement, CONFIG_SYS_MAXARGS, 1, do_ut_measurement, - "", ""), + SUITE_CMD(measurement, do_ut_measurement), #endif #ifdef CONFIG_SANDBOX #if CONFIG_IS_ENABLED(BLOBLIST) - U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist, - "", ""), - U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""), + SUITE_CMD(bloblist, do_ut_bloblist), + SUITE_CMD(bootm, do_ut_bootm), #endif #endif #ifdef CONFIG_CMD_ADDRMAP - U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""), + SUITE_CMD(addrmap, do_ut_addrmap), #endif #if CONFIG_IS_ENABLED(HUSH_PARSER) - U_BOOT_CMD_MKENT(hush, CONFIG_SYS_MAXARGS, 1, do_ut_hush, "", ""), + SUITE_CMD(hush, do_ut_hush), #endif #ifdef CONFIG_CMD_LOADM - U_BOOT_CMD_MKENT(loadm, CONFIG_SYS_MAXARGS, 1, do_ut_loadm, "", ""), + SUITE_CMD(loadm, do_ut_loadm), #endif #ifdef CONFIG_CMD_PCI_MPS - U_BOOT_CMD_MKENT(pci_mps, CONFIG_SYS_MAXARGS, 1, do_ut_pci_mps, "", ""), + SUITE_CMD(pci_mps, do_ut_pci_mps), #endif #ifdef CONFIG_CMD_SEAMA - U_BOOT_CMD_MKENT(seama, CONFIG_SYS_MAXARGS, 1, do_ut_seama, "", ""), + SUITE_CMD(seama, do_ut_seama), #endif #ifdef CONFIG_CMD_UPL - U_BOOT_CMD_MKENT(upl, CONFIG_SYS_MAXARGS, 1, do_ut_upl, "", ""), + SUITE_CMD(upl, do_ut_upl), #endif }; +/** run_suite() - Run a suite of tests */ +static int run_suite(struct suite *ste, struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + int ret; + + if (ste->cmd) { + ret = ste->cmd(cmdtp, flag, argc, argv); + } else { + int n_ents = ste->end - ste->start; + char prefix[30]; + + /* use a standard prefix */ + snprintf(prefix, sizeof(prefix), "%s_test", ste->name); + ret = cmd_ut_category(ste->name, prefix, ste->start, n_ents, + argc, argv); + } + + return ret; +} + static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -140,9 +222,12 @@ static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc, int retval; int any_fail = 0; - for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++) { - printf("----Running %s tests----\n", cmd_ut_sub[i].name); - retval = cmd_ut_sub[i].cmd(cmdtp, flag, 1, &cmd_ut_sub[i].name); + for (i = 0; i < ARRAY_SIZE(suites); i++) { + struct suite *ste = &suites[i]; + char *const argv[] = {(char *)ste->name, NULL}; + + printf("----Running %s tests----\n", ste->name); + retval = run_suite(ste, cmdtp, flag, 1, argv); if (!any_fail) any_fail = retval; } @@ -155,7 +240,7 @@ static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int argc, { const char *flags; - printf("Test suites: %d\n", (int)ARRAY_SIZE(cmd_ut_sub) - 1); + printf("Test suites: %d\n", (int)ARRAY_SIZE(suites)); printf("Total tests: %d\n", (int)UNIT_TEST_ALL_COUNT()); flags = cmd_arg1(argc, argv); @@ -164,16 +249,38 @@ static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int argc, puts("\nTests Suite\n"); puts("----- -----\n"); - for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++) - printf("%5s %s\n", "?", cmd_ut_sub[i].name); + for (i = 1; i < ARRAY_SIZE(suites); i++) { + struct suite *ste = &suites[i]; + long n_ent = ste->end - ste->start; + + if (n_ent) + printf("%5ld %s\n", n_ent, ste->name); + else + printf("%5s %s\n", "?", ste->name); + } } return 0; } +static struct suite *find_suite(const char *name) +{ + struct suite *ste; + int i; + + for (i = 0, ste = suites; i < ARRAY_SIZE(suites); i++, ste++) { + if (!strcmp(ste->name, name)) + return ste; + } + + return NULL; +} + static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct cmd_tbl *cp; + struct suite *ste; + const char *name; + int ret; if (argc < 2) return CMD_RET_USAGE; @@ -182,12 +289,24 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) argc--; argv++; - cp = find_cmd_tbl(argv[0], cmd_ut_sub, ARRAY_SIZE(cmd_ut_sub)); + name = argv[0]; + if (!strcmp(name, "all")) { + ret = do_ut_all(cmdtp, flag, argc, argv); + } else if (!strcmp(name, "info")) { + ret = do_ut_info(cmdtp, flag, argc, argv); + } else { + ste = find_suite(argv[0]); + if (!ste) { + printf("Suite '%s' not found\n", argv[0]); + return CMD_RET_FAILURE; + } - if (cp) - return cp->cmd(cmdtp, flag, argc, argv); + ret = run_suite(ste, cmdtp, flag, argc, argv); + } + if (ret) + return ret; - return CMD_RET_USAGE; + return 0; } U_BOOT_LONGHELP(ut, -- cgit v1.3.1 From 9e93c249f7a3b16ced4844c1c41b5298c7b4907b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:34 -0700 Subject: test: Drop the function for running bdinfo tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd/bdinfo.c | 8 -------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index c1119e44999..b6af9295424 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -32,7 +32,6 @@ int cmd_ut_category(const char *name, const char *prefix, int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index b0b24bcb5a7..7408c271a30 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -282,11 +282,3 @@ static int bdinfo_test_eth(struct unit_test_state *uts) return 0; } BDINFO_TEST(bdinfo_test_eth, UTF_CONSOLE); - -int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo); - const int n_ents = UNIT_TEST_SUITE_COUNT(bdinfo); - - return cmd_ut_category("bdinfo", "bdinfo_test_", tests, n_ents, argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index c5df8b397b3..bbd329912d4 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -123,7 +123,7 @@ SUITE_DECL(upl); static struct suite suites[] = { SUITE_CMD(info, do_ut_info), #ifdef CONFIG_CMD_BDI - SUITE_CMD(bdinfo, do_ut_bdinfo), + SUITE(bdinfo), #endif #ifdef CONFIG_UT_BOOTSTD SUITE_CMD(bootstd, do_ut_bootstd), -- cgit v1.3.1 From 6054e8463c57d62668866a9ffb21654f5d510cfb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:35 -0700 Subject: test: Drop the function for running cmd tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd/Makefile | 2 -- test/cmd/cmd_ut_cmd.c | 20 -------------------- test/cmd_ut.c | 2 +- 4 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 test/cmd/cmd_ut_cmd.c (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index b6af9295424..21158692e9b 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/Makefile b/test/cmd/Makefile index 583e7c2eec4..f83c53696d0 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -3,8 +3,6 @@ # Copyright (c) 2013 Google, Inc # Copyright 2022-2023 Arm Limited and/or its affiliates -obj-y += cmd_ut_cmd.o - obj-$(CONFIG_$(XPL_)CMDLINE) += command.o ifdef CONFIG_HUSH_PARSER obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o diff --git a/test/cmd/cmd_ut_cmd.c b/test/cmd/cmd_ut_cmd.c deleted file mode 100644 index ad192563c5a..00000000000 --- a/test/cmd/cmd_ut_cmd.c +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright 2023 Google LLC - * Written by Simon Glass - * - * Unit tests for command functions - */ - -#include -#include -#include -#include - -int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(cmd); - const int n_ents = UNIT_TEST_SUITE_COUNT(cmd); - - return cmd_ut_category("cmd", "cmd_test_", tests, n_ents, argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index bbd329912d4..09538301cd7 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -129,7 +129,7 @@ static struct suite suites[] = { SUITE_CMD(bootstd, do_ut_bootstd), #endif #ifdef CONFIG_CMDLINE - SUITE_CMD(cmd, do_ut_cmd), + SUITE(cmd), #endif SUITE_CMD(common, do_ut_common), #if defined(CONFIG_UT_DM) -- cgit v1.3.1 From cfc0f46cd05ec166509f344b4320976a8fba8747 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:36 -0700 Subject: test: Drop the function for running common tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd_ut.c | 2 +- test/common/Makefile | 1 - test/common/cmd_ut_common.c | 21 --------------------- 4 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 test/common/cmd_ut_common.c (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 21158692e9b..d6c0061ff87 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 09538301cd7..1fda67abd95 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -131,7 +131,7 @@ static struct suite suites[] = { #ifdef CONFIG_CMDLINE SUITE(cmd), #endif - SUITE_CMD(common, do_ut_common), + SUITE(common), #if defined(CONFIG_UT_DM) SUITE_CMD(dm, do_ut_dm), #endif diff --git a/test/common/Makefile b/test/common/Makefile index 53c4f16164d..9cfb5585d78 100644 --- a/test/common/Makefile +++ b/test/common/Makefile @@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ -obj-y += cmd_ut_common.o obj-$(CONFIG_AUTOBOOT) += test_autoboot.o ifneq ($(CONFIG_$(XPL_)BLOBLIST),) obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o diff --git a/test/common/cmd_ut_common.c b/test/common/cmd_ut_common.c deleted file mode 100644 index 0724c9361b8..00000000000 --- a/test/common/cmd_ut_common.c +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2019 Heinrich Schuchardt - * Copyright (c) 2021 Steffen Jaeckel - * - * Unit tests for common functions - */ - -#include -#include -#include -#include - -int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(common); - const int n_ents = UNIT_TEST_SUITE_COUNT(common); - - return cmd_ut_category("common", "common_test_", tests, n_ents, argc, - argv); -} -- cgit v1.3.1 From 7c012db10608afaa04c784187a1bc8f07b9ac4eb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:37 -0700 Subject: test: Drop the function for running dm tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd_ut.c | 2 +- test/dm/Makefile | 2 -- test/dm/test-dm.c | 15 --------------- 4 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 test/dm/test-dm.c (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index d6c0061ff87..414613c593e 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 1fda67abd95..a0905ec54b7 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -133,7 +133,7 @@ static struct suite suites[] = { #endif SUITE(common), #if defined(CONFIG_UT_DM) - SUITE_CMD(dm, do_ut_dm), + SUITE(dm), #endif #if defined(CONFIG_UT_ENV) SUITE_CMD(env, do_ut_env), diff --git a/test/dm/Makefile b/test/dm/Makefile index bcb52ef1067..e44f3d89e77 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -3,8 +3,6 @@ # Copyright (c) 2013 Google, Inc # Copyright 2022-2023 Arm Limited and/or its affiliates -obj-$(CONFIG_UT_DM) += test-dm.o - # Tests for particular subsystems - when enabling driver model for a new # subsystem you must add sandbox tests here. ifeq ($(CONFIG_XPL_BUILD),y) diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c deleted file mode 100644 index 8f83110163a..00000000000 --- a/test/dm/test-dm.c +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright (c) 2013 Google, Inc - */ - -#include -#include - -int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(dm); - const int n_ents = UNIT_TEST_SUITE_COUNT(dm); - - return cmd_ut_category("dm", "dm_test_", tests, n_ents, argc, argv); -} -- cgit v1.3.1 From 3e5e638e62574fa1f9989f2fd35dd9dd7b6d72b5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:38 -0700 Subject: test: Drop the function for running env tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd_ut.c | 2 +- test/env/cmd_ut_env.c | 9 --------- 3 files changed, 1 insertion(+), 11 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 414613c593e..b78436fe2b2 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd_ut.c b/test/cmd_ut.c index a0905ec54b7..155b187ad4b 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -136,7 +136,7 @@ static struct suite suites[] = { SUITE(dm), #endif #if defined(CONFIG_UT_ENV) - SUITE_CMD(env, do_ut_env), + SUITE(env), #endif SUITE_CMD(exit, do_ut_exit), #ifdef CONFIG_CMD_FDT diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c index 332139bb803..81d1bb2f80d 100644 --- a/test/env/cmd_ut_env.c +++ b/test/env/cmd_ut_env.c @@ -4,7 +4,6 @@ * Joe Hershberger, National Instruments, joe.hershberger@ni.com */ -#include #include #include #include @@ -74,11 +73,3 @@ static int env_test_env_cmd(struct unit_test_state *uts) return 0; } ENV_TEST(env_test_env_cmd, UTF_CONSOLE); - -int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(env); - const int n_ents = UNIT_TEST_SUITE_COUNT(env); - - return cmd_ut_category("env", "env_test_", tests, n_ents, argc, argv); -} -- cgit v1.3.1 From ca917e491f81916ef4accc34615680ffae161430 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:39 -0700 Subject: test: Drop the function for running exit tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd/exit.c | 9 --------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index b78436fe2b2..70b9af1fd05 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/exit.c b/test/cmd/exit.c index d1eacdc36c2..71c37edcdf6 100644 --- a/test/cmd/exit.c +++ b/test/cmd/exit.c @@ -110,12 +110,3 @@ static int cmd_exit_test(struct unit_test_state *uts) return 0; } EXIT_TEST(cmd_exit_test, UTF_CONSOLE); - -int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(exit); - const int n_ents = UNIT_TEST_SUITE_COUNT(exit); - - return cmd_ut_category("exit", "exit_test_", tests, n_ents, - argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 155b187ad4b..387aacb916b 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -138,7 +138,7 @@ static struct suite suites[] = { #if defined(CONFIG_UT_ENV) SUITE(env), #endif - SUITE_CMD(exit, do_ut_exit), + SUITE(exit), #ifdef CONFIG_CMD_FDT SUITE_CMD(fdt, do_ut_fdt), #endif -- cgit v1.3.1 From 45dfbdde373587f13ba8edf5fb6783043cb5ee1c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:40 -0700 Subject: test: Drop the function for running fdt tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd/fdt.c | 8 -------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 70b9af1fd05..bf3a9851322 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 74fd603bb02..ab6dbd45e54 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1462,11 +1462,3 @@ static int fdt_test_apply(struct unit_test_state *uts) return 0; } FDT_TEST(fdt_test_apply, UTF_CONSOLE); - -int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(fdt); - const int n_ents = UNIT_TEST_SUITE_COUNT(fdt); - - return cmd_ut_category("fdt", "fdt_test_", tests, n_ents, argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 387aacb916b..0babc91d118 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -140,7 +140,7 @@ static struct suite suites[] = { #endif SUITE(exit), #ifdef CONFIG_CMD_FDT - SUITE_CMD(fdt, do_ut_fdt), + SUITE(fdt), #endif #ifdef CONFIG_CONSOLE_TRUETYPE SUITE_CMD(font, do_ut_font), -- cgit v1.3.1 From a9976e52bea8d1b89469226989f7429d4b174050 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:41 -0700 Subject: test: Drop the function for running font tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd/font.c | 8 -------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index bf3a9851322..587d6a5b473 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/font.c b/test/cmd/font.c index d860efe8ce5..af88d1b5459 100644 --- a/test/cmd/font.c +++ b/test/cmd/font.c @@ -85,11 +85,3 @@ static int font_test_base(struct unit_test_state *uts) } FONT_TEST(font_test_base, UTF_SCAN_PDATA | UTF_SCAN_FDT | UTF_CONSOLE | UTF_DM); - -int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(font); - const int n_ents = UNIT_TEST_SUITE_COUNT(font); - - return cmd_ut_category("font", "font_test_", tests, n_ents, argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 0babc91d118..db96a4ac2ac 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -143,7 +143,7 @@ static struct suite suites[] = { SUITE(fdt), #endif #ifdef CONFIG_CONSOLE_TRUETYPE - SUITE_CMD(font, do_ut_font), + SUITE(font), #endif #ifdef CONFIG_UT_OPTEE SUITE_CMD(optee, do_ut_optee), -- cgit v1.3.1 From d824e20fc27c2c40d8638b1cdf9ad6ea2cc32420 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:42 -0700 Subject: test: Drop the function for running lib tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd_ut.c | 2 +- test/lib/Makefile | 1 - test/lib/cmd_ut_lib.c | 19 ------------------- 4 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 test/lib/cmd_ut_lib.c (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 587d6a5b473..08b35b276be 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -38,7 +38,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd_ut.c b/test/cmd_ut.c index db96a4ac2ac..27d090c7225 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -152,7 +152,7 @@ static struct suite suites[] = { SUITE_CMD(overlay, do_ut_overlay), #endif #ifdef CONFIG_UT_LIB - SUITE_CMD(lib, do_ut_lib), + SUITE(lib), #endif #ifdef CONFIG_UT_LOG SUITE_CMD(log, do_ut_log), diff --git a/test/lib/Makefile b/test/lib/Makefile index 24ce6ed8f00..f136cac5ce7 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -6,7 +6,6 @@ obj-$(CONFIG_$(XPL_)UT_COMPRESSION) += compression.o ifeq ($(CONFIG_XPL_BUILD),) -obj-y += cmd_ut_lib.o obj-y += abuf.o obj-y += alist.o obj-$(CONFIG_EFI_LOADER) += efi_device_path.o diff --git a/test/lib/cmd_ut_lib.c b/test/lib/cmd_ut_lib.c deleted file mode 100644 index 90a8c0728b7..00000000000 --- a/test/lib/cmd_ut_lib.c +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2019 Heinrich Schuchardt - * - * Unit tests for library functions - */ - -#include -#include -#include -#include - -int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(lib); - const int n_ents = UNIT_TEST_SUITE_COUNT(lib); - - return cmd_ut_category("lib", "lib_test_", tests, n_ents, argc, argv); -} -- cgit v1.3.1 From 87cf479fdb7f35878133295e306192f118ea2336 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:43 -0700 Subject: test: Drop the function for running log tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd_ut.c | 2 +- test/log/Makefile | 2 -- test/log/log_ut.c | 20 -------------------- 4 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 test/log/log_ut.c (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 08b35b276be..72f98eb3558 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -39,7 +39,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 27d090c7225..a196702dd17 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -155,7 +155,7 @@ static struct suite suites[] = { SUITE(lib), #endif #ifdef CONFIG_UT_LOG - SUITE_CMD(log, do_ut_log), + SUITE(log), #endif #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_MBR) && defined(CONFIG_CMD_MMC) \ && defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE) diff --git a/test/log/Makefile b/test/log/Makefile index 08eea70e344..24b7c46786d 100644 --- a/test/log/Makefile +++ b/test/log/Makefile @@ -7,8 +7,6 @@ obj-$(CONFIG_CMD_LOG) += log_filter.o ifdef CONFIG_UT_LOG -obj-y += log_ut.o - ifdef CONFIG_SANDBOX obj-$(CONFIG_LOG_SYSLOG) += syslog_test.o obj-$(CONFIG_LOG_SYSLOG) += syslog_test_ndebug.o diff --git a/test/log/log_ut.c b/test/log/log_ut.c deleted file mode 100644 index 2aa3afe286a..00000000000 --- a/test/log/log_ut.c +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright (c) 2020, Heinrich Schuchardt - * - * Logging function tests. - */ - -#include -#include -#include -#include - -int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(log); - const int n_ents = UNIT_TEST_SUITE_COUNT(log); - - return cmd_ut_category("log", "log_test_", - tests, n_ents, argc, argv); -} -- cgit v1.3.1 From 1ade3afa2da2242ad1006dc393a3bb3242226d4c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:44 -0700 Subject: test: Drop the function for running mbr tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd/mbr.c | 8 -------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 72f98eb3558..612167fe053 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -39,7 +39,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/mbr.c b/test/cmd/mbr.c index ad859921ce5..45bab04923a 100644 --- a/test/cmd/mbr.c +++ b/test/cmd/mbr.c @@ -471,11 +471,3 @@ static int mbr_test_run(struct unit_test_state *uts) /* Declare mbr test */ UNIT_TEST(mbr_test_run, UTF_CONSOLE, mbr); - -int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(mbr); - const int n_ents = UNIT_TEST_SUITE_COUNT(mbr); - - return cmd_ut_category("mbr", "mbr_test_", tests, n_ents, argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index a196702dd17..1a69b1c215b 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -159,7 +159,7 @@ static struct suite suites[] = { #endif #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_MBR) && defined(CONFIG_CMD_MMC) \ && defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE) - SUITE_CMD(mbr, do_ut_mbr), + SUITE(mbr), #endif SUITE_CMD(mem, do_ut_mem), #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR) -- cgit v1.3.1 From bda212bad51797a44664bf2563490c0a3f3c4576 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:45 -0700 Subject: test: Drop the function for running mem tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd/Makefile | 2 +- test/cmd/mem.c | 19 ------------------- test/cmd_ut.c | 2 +- 4 files changed, 2 insertions(+), 22 deletions(-) delete mode 100644 test/cmd/mem.c (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 612167fe053..cb6b6fba240 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -40,7 +40,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); -int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/Makefile b/test/cmd/Makefile index f83c53696d0..d8a5e77402d 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -10,7 +10,7 @@ endif ifdef CONFIG_CONSOLE_RECORD obj-$(CONFIG_CMD_PAUSE) += test_pause.o endif -obj-y += exit.o mem.o +obj-y += exit.o obj-$(CONFIG_X86) += cpuid.o msr.o obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o obj-$(CONFIG_CMD_BDI) += bdinfo.o diff --git a/test/cmd/mem.c b/test/cmd/mem.c deleted file mode 100644 index 2b78e421a9c..00000000000 --- a/test/cmd/mem.c +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Executes tests for memory-related commands - * - * Copyright 2020 Google LLC - */ - -#include -#include -#include - -int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(mem); - const int n_ents = UNIT_TEST_SUITE_COUNT(mem); - - return cmd_ut_category("mem", "mem_test_", tests, n_ents, argc, - argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 1a69b1c215b..8ab29046969 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -161,7 +161,7 @@ static struct suite suites[] = { && defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE) SUITE(mbr), #endif - SUITE_CMD(mem, do_ut_mem), + SUITE(mem), #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR) SUITE_CMD(setexpr, do_ut_setexpr), #endif -- cgit v1.3.1 From cebdc5376f9663254387c5c59c095f9f64b3eb99 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:46 -0700 Subject: test: Drop the function for running setexpr tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 2 -- test/cmd/setexpr.c | 9 --------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index cb6b6fba240..775b0a5a131 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -46,8 +46,6 @@ int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); #endif /* __TEST_SUITES_H__ */ diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index 49eac5890aa..7f318a42ead 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -479,12 +479,3 @@ static int setexpr_test_fmt(struct unit_test_state *uts) } SETEXPR_TEST(setexpr_test_fmt, UTF_CONSOLE); #endif - -int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(setexpr); - const int n_ents = UNIT_TEST_SUITE_COUNT(setexpr); - - return cmd_ut_category("setexpr", "setexpr_test_", tests, n_ents, - argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 8ab29046969..f2a72adc16e 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -163,7 +163,7 @@ static struct suite suites[] = { #endif SUITE(mem), #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR) - SUITE_CMD(setexpr, do_ut_setexpr), + SUITE(setexpr), #endif #ifdef CONFIG_MEASURED_BOOT SUITE_CMD(measurement, do_ut_measurement), -- cgit v1.3.1 From 446e6f9cd373d4642a5da62e870cb7c46fc9e43a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:47 -0700 Subject: test: Drop the function for running measurement tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/boot/measurement.c | 10 ---------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 775b0a5a131..1a40af6599a 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -39,7 +39,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/boot/measurement.c b/test/boot/measurement.c index 018e8af45f0..5a49c7a6b23 100644 --- a/test/boot/measurement.c +++ b/test/boot/measurement.c @@ -53,13 +53,3 @@ static int measure(struct unit_test_state *uts) return 0; } MEASUREMENT_TEST(measure, 0); - -int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(measurement); - const int n_ents = UNIT_TEST_SUITE_COUNT(measurement); - - return cmd_ut_category("measurement", "measurement_test_", tests, - n_ents, argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index f2a72adc16e..ff9976cb98a 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -166,7 +166,7 @@ static struct suite suites[] = { SUITE(setexpr), #endif #ifdef CONFIG_MEASURED_BOOT - SUITE_CMD(measurement, do_ut_measurement), + SUITE(measurement), #endif #ifdef CONFIG_SANDBOX #if CONFIG_IS_ENABLED(BLOBLIST) -- cgit v1.3.1 From 28b32858aaa8afa20b9bd2de8e7f535b6f8f2a2e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:48 -0700 Subject: test: Drop the function for running bloblist tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 2 -- test/cmd_ut.c | 2 +- test/common/bloblist.c | 10 ---------- 3 files changed, 1 insertion(+), 13 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 1a40af6599a..32b7e8e3d5a 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -35,8 +35,6 @@ int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd_ut.c b/test/cmd_ut.c index ff9976cb98a..93bcc5efc74 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -170,7 +170,7 @@ static struct suite suites[] = { #endif #ifdef CONFIG_SANDBOX #if CONFIG_IS_ENABLED(BLOBLIST) - SUITE_CMD(bloblist, do_ut_bloblist), + SUITE(bloblist), SUITE_CMD(bootm, do_ut_bootm), #endif #endif diff --git a/test/common/bloblist.c b/test/common/bloblist.c index f5d98774862..9467abfa8e1 100644 --- a/test/common/bloblist.c +++ b/test/common/bloblist.c @@ -602,13 +602,3 @@ static int bloblist_test_blob_maxsize(struct unit_test_state *uts) return 0; } BLOBLIST_TEST(bloblist_test_blob_maxsize, UFT_BLOBLIST); - -int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(bloblist); - const int n_ents = UNIT_TEST_SUITE_COUNT(bloblist); - - return cmd_ut_category("bloblist", "bloblist_test_", - tests, n_ents, argc, argv); -} -- cgit v1.3.1 From 1ca67c3f040fb91cb32c9c29251429496a6ee280 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:49 -0700 Subject: test: Drop the function for running bootm tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/boot/bootm.c | 9 --------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 32b7e8e3d5a..77af692be3c 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -32,7 +32,6 @@ int cmd_ut_category(const char *name, const char *prefix, int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/boot/bootm.c b/test/boot/bootm.c index 6e78c3ef9ac..7e0ccb0e23f 100644 --- a/test/boot/bootm.c +++ b/test/boot/bootm.c @@ -249,12 +249,3 @@ static int bootm_test_subst_both(struct unit_test_state *uts) return 0; } BOOTM_TEST(bootm_test_subst_both, 0); - -int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(bootm); - const int n_ents = UNIT_TEST_SUITE_COUNT(bootm); - - return cmd_ut_category("bootm", "bootm_test_", tests, n_ents, - argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 93bcc5efc74..71283d6dd14 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -171,7 +171,7 @@ static struct suite suites[] = { #ifdef CONFIG_SANDBOX #if CONFIG_IS_ENABLED(BLOBLIST) SUITE(bloblist), - SUITE_CMD(bootm, do_ut_bootm), + SUITE(bootm), #endif #endif #ifdef CONFIG_CMD_ADDRMAP -- cgit v1.3.1 From e6959512b6f5e68314718b3ccd44608017bfb305 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:50 -0700 Subject: test: Drop the function for running addrmap tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 2 -- test/cmd/addrmap.c | 9 --------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 77af692be3c..54fddaa6bac 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -30,8 +30,6 @@ 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_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/addrmap.c b/test/cmd/addrmap.c index fd0117102e2..1f2deb15052 100644 --- a/test/cmd/addrmap.c +++ b/test/cmd/addrmap.c @@ -24,12 +24,3 @@ static int addrmap_test_basic(struct unit_test_state *uts) return 0; } ADDRMAP_TEST(addrmap_test_basic, UTF_CONSOLE); - -int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(addrmap); - const int n_ents = UNIT_TEST_SUITE_COUNT(addrmap); - - return cmd_ut_category("addrmap", "cmd_addrmap_", tests, n_ents, - argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 71283d6dd14..611171740a9 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -175,7 +175,7 @@ static struct suite suites[] = { #endif #endif #ifdef CONFIG_CMD_ADDRMAP - SUITE_CMD(addrmap, do_ut_addrmap), + SUITE(addrmap), #endif #if CONFIG_IS_ENABLED(HUSH_PARSER) SUITE_CMD(hush, do_ut_hush), -- cgit v1.3.1 From d5e5cb48e646ef089b57a4d924796b153f73fbfd Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:51 -0700 Subject: test: Drop the function for running hush tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd_ut.c | 2 +- test/hush/Makefile | 1 - test/hush/cmd_ut_hush.c | 19 ------------------- 4 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 test/hush/cmd_ut_hush.c (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 54fddaa6bac..b96a78f7129 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -32,7 +32,6 @@ int cmd_ut_category(const char *name, const char *prefix, int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 611171740a9..c892891d6c8 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -178,7 +178,7 @@ static struct suite suites[] = { SUITE(addrmap), #endif #if CONFIG_IS_ENABLED(HUSH_PARSER) - SUITE_CMD(hush, do_ut_hush), + SUITE(hush), #endif #ifdef CONFIG_CMD_LOADM SUITE_CMD(loadm, do_ut_loadm), diff --git a/test/hush/Makefile b/test/hush/Makefile index 4c3a0be857a..febdc82e8aa 100644 --- a/test/hush/Makefile +++ b/test/hush/Makefile @@ -3,7 +3,6 @@ # (C) Copyright 2021 # Francis Laniel, Amarula Solutions, francis.laniel@amarulasolutions.com -obj-y += cmd_ut_hush.o obj-y += if.o ifdef CONFIG_CONSOLE_RECORD obj-y += dollar.o diff --git a/test/hush/cmd_ut_hush.c b/test/hush/cmd_ut_hush.c deleted file mode 100644 index 141203d766b..00000000000 --- a/test/hush/cmd_ut_hush.c +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * (C) Copyright 2021 - * Francis Laniel, Amarula Solutions, francis.laniel@amarulasolutions.com - */ - -#include -#include -#include -#include - -int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(hush); - const int n_ents = UNIT_TEST_SUITE_COUNT(hush); - - return cmd_ut_category("hush", "hush_test_", - tests, n_ents, argc, argv); -} -- cgit v1.3.1 From 822cb558e1a9415c3b4b8069fd62734d3d37ddfe Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:52 -0700 Subject: test: Drop the function for running loadm tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/cmd/loadm.c | 9 --------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index b96a78f7129..f6b33da5a28 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -32,7 +32,6 @@ int cmd_ut_category(const char *name, const char *prefix, int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/loadm.c b/test/cmd/loadm.c index 78bb12ce88c..3c623aa655f 100644 --- a/test/cmd/loadm.c +++ b/test/cmd/loadm.c @@ -58,12 +58,3 @@ static int loadm_test_load (struct unit_test_state *uts) return 0; } LOADM_TEST(loadm_test_load, UTF_CONSOLE); - -int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(loadm); - const int n_ents = UNIT_TEST_SUITE_COUNT(loadm); - - return cmd_ut_category("loadm", "loadm_test_", tests, n_ents, argc, - argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index c892891d6c8..3620be62ce6 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -181,7 +181,7 @@ static struct suite suites[] = { SUITE(hush), #endif #ifdef CONFIG_CMD_LOADM - SUITE_CMD(loadm, do_ut_loadm), + SUITE(loadm), #endif #ifdef CONFIG_CMD_PCI_MPS SUITE_CMD(pci_mps, do_ut_pci_mps), -- cgit v1.3.1 From a2cf88d807a59ec20eabdb32189a598b59fc0113 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:53 -0700 Subject: test: Drop the function for running pci_mps tests Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass --- include/test/suites.h | 2 -- test/cmd/pci_mps.c | 10 ---------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 13 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index f6b33da5a28..49c18ebf456 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -35,8 +35,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/cmd/pci_mps.c b/test/cmd/pci_mps.c index 2595ea103ff..8b3ea4a6134 100644 --- a/test/cmd/pci_mps.c +++ b/test/cmd/pci_mps.c @@ -28,13 +28,3 @@ static int test_pci_mps_safe(struct unit_test_state *uts) return 0; } PCI_MPS_TEST(test_pci_mps_safe, UTF_CONSOLE); - -int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc, - char * const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(pci_mps); - const int n = UNIT_TEST_SUITE_COUNT(pci_mps); - - return cmd_ut_category("pci_mps", "pci_mps_test_", tests, n, - argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 3620be62ce6..080a36a909c 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -184,7 +184,7 @@ static struct suite suites[] = { SUITE(loadm), #endif #ifdef CONFIG_CMD_PCI_MPS - SUITE_CMD(pci_mps, do_ut_pci_mps), + SUITE(pci_mps), #endif #ifdef CONFIG_CMD_SEAMA SUITE_CMD(seama, do_ut_seama), -- cgit v1.3.1 From b073d8a2727fa1177a2944807cb5ebc5122d6a39 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:54 -0700 Subject: test: Drop the function for running seama tests Use the new suite-runner to run these tests instead. It is not clear that these actually work, since they are not enabled on sandbox for some reason. Signed-off-by: Simon Glass Acked-by: Linus Walleij --- include/test/suites.h | 1 - test/cmd/seama.c | 9 --------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 49c18ebf456..cd758b8c464 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -35,7 +35,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); #endif /* __TEST_SUITES_H__ */ diff --git a/test/cmd/seama.c b/test/cmd/seama.c index 39590d162ac..1edc3fcac5a 100644 --- a/test/cmd/seama.c +++ b/test/cmd/seama.c @@ -56,12 +56,3 @@ static int seama_test_index(struct unit_test_state *uts) return 0; } SEAMA_TEST(seama_test_index, UTF_CONSOLE); - -int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(seama); - const int n_ents = UNIT_TEST_SUITE_COUNT(seama); - - return cmd_ut_category("seama", "seama_test_", tests, n_ents, argc, - argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 080a36a909c..ed6bc3a9a49 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -187,7 +187,7 @@ static struct suite suites[] = { SUITE(pci_mps), #endif #ifdef CONFIG_CMD_SEAMA - SUITE_CMD(seama, do_ut_seama), + SUITE(seama), #endif #ifdef CONFIG_CMD_UPL SUITE_CMD(upl, do_ut_upl), -- cgit v1.3.1 From 0af17462b96953de3be877dda0d84734503596fb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:55 -0700 Subject: test: Drop the function for running upl tests Use the new suite-runner to run these tests instead. It is not clear that these actually work, since they are not enabled on sandbox for some reason. Signed-off-by: Simon Glass --- include/test/suites.h | 1 - test/boot/upl.c | 8 -------- test/cmd_ut.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index cd758b8c464..20e6a2a113b 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -35,6 +35,5 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); #endif /* __TEST_SUITES_H__ */ diff --git a/test/boot/upl.c b/test/boot/upl.c index 2c9b8bc8bc0..aa58cdf083b 100644 --- a/test/boot/upl.c +++ b/test/boot/upl.c @@ -426,11 +426,3 @@ static int upl_test_info_norun(struct unit_test_state *uts) return 0; } UPL_TEST(upl_test_info_norun, UTF_CONSOLE | UTF_MANUAL); - -int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct unit_test *tests = UNIT_TEST_SUITE_START(upl); - const int n_ents = UNIT_TEST_SUITE_COUNT(upl); - - return cmd_ut_category("upl", "cmd_upl_", tests, n_ents, argc, argv); -} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index ed6bc3a9a49..efcac626a5b 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -190,7 +190,7 @@ static struct suite suites[] = { SUITE(seama), #endif #ifdef CONFIG_CMD_UPL - SUITE_CMD(upl, do_ut_upl), + SUITE(upl), #endif }; -- cgit v1.3.1 From bbff0b165c170598c100dac81a5ee58fb07ed3ae Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:58 -0700 Subject: test: Pass the test state to cmd_ut_category() Update this function to access a unit-test state, so that the caller can collect results from running multiple suites. Signed-off-by: Simon Glass --- include/test/suites.h | 20 ++++++++++++-------- test/boot/bootstd_common.c | 7 ++++--- test/cmd_ut.c | 37 +++++++++++++++++++------------------ test/overlay/cmd_ut_overlay.c | 10 +++------- 4 files changed, 38 insertions(+), 36 deletions(-) (limited to 'include') diff --git a/include/test/suites.h b/include/test/suites.h index 20e6a2a113b..774dd893378 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -9,14 +9,18 @@ struct cmd_tbl; struct unit_test; +struct unit_test_state; /* 'command' functions normally called do_xxx where xxx is the command name */ -typedef int (*ut_cmd_func)(struct cmd_tbl *cmd, int flags, int argc, - char *const argv[]); +typedef int (*ut_cmd_func)(struct unit_test_state *uts, struct cmd_tbl *cmd, + int flags, int argc, char *const argv[]); /** * cmd_ut_category() - Run a category of unit tests * + * @uts: Unit-test state, which must be ready for use, i.e. ut_init_state() + * has been called. The caller is responsible for calling + * ut_uninit_state() after this function returns * @name: Category name * @prefix: Prefix of test name * @tests: List of tests to run @@ -26,14 +30,14 @@ typedef int (*ut_cmd_func)(struct cmd_tbl *cmd, int flags, int argc, * @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, const char *prefix, - struct unit_test *tests, int n_ents, +int cmd_ut_category(struct unit_test_state *uts, const char *name, + const char *prefix, struct unit_test *tests, int n_ents, int argc, char *const argv[]); -int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); +int do_ut_bootstd(struct unit_test_state *uts, struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); +int do_ut_overlay(struct unit_test_state *uts, struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]); #endif /* __TEST_SUITES_H__ */ diff --git a/test/boot/bootstd_common.c b/test/boot/bootstd_common.c index 6bd9bb65a40..724e3d9bdd2 100644 --- a/test/boot/bootstd_common.c +++ b/test/boot/bootstd_common.c @@ -94,7 +94,8 @@ void bootstd_reset_usb(void) usb_started = false; } -int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +int do_ut_bootstd(struct unit_test_state *uts, struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd); const int n_ents = UNIT_TEST_SUITE_COUNT(bootstd); @@ -106,6 +107,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_FAILURE; } - return cmd_ut_category("bootstd", "bootstd_", tests, n_ents, - argc, argv); + return cmd_ut_category(uts, "bootstd", "bootstd_", + tests, n_ents, argc, argv); } diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 16490e00ab3..80df954694f 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -29,17 +29,16 @@ struct suite { ut_cmd_func cmd; }; -static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); +static int do_ut_all(struct unit_test_state *uts, struct cmd_tbl *cmdtp, + int flag, int argc, char *const argv[]); static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); -int cmd_ut_category(const char *name, const char *prefix, - struct unit_test *tests, int n_ents, +int cmd_ut_category(struct unit_test_state *uts, const char *name, + const char *prefix, struct unit_test *tests, int n_ents, int argc, char *const argv[]) { - struct unit_test_state uts; const char *test_insert = NULL; int runs_per_text = 1; bool force_run = false; @@ -63,11 +62,9 @@ int cmd_ut_category(const char *name, const char *prefix, argc--; } - ut_init_state(&uts); - ret = ut_run_list(&uts, name, prefix, tests, n_ents, + ret = ut_run_list(uts, name, prefix, tests, n_ents, cmd_arg1(argc, argv), runs_per_text, force_run, test_insert); - ut_uninit_state(&uts); return ret ? CMD_RET_FAILURE : 0; } @@ -170,28 +167,29 @@ static bool has_tests(struct suite *ste) } /** run_suite() - Run a suite of tests */ -static int run_suite(struct suite *ste, struct cmd_tbl *cmdtp, int flag, - int argc, char *const argv[]) +static int run_suite(struct unit_test_state *uts, struct suite *ste, + struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) { int ret; if (ste->cmd) { - ret = ste->cmd(cmdtp, flag, argc, argv); + ret = ste->cmd(uts, cmdtp, flag, argc, argv); } else { int n_ents = ste->end - ste->start; char prefix[30]; /* use a standard prefix */ snprintf(prefix, sizeof(prefix), "%s_test", ste->name); - ret = cmd_ut_category(ste->name, prefix, ste->start, n_ents, - argc, argv); + ret = cmd_ut_category(uts, ste->name, prefix, ste->start, + n_ents, argc, argv); } return ret; } -static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) +static int do_ut_all(struct unit_test_state *uts, struct cmd_tbl *cmdtp, + int flag, int argc, char *const argv[]) { int i; int retval; @@ -203,7 +201,7 @@ static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc, if (has_tests(ste)) { printf("----Running %s tests----\n", ste->name); - retval = run_suite(ste, cmdtp, flag, 1, argv); + retval = run_suite(uts, ste, cmdtp, flag, 1, argv); if (!any_fail) any_fail = retval; } @@ -263,6 +261,7 @@ static struct suite *find_suite(const char *name) static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + struct unit_test_state uts; struct suite *ste; const char *name; int ret; @@ -274,9 +273,10 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) argc--; argv++; + ut_init_state(&uts); name = argv[0]; if (!strcmp(name, "all")) { - ret = do_ut_all(cmdtp, flag, argc, argv); + ret = do_ut_all(&uts, cmdtp, flag, argc, argv); } else if (!strcmp(name, "info")) { ret = do_ut_info(cmdtp, flag, argc, argv); } else { @@ -290,10 +290,11 @@ static int do_ut(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_FAILURE; } - ret = run_suite(ste, cmdtp, flag, argc, argv); + ret = run_suite(&uts, ste, cmdtp, flag, argc, argv); } if (ret) return ret; + ut_uninit_state(&uts); return 0; } diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c index e0483afc31d..aefa147ec04 100644 --- a/test/overlay/cmd_ut_overlay.c +++ b/test/overlay/cmd_ut_overlay.c @@ -210,21 +210,17 @@ static int fdt_overlay_stacked(struct unit_test_state *uts) } OVERLAY_TEST(fdt_overlay_stacked, 0); -int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +int do_ut_overlay(struct unit_test_state *uts, struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(overlay); const int n_ents = UNIT_TEST_SUITE_COUNT(overlay); - struct unit_test_state *uts; void *fdt_base = &__dtb_test_fdt_base_begin; void *fdt_overlay = &__dtbo_test_fdt_overlay_begin; void *fdt_overlay_stacked = &__dtbo_test_fdt_overlay_stacked_begin; void *fdt_overlay_copy, *fdt_overlay_stacked_copy; int ret = -ENOMEM; - uts = calloc(1, sizeof(*uts)); - if (!uts) - return -ENOMEM; - ut_assertok(fdt_check_header(fdt_base)); ut_assertok(fdt_check_header(fdt_overlay)); @@ -272,7 +268,7 @@ int do_ut_overlay(struct cmd_tbl *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(uts, "overlay", "", tests, n_ents, argc, argv); free(fdt_overlay_stacked_copy); err3: -- cgit v1.3.1 From 0925659a5226ee70dab8b4d3e9c8aba9ec586548 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:25:59 -0700 Subject: test: Move stats into a struct Use a struct to hold the stats, since we also want to have the same stats for all runs as we have for each suite. Signed-off-by: Simon Glass --- include/test/test.h | 17 +++++++++++++---- test/test-main.c | 29 +++++++++++++++-------------- test/ut.c | 4 ++-- 3 files changed, 30 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/include/test/test.h b/include/test/test.h index 21c0478befe..bc8f0bbe501 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -9,11 +9,21 @@ #include #include -/* - * struct unit_test_state - Entire state of test system +/** + * struct ut_stats - Statistics about tests run * * @fail_count: Number of tests that failed * @skip_count: Number of tests that were skipped + */ +struct ut_stats { + int fail_count; + int skip_count; +}; + +/* + * struct unit_test_state - Entire state of test system + * + * @cur: Statistics for the current run * @start: Store the starting mallinfo when doing leak test * @of_live: true to use livetree if available, false to use flattree * @of_root: Record of the livetree root node (used for setting up tests) @@ -34,8 +44,7 @@ * @actual_str: Temporary string used to hold actual string value */ struct unit_test_state { - int fail_count; - int skip_count; + struct ut_stats cur; struct mallinfo start; struct device_node *of_root; bool of_live; diff --git a/test/test-main.c b/test/test-main.c index 391d4e7bb0e..e8aecd267c7 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -448,7 +448,7 @@ static int test_post_run(struct unit_test_state *uts, struct unit_test *test) */ static int skip_test(struct unit_test_state *uts) { - uts->skip_count++; + uts->cur.skip_count++; return -EAGAIN; } @@ -460,7 +460,7 @@ static int skip_test(struct unit_test_state *uts) * the name of each test before running it. * * @uts: Test state to update. The caller should ensure that this is zeroed for - * the first call to this function. On exit, @uts->fail_count is + * the first call to this function. On exit, @uts->cur.fail_count is * incremented by the number of failures (0, one hopes) * @test_name: Test to run * @name: Name of test, possibly skipping a prefix that should not be displayed @@ -510,7 +510,7 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test, * SPL. * * @uts: Test state to update. The caller should ensure that this is zeroed for - * the first call to this function. On exit, @uts->fail_count is + * the first call to this function. On exit, @uts->cur.fail_count is * incremented by the number of failures (0, one hopes) * @test: Test to run * Return: 0 if all tests passed, -EAGAIN if the test should be skipped, -1 if @@ -574,7 +574,7 @@ static int ut_run_test_live_flat(struct unit_test_state *uts, * the name of each test before running it. * * @uts: Test state to update. The caller should ensure that this is zeroed for - * the first call to this function. On exit, @uts->fail_count is + * the first call to this function. On exit, @uts->cur.fail_count is * incremented by the number of failures (0, one hopes) * @prefix: String prefix for the tests. Any tests that have this prefix will be * printed without the prefix, so that it is easier to see the unique part @@ -632,7 +632,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix, if (len < 6 || strcmp(test_name + len - 6, "_norun")) { printf("Test '%s' is manual so must have a name ending in _norun\n", test_name); - uts->fail_count++; + uts->cur.fail_count++; return -EBADF; } if (!uts->force_run) { @@ -641,23 +641,24 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix, continue; } } - old_fail_count = uts->fail_count; + old_fail_count = uts->cur.fail_count; if (one && upto == pos) { ret = ut_run_test_live_flat(uts, one); - if (uts->fail_count != old_fail_count) { + if (uts->cur.fail_count != old_fail_count) { printf("Test '%s' failed %d times (position %d)\n", one->name, - uts->fail_count - old_fail_count, pos); + uts->cur.fail_count - old_fail_count, + pos); } return -EBADF; } for (i = 0; i < uts->runs_per_test; i++) ret = ut_run_test_live_flat(uts, test); - if (uts->fail_count != old_fail_count) { + if (uts->cur.fail_count != old_fail_count) { printf("Test '%s' failed %d times\n", test_name, - uts->fail_count - old_fail_count); + uts->cur.fail_count - old_fail_count); } found++; if (ret == -EAGAIN) @@ -668,7 +669,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix, if (select_name && !found) return -ENOENT; - return uts->fail_count ? -EBADF : 0; + return uts->cur.fail_count ? -EBADF : 0; } int ut_run_list(struct unit_test_state *uts, const char *category, @@ -716,12 +717,12 @@ int ut_run_list(struct unit_test_state *uts, const char *category, if (has_dm_tests) dm_test_restore(uts->of_root); - if (uts->skip_count) - printf("Skipped: %d, ", uts->skip_count); + if (uts->cur.skip_count) + printf("Skipped: %d, ", uts->cur.skip_count); if (ret == -ENOENT) printf("Test '%s' not found\n", select_name); else - printf("Failures: %d\n", uts->fail_count); + printf("Failures: %d\n", uts->cur.fail_count); return ret; } diff --git a/test/ut.c b/test/ut.c index 7454da3e001..a16fdfb3a93 100644 --- a/test/ut.c +++ b/test/ut.c @@ -21,7 +21,7 @@ void ut_fail(struct unit_test_state *uts, const char *fname, int line, { gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); printf("%s:%d, %s(): %s\n", fname, line, func, cond); - uts->fail_count++; + uts->cur.fail_count++; } void ut_failf(struct unit_test_state *uts, const char *fname, int line, @@ -35,7 +35,7 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line, vprintf(fmt, args); va_end(args); putc('\n'); - uts->fail_count++; + uts->cur.fail_count++; } ulong ut_check_free(void) -- cgit v1.3.1 From 561320beffd10d133a316aacaf3170387324bdae Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:26:00 -0700 Subject: test: Keep a track of the numbers of tests run This is useful information and is not always the same as the 'count' arg to ut_run_list() so add it as a separate stat. Signed-off-by: Simon Glass --- include/test/test.h | 3 +++ test/test-main.c | 2 ++ 2 files changed, 5 insertions(+) (limited to 'include') diff --git a/include/test/test.h b/include/test/test.h index bc8f0bbe501..f7087ab4eea 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -14,10 +14,13 @@ * * @fail_count: Number of tests that failed * @skip_count: Number of tests that were skipped + * @test_count: Number of tests run. If a test is run muiltiple times, only one + * is counted */ struct ut_stats { int fail_count; int skip_count; + int test_count; }; /* diff --git a/test/test-main.c b/test/test-main.c index e8aecd267c7..e36bc37d29e 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -643,6 +643,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix, } old_fail_count = uts->cur.fail_count; + uts->cur.test_count++; if (one && upto == pos) { ret = ut_run_test_live_flat(uts, one); if (uts->cur.fail_count != old_fail_count) { @@ -717,6 +718,7 @@ int ut_run_list(struct unit_test_state *uts, const char *category, if (has_dm_tests) dm_test_restore(uts->of_root); + printf("Tests run: %d, ", uts->cur.test_count); if (uts->cur.skip_count) printf("Skipped: %d, ", uts->cur.skip_count); if (ret == -ENOENT) -- cgit v1.3.1 From 15c39587cf8a977df33aba37715b6ce3e17536d7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:26:01 -0700 Subject: test: Move stat-printing into its own function Add a function to show the stats, so we can decide when to print it. This slightly adjusts the output, so that any 'test not found' message appears on its own line after all other output. The 'failures' message now appears in lower case so update pytest accordingly. Signed-off-by: Simon Glass --- arch/sandbox/cpu/spl.c | 1 + include/test/ut.h | 8 ++++++++ test/py/tests/test_spl.py | 2 +- test/py/tests/test_upl.py | 2 +- test/py/tests/test_ut.py | 2 +- test/py/tests/test_vbe.py | 2 +- test/py/tests/test_vpl.py | 2 +- test/test-main.c | 18 +++++++++++++----- 8 files changed, 27 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 0ad23e4ba95..ecc03785463 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -153,6 +153,7 @@ void spl_board_init(void) ut_init_state(&uts); ret = ut_run_list(&uts, "spl", NULL, tests, count, state->select_unittests, 1, false, NULL); + ut_report(&uts.cur, 1); ut_uninit_state(&uts); /* continue execution into U-Boot */ } diff --git a/include/test/ut.h b/include/test/ut.h index a51defc3b90..be5502e03a1 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -530,4 +530,12 @@ int ut_run_list(struct unit_test_state *uts, const char *category, const char *select_name, int runs_per_test, bool force_run, const char *test_insert); +/** + * ut_report() - Report stats on a test run + * + * @stats: Stats to show + * @run_count: Number of suites that were run + */ +void ut_report(struct ut_stats *stats, int run_count); + #endif diff --git a/test/py/tests/test_spl.py b/test/py/tests/test_spl.py index 42e4c4342b2..474f430a344 100644 --- a/test/py/tests/test_spl.py +++ b/test/py/tests/test_spl.py @@ -36,7 +36,7 @@ def test_spl(u_boot_console, ut_spl_subtest): cons = u_boot_console cons.restart_uboot_with_flags(['-u', '-k', ut_spl_subtest.split()[1]]) output = cons.get_spawn_output().replace('\r', '') - assert 'Failures: 0' in output + assert 'failures: 0' in output finally: # Restart afterward in case a non-SPL test is run next. This should not # happen since SPL tests are run in their own invocation of test.py, but diff --git a/test/py/tests/test_upl.py b/test/py/tests/test_upl.py index 3164bda6b71..d94359d8b9b 100644 --- a/test/py/tests/test_upl.py +++ b/test/py/tests/test_upl.py @@ -35,4 +35,4 @@ def test_upl_handoff(u_boot_console): # Check the FIT offsets look correct output = cons.run_command('ut upl -f upl_test_info_norun') - assert 'Failures: 0' in output + assert 'failures: 0' in output diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index cacf11f7c0a..d2d8ce10755 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -607,4 +607,4 @@ def test_ut(u_boot_console, ut_subtest): assert 'Unknown command \'quux\' - try \'help\'' in output else: output = u_boot_console.run_command('ut ' + ut_subtest) - assert output.endswith('Failures: 0') + assert output.endswith('failures: 0') diff --git a/test/py/tests/test_vbe.py b/test/py/tests/test_vbe.py index 50b6c1cd911..861df3f8266 100644 --- a/test/py/tests/test_vbe.py +++ b/test/py/tests/test_vbe.py @@ -117,4 +117,4 @@ def test_vbe(u_boot_console): with cons.log.section('Kernel load'): output = cons.run_command_list(cmd.splitlines()) - assert 'Failures: 0' in output[-1] + assert 'failures: 0' in output[-1] diff --git a/test/py/tests/test_vpl.py b/test/py/tests/test_vpl.py index 4af578b9173..8c472ca7a92 100644 --- a/test/py/tests/test_vpl.py +++ b/test/py/tests/test_vpl.py @@ -26,7 +26,7 @@ def test_vpl(u_boot_console, ut_vpl_subtest): cons = u_boot_console cons.restart_uboot_with_flags(['-u', '-k', ut_vpl_subtest.split()[1]]) output = cons.get_spawn_output().replace('\r', '') - assert 'Failures: 0' in output + assert 'failures: 0' in output finally: # Restart afterward in case a non-VPL test is run next. This should not # happen since VPL tests are run in their own invocation of test.py, but diff --git a/test/test-main.c b/test/test-main.c index e36bc37d29e..d02ab791b5a 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -673,6 +673,18 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix, return uts->cur.fail_count ? -EBADF : 0; } +void ut_report(struct ut_stats *stats, int run_count) +{ + if (run_count > 1) + printf("Suites run: %d, total tests", run_count); + else + printf("Tests"); + printf(" run: %d, ", stats->test_count); + if (stats->skip_count) + printf("skipped: %d, ", stats->skip_count); + printf("failures: %d\n", stats->fail_count); +} + int ut_run_list(struct unit_test_state *uts, const char *category, const char *prefix, struct unit_test *tests, int count, const char *select_name, int runs_per_test, bool force_run, @@ -718,13 +730,9 @@ int ut_run_list(struct unit_test_state *uts, const char *category, if (has_dm_tests) dm_test_restore(uts->of_root); - printf("Tests run: %d, ", uts->cur.test_count); - if (uts->cur.skip_count) - printf("Skipped: %d, ", uts->cur.skip_count); + ut_report(&uts->cur, 1); if (ret == -ENOENT) printf("Test '%s' not found\n", select_name); - else - printf("Failures: %d\n", uts->cur.fail_count); return ret; } -- cgit v1.3.1 From 6d97c98095a11ca104a8ea7a560469ae7e2c2bd0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Jan 2025 14:26:02 -0700 Subject: test: Record and show the totals for all test runs With 'ut all' multiple test suites are run. Add a way to collect totals and show them at the end. Signed-off-by: Simon Glass --- include/test/test.h | 4 ++++ test/cmd_ut.c | 1 + test/test-main.c | 7 +++++++ 3 files changed, 12 insertions(+) (limited to 'include') diff --git a/include/test/test.h b/include/test/test.h index f7087ab4eea..bac43c81d63 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -27,6 +27,8 @@ struct ut_stats { * struct unit_test_state - Entire state of test system * * @cur: Statistics for the current run + * @total: Statistics for all test runs + * @run_count: Number of times ut_run_list() has been called * @start: Store the starting mallinfo when doing leak test * @of_live: true to use livetree if available, false to use flattree * @of_root: Record of the livetree root node (used for setting up tests) @@ -48,6 +50,8 @@ struct ut_stats { */ struct unit_test_state { struct ut_stats cur; + struct ut_stats total; + int run_count; struct mallinfo start; struct device_node *of_root; bool of_live; diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 80df954694f..0b8bfe603b9 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -206,6 +206,7 @@ static int do_ut_all(struct unit_test_state *uts, struct cmd_tbl *cmdtp, any_fail = retval; } } + ut_report(&uts->total, uts->run_count); return any_fail; } diff --git a/test/test-main.c b/test/test-main.c index d02ab791b5a..22b9b46d9cd 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -694,6 +694,8 @@ int ut_run_list(struct unit_test_state *uts, const char *category, bool has_dm_tests = false; int ret; + memset(&uts->cur, '\0', sizeof(struct ut_stats)); + if (!CONFIG_IS_ENABLED(OF_PLATDATA) && ut_list_has_dm_tests(tests, count, prefix, select_name)) { has_dm_tests = true; @@ -734,5 +736,10 @@ int ut_run_list(struct unit_test_state *uts, const char *category, if (ret == -ENOENT) printf("Test '%s' not found\n", select_name); + uts->total.skip_count += uts->cur.skip_count; + uts->total.fail_count += uts->cur.fail_count; + uts->total.test_count += uts->cur.test_count; + uts->run_count++; + return ret; } -- cgit v1.3.1