summaryrefslogtreecommitdiff
path: root/test/dm/test-dm.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-08 03:35:05 +0300
committerTom Rini <trini@konsulko.com>2021-03-12 17:57:30 +0300
commitf97f85e6618667c877b90e938d6bf36d56e69270 (patch)
treeb41379638260f8e854aa67e77d12bf4652a32bde /test/dm/test-dm.c
parentfe806861a98b4ad524d070c6d7b9d20fd475ec6f (diff)
downloadu-boot-f97f85e6618667c877b90e938d6bf36d56e69270.tar.xz
test: Run driver-model tests using ut_run_list()
Use this function instead of implementing it separately for driver model. Make ut_run_tests() private since it is only used in test-main.c Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/test-dm.c')
-rw-r--r--test/dm/test-dm.c45
1 files changed, 5 insertions, 40 deletions
diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c
index cdaf27bf98..20af1c13b3 100644
--- a/test/dm/test-dm.c
+++ b/test/dm/test-dm.c
@@ -20,31 +20,14 @@
DECLARE_GLOBAL_DATA_PTR;
-static bool test_matches(const char *test_name, const char *find_name)
-{
- if (!find_name)
- return true;
-
- if (!strcmp(test_name, find_name))
- return true;
-
- /* All tests have this prefix */
- if (!strncmp(test_name, "dm_test_", 8))
- test_name += 8;
-
- if (!strcmp(test_name, find_name))
- return true;
-
- return false;
-}
+struct unit_test_state global_dm_test_state;
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_state uts_s = { .fail_count = 0 }, *uts = &uts_s;
- struct unit_test *test;
- int found;
+ struct device_node *of_root;
uts->fail_count = 0;
@@ -60,29 +43,11 @@ int dm_test_run(const char *test_name)
}
}
- if (!test_name)
- printf("Running %d driver model tests\n", n_ents);
- else
-
- found = 0;
- uts->of_root = gd_of_root();
- for (test = tests; test < tests + n_ents; test++) {
- const char *name = test->name;
-
- if (!test_matches(name, test_name))
- continue;
-
- ut_assertok(ut_run_test_live_flat(uts, test, test->name));
- found++;
- }
-
- if (test_name && !found)
- printf("Test '%s' not found\n", test_name);
- else
- printf("Failures: %d\n", uts->fail_count);
+ of_root = gd_of_root();
+ ut_run_list("driver model", "dm_test_", tests, n_ents, test_name);
/* Put everything back to normal so that sandbox works as expected */
- gd_set_of_root(uts->of_root);
+ gd_set_of_root(of_root);
gd->dm_root = NULL;
ut_assertok(dm_init(CONFIG_IS_ENABLED(OF_LIVE)));
dm_scan_plat(false);