Skip to content

Commit

Permalink
test: Add a macros for finding tests in linker_lists
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sjg20 authored and trini committed Mar 12, 2021
1 parent 5c1cf4d commit a7a9875
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 32 deletions.
6 changes: 6 additions & 0 deletions include/test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions test/bloblist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/cmd/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions test/cmd/setexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions test/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/dm/test-dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/env/cmd_ut_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/lib/cmd_ut_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions test/log/log_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions test/optee/cmd_ut_optee.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions test/overlay/cmd_ut_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions test/str_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions test/unicode_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a7a9875

Please sign in to comment.