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>
diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c
index cdaf27b..20af1c1 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 @@
 		}
 	}
 
-	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);