diff --git a/include/test/suites.h b/include/test/suites.h index 20970f08d6646795ec7aaae24429f858dbd5ed88..0748185eaf75b05011ccc52b8474383e8ed298fe 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -13,6 +13,7 @@ struct unit_test; * cmd_ut_category() - Run a category of unit tests * * @name: Category name + * @prefix: Prefix of test name * @tests: List of tests to run * @n_ents: Number of tests in @tests * @argc: Argument count provided. Must be >= 1. If this is 1 then all @@ -20,7 +21,8 @@ struct unit_test; * @argv: Arguments: argv[1] is the test to run (if @argc >= 2) * @return 0 if OK, CMD_RET_FAILURE on failure */ -int cmd_ut_category(const char *name, struct unit_test *tests, int n_ents, +int cmd_ut_category(const char *name, const char *prefix, + struct unit_test *tests, int n_ents, int argc, char * const argv[]); int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); diff --git a/test/bloblist.c b/test/bloblist.c index 89bdb012e351e1bf23ecc91c33a61a29c8751ef8..d0f7296e0d89c40805f9dcb4d6220c1b038995c1 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -183,5 +183,6 @@ int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) bloblist_test); const int n_ents = ll_entry_count(struct unit_test, bloblist_test); - return cmd_ut_category("bloblist", tests, n_ents, argc, argv); + return cmd_ut_category("bloblist", "bloblist_test_", + tests, n_ents, argc, argv); } diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 2781f8bd5668cafdde519bb1653cdc3e8a7f8172..400719e7b67935af9c885cc53d44fbcbfa199fd8 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -11,17 +11,25 @@ static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); -int cmd_ut_category(const char *name, struct unit_test *tests, int n_ents, +int cmd_ut_category(const char *name, const char *prefix, + struct unit_test *tests, int n_ents, int argc, char * const argv[]) { struct unit_test_state uts = { .fail_count = 0 }; struct unit_test *test; + int prefix_len = prefix ? strlen(prefix) : 0; if (argc == 1) printf("Running %d %s tests\n", n_ents, name); for (test = tests; test < tests + n_ents; test++) { - if (argc > 1 && strcmp(argv[1], test->name)) + const char *test_name = test->name; + + /* Remove the prefix */ + if (!strncmp(test_name, prefix, prefix_len)) + test_name += prefix_len; + + if (argc > 1 && strcmp(argv[1], test_name)) continue; printf("Test: %s\n", test->name); diff --git a/test/compression.c b/test/compression.c index 48dccc0e891ba3734b6703559c3e1ce7ca5f61f3..cf040d7c8612eba2c8ebf96b1c8fc5bf8f1409f1 100644 --- a/test/compression.c +++ b/test/compression.c @@ -540,5 +540,6 @@ int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) compression_test); const int n_ents = ll_entry_count(struct unit_test, compression_test); - return cmd_ut_category("compression", tests, n_ents, argc, argv); + return cmd_ut_category("compression", "compression_test_", + tests, n_ents, argc, argv); } diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c index 54041a02197d500109f3c017944c2e4c2984c494..ad67dbe7929fdebc374c767f4d1a3c343d557d46 100644 --- a/test/env/cmd_ut_env.c +++ b/test/env/cmd_ut_env.c @@ -15,5 +15,6 @@ int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct unit_test *tests = ll_entry_start(struct unit_test, env_test); const int n_ents = ll_entry_count(struct unit_test, env_test); - return cmd_ut_category("environment", tests, n_ents, argc, argv); + return cmd_ut_category("environment", "env_test_", + tests, n_ents, argc, argv); } diff --git a/test/lib/cmd_ut_lib.c b/test/lib/cmd_ut_lib.c index eb90e539148e880eb1217c6ef9632bbfcd338fde..c73e8d7b05a98c1b62377aeb819f1ac8f768ab35 100644 --- a/test/lib/cmd_ut_lib.c +++ b/test/lib/cmd_ut_lib.c @@ -16,5 +16,5 @@ int do_ut_lib(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct unit_test *tests = ll_entry_start(struct unit_test, lib_test); const int n_ents = ll_entry_count(struct unit_test, lib_test); - return cmd_ut_category("lib", tests, n_ents, argc, argv); + return cmd_ut_category("lib", "lib_test_", tests, n_ents, argc, argv); } diff --git a/test/optee/cmd_ut_optee.c b/test/optee/cmd_ut_optee.c index 670682f3d41eddf32216d9012b1db4dda7808363..092710326a8be2fb8a544ef668bea0a677dc6564 100644 --- a/test/optee/cmd_ut_optee.c +++ b/test/optee/cmd_ut_optee.c @@ -129,20 +129,20 @@ int do_ut_optee(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ut_assertok(optee_copy_fdt_nodes(fdt_no_optee, fdt)); expect_success = false; - ret = cmd_ut_category("optee", tests, n_ents, argc, argv); + ret = cmd_ut_category("optee", "", tests, n_ents, argc, argv); /* (2) Try to copy optee nodes from prefilled dt */ ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt)); expect_success = true; - ret = cmd_ut_category("optee", tests, n_ents, argc, argv); + ret = cmd_ut_category("optee", "", tests, n_ents, argc, argv); /* (3) Try to copy OP-TEE nodes into a already filled DT */ ut_assertok(fdt_open_into(fdt_optee, fdt, FDT_COPY_SIZE)); ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt)); expect_success = true; - ret = cmd_ut_category("optee", tests, n_ents, argc, argv); + ret = cmd_ut_category("optee", "", tests, n_ents, argc, argv); free(fdt); return ret; diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c index fc2491d0b4750d59246f7a98e15cda33c758d7d5..d0083fd6bee32bdb83ac5c084889b8e15e63b5c2 100644 --- a/test/overlay/cmd_ut_overlay.c +++ b/test/overlay/cmd_ut_overlay.c @@ -272,7 +272,7 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* Apply the stacked overlay */ ut_assertok(fdt_overlay_apply(fdt, fdt_overlay_stacked_copy)); - ret = cmd_ut_category("overlay", tests, n_ents, argc, argv); + ret = cmd_ut_category("overlay", "", tests, n_ents, argc, argv); free(fdt_overlay_stacked_copy); err3: diff --git a/test/unicode_ut.c b/test/unicode_ut.c index 8875cdc6b2f5b6b8e419c54111cad669784bc576..47532a64df62b8409ac2dd8e8e716ee84ee15b4c 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -585,5 +585,6 @@ int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct unit_test *tests = ll_entry_start(struct unit_test, unicode_test); const int n_ents = ll_entry_count(struct unit_test, unicode_test); - return cmd_ut_category("Unicode", tests, n_ents, argc, argv); + return cmd_ut_category("Unicode", "unicode_test_", + tests, n_ents, argc, argv); }