summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-05-19 02:09:14 (GMT)
committerSimon Glass <sjg@chromium.org>2017-06-01 13:03:09 (GMT)
commitf86db10cc56b9c8b73cb1bb94c5172c96958ef29 (patch)
tree38e7d4c93dac2a8a44a7e45e3c7b127be71be7af /test
parent34b744beb866c9ae660f2851f9776f80e165d421 (diff)
downloadu-boot-fsl-qoriq-f86db10cc56b9c8b73cb1bb94c5172c96958ef29.tar.xz
dm: test: Move test running code into a separate function
We want to run the same test on flat and live trees. In preparation for this, create a new function which handles running a test. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/test-main.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 9aa9d3a..2848673 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -72,12 +72,42 @@ static int dm_test_destroy(struct unit_test_state *uts)
return 0;
}
+static int dm_do_test(struct unit_test_state *uts, struct unit_test *test)
+{
+ struct sandbox_state *state = state_get_current();
+
+ printf("Test: %s\n", test->name);
+ ut_assertok(dm_test_init(uts));
+
+ 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_scan_fdt(gd->fdt_blob, false));
+
+ /*
+ * Silence the console and rely on console reocrding to get
+ * our output.
+ */
+ console_record_reset();
+ if (!state->show_test_output)
+ gd->flags |= GD_FLG_SILENT;
+ test->func(uts);
+ gd->flags &= ~GD_FLG_SILENT;
+ state_set_skip_delays(false);
+
+ ut_assertok(dm_test_destroy(uts));
+
+ return 0;
+}
+
static int dm_test_main(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 = &global_dm_test_state;
- struct sandbox_state *state = state_get_current();
uts->priv = &_global_priv_dm_test_state;
struct unit_test *test;
int run_count;
@@ -106,30 +136,8 @@ static int dm_test_main(const char *test_name)
name += 8;
if (test_name && strcmp(test_name, name))
continue;
- printf("Test: %s\n", test->name);
+ ut_assertok(dm_do_test(uts, test));
run_count++;
- ut_assertok(dm_test_init(uts));
-
- 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_scan_fdt(gd->fdt_blob, false));
-
- /*
- * Silence the console and rely on console reocrding to get
- * our output.
- */
- console_record_reset();
- if (!state->show_test_output)
- gd->flags |= GD_FLG_SILENT;
- test->func(uts);
- gd->flags &= ~GD_FLG_SILENT;
- state_set_skip_delays(false);
-
- ut_assertok(dm_test_destroy(uts));
}
if (test_name && !run_count)