From a7a98755b888254cbc1857c567ce898a8e105e0f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 7 Mar 2021 17:35:10 -0700 Subject: [PATCH] test: Add a macros for finding tests in linker_lists At present we use the linker list directly. This is not very friendly, so add a helpful macro instead. This will also allow us to change the naming later without updating this code. Signed-off-by: Simon Glass --- include/test/test.h | 6 ++++++ test/bloblist.c | 5 ++--- test/bootm.c | 4 ++-- test/cmd/mem.c | 4 ++-- test/cmd/setexpr.c | 5 ++--- test/compression.c | 5 ++--- test/dm/test-dm.c | 4 ++-- test/env/cmd_ut_env.c | 4 ++-- test/lib/cmd_ut_lib.c | 4 ++-- test/log/log_ut.c | 4 ++-- test/optee/cmd_ut_optee.c | 5 ++--- test/overlay/cmd_ut_overlay.c | 5 ++--- test/str_ut.c | 5 ++--- test/unicode_ut.c | 4 ++-- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/test/test.h b/include/test/test.h index 5eeec35f52..b16c9135f2 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -93,6 +93,12 @@ struct unit_test { .func = _name, \ } +/* Get the start of a list of unit tests for a particular category */ +#define UNIT_TEST_SUITE_START(_suite) \ + ll_entry_start(struct unit_test, _suite) +#define UNIT_TEST_SUITE_COUNT(_suite) \ + ll_entry_count(struct unit_test, _suite) + /* Sizes for devres tests */ enum { TEST_DEVRES_SIZE = 100, diff --git a/test/bloblist.c b/test/bloblist.c index 6953d3010a..d876b63918 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -387,9 +387,8 @@ BLOBLIST_TEST(bloblist_test_reloc, 0); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - bloblist_test); - const int n_ents = ll_entry_count(struct unit_test, bloblist_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(bloblist_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(bloblist_test); return cmd_ut_category("bloblist", "bloblist_test_", tests, n_ents, argc, argv); diff --git a/test/bootm.c b/test/bootm.c index 563d6ebaa5..8528982ae1 100644 --- a/test/bootm.c +++ b/test/bootm.c @@ -240,8 +240,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 = ll_entry_start(struct unit_test, bootm_test); - const int n_ents = ll_entry_count(struct unit_test, bootm_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(bootm_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(bootm_test); return cmd_ut_category("bootm", "bootm_test_", tests, n_ents, argc, argv); diff --git a/test/cmd/mem.c b/test/cmd/mem.c index fbaa8a4b3c..d76f47cf31 100644 --- a/test/cmd/mem.c +++ b/test/cmd/mem.c @@ -12,8 +12,8 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, mem_test); - const int n_ents = ll_entry_count(struct unit_test, mem_test); + 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, argv); diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index b483069ff0..27113c083c 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -390,9 +390,8 @@ SETEXPR_TEST(setexpr_test_str_long, UT_TESTF_CONSOLE_REC); int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - setexpr_test); - const int n_ents = ll_entry_count(struct unit_test, setexpr_test); + 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, argc, argv); diff --git a/test/compression.c b/test/compression.c index a2a4b9ff9e..4cd1be564f 100644 --- a/test/compression.c +++ b/test/compression.c @@ -539,9 +539,8 @@ COMPRESSION_TEST(compression_test_bootm_none, 0); int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - compression_test); - const int n_ents = ll_entry_count(struct unit_test, compression_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(compression_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(compression_test); return cmd_ut_category("compression", "compression_test_", tests, n_ents, argc, argv); diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c index cb4f99537d..729becf57b 100644 --- a/test/dm/test-dm.c +++ b/test/dm/test-dm.c @@ -22,8 +22,8 @@ DECLARE_GLOBAL_DATA_PTR; int dm_test_run(const char *test_name) { - struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); - const int n_ents = ll_entry_count(struct unit_test, dm_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(dm_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(dm_test); int ret; ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name); diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c index a440b1bfb0..d65a32179c 100644 --- a/test/env/cmd_ut_env.c +++ b/test/env/cmd_ut_env.c @@ -12,8 +12,8 @@ int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, env_test); - const int n_ents = ll_entry_count(struct unit_test, env_test); + 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); diff --git a/test/lib/cmd_ut_lib.c b/test/lib/cmd_ut_lib.c index f5c7bf3d3b..f1ac015b2c 100644 --- a/test/lib/cmd_ut_lib.c +++ b/test/lib/cmd_ut_lib.c @@ -13,8 +13,8 @@ int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, lib_test); - const int n_ents = ll_entry_count(struct unit_test, lib_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(lib_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(lib_test); 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 c534add493..5aa3a18400 100644 --- a/test/log/log_ut.c +++ b/test/log/log_ut.c @@ -13,8 +13,8 @@ int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, log_test); - const int n_ents = ll_entry_count(struct unit_test, log_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(log_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(log_test); 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 9fa4c91e0d..c3887ab11d 100644 --- a/test/optee/cmd_ut_optee.c +++ b/test/optee/cmd_ut_optee.c @@ -94,9 +94,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 = ll_entry_start(struct unit_test, - optee_test); - const int n_ents = ll_entry_count(struct unit_test, optee_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(optee_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(optee_test); 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 c001fb183f..56a3df1713 100644 --- a/test/overlay/cmd_ut_overlay.c +++ b/test/overlay/cmd_ut_overlay.c @@ -213,9 +213,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 = ll_entry_start(struct unit_test, - overlay_test); - const int n_ents = ll_entry_count(struct unit_test, overlay_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(overlay_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(overlay_test); struct unit_test_state *uts; void *fdt_base = &__dtb_test_fdt_base_begin; void *fdt_overlay = &__dtb_test_fdt_overlay_begin; diff --git a/test/str_ut.c b/test/str_ut.c index cd5045516d..359d7d4ea1 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -107,9 +107,8 @@ STR_TEST(str_simple_strtoul, 0); int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, - str_test); - const int n_ents = ll_entry_count(struct unit_test, str_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(str_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(str_test); return cmd_ut_category("str", "str_", tests, n_ents, argc, argv); } diff --git a/test/unicode_ut.c b/test/unicode_ut.c index 6130ef0b54..7b9c020eff 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -615,8 +615,8 @@ UNICODE_TEST(unicode_test_efi_create_indexed_name); int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct unit_test *tests = ll_entry_start(struct unit_test, unicode_test); - const int n_ents = ll_entry_count(struct unit_test, unicode_test); + struct unit_test *tests = UNIT_TEST_SUITE_START(unicode_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(unicode_test); return cmd_ut_category("Unicode", "unicode_test_", tests, n_ents, argc, argv);