* 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
* @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[]);
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);
}
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);
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);
}
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);
}
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);
}
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;
/* 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:
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);
}