dm: test: Fix running of multiple test from command line
authorSimon Glass <sjg@chromium.org>
Wed, 25 Sep 2019 14:55:51 +0000 (08:55 -0600)
committerBin Meng <bmeng.cn@gmail.com>
Tue, 8 Oct 2019 05:57:38 +0000 (13:57 +0800)
At present when multiple 'ut dm' commands are executed, all but the first
is run with a flat tree, even if live tree is enabled. This is because the
live tree node pointer is set to NULL and never restored.

This does not affect normal test running, which just runs all the test in
one go, but can be confusing when several individual tests are run during
the same U-Boot run.

Correct this by restoring the pointer.

Fixes: c166c47ba3 (dm: test: Add support for running tests with livetree)
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
test/dm/test-main.c

index 5d79ce641d7b6c4198f08f9d1f78b327ea80e341..487d8b9627539c6eb2df04d271d01ba5bd4cddd8 100644 (file)
@@ -188,8 +188,12 @@ static int dm_test_main(const char *test_name)
        else
                printf("Failures: %d\n", uts->fail_count);
 
+       /* Put everything back to normal so that sandbox works as expected */
+#ifdef CONFIG_OF_LIVE
+       gd->of_root = uts->of_root;
+#endif
        gd->dm_root = NULL;
-       ut_assertok(dm_init(false));
+       ut_assertok(dm_init(IS_ENABLED(CONFIG_OF_LIVE)));
        dm_scan_platdata(false);
        dm_scan_fdt(gd->fdt_blob, false);