+static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
+ bool of_live)
+{
+ struct sandbox_state *state = state_get_current();
+ const char *fname = strrchr(test->file, '/') + 1;
+
+ printf("Test: %s: %s%s\n", test->name, fname,
+ !of_live ? " (flat tree)" : "");
+ ut_assertok(dm_test_init(uts, of_live));
+
+ uts->start = mallinfo();
+ if (test->flags & DM_TESTF_SCAN_PDATA)
+ ut_assertok(dm_scan_platdata(false));
+ if (test->flags & DM_TESTF_PROBE_TEST)
+ ut_assertok(do_autoprobe(uts));
+ if (test->flags & DM_TESTF_SCAN_FDT)
+ ut_assertok(dm_extended_scan_fdt(gd->fdt_blob, false));
+
+ /*
+ * Silence the console and rely on console recording to get
+ * our output.
+ */
+ console_record_reset_enable();
+ if (!state->show_test_output)
+ gd->flags |= GD_FLG_SILENT;
+ test->func(uts);
+ gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
+ state_set_skip_delays(false);
+
+ ut_assertok(dm_test_destroy(uts));
+
+ return 0;
+}
+
+/**
+ * dm_test_run_on_flattree() - Check if we should run a test with flat DT
+ *
+ * This skips long/slow tests where there is not much value in running a flat
+ * DT test in addition to a live DT test.
+ *
+ * @return true to run the given test on the flat device tree
+ */
+static bool dm_test_run_on_flattree(struct unit_test *test)
+{
+ const char *fname = strrchr(test->file, '/') + 1;
+
+ return !strstr(fname, "video") || strstr(test->name, "video_base");
+}
+
+static int dm_test_main(const char *test_name)