summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut+renesas@mailbox.org>2023-03-02 04:08:30 +0100
committerSimon Glass <sjg@chromium.org>2023-03-09 08:50:48 -0800
commit79bcd809f49ccb9ab7bc9712904475fbf5fb048c (patch)
tree01e336526c05ed4baa4263007f4d574e003e06ec /test
parente2d7daa6c932646c25fadbf52ac68462de60e2f9 (diff)
test: cmd: fdt: Test fdt move
Add 'fdt move' test which works as follows: - Create simple FDT, map it to sysmem - 'move' the FDT into new zeroed out sysmem location - Verify newly active FDT is in the new location - Compare both locations The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/cmd/fdt.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 69a69c5c75..023b83eb01 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -238,6 +238,40 @@ static int fdt_test_addr_resize(struct unit_test_state *uts)
}
FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC);
+static int fdt_test_move(struct unit_test_state *uts)
+{
+ char fdt[256];
+ ulong addr, newaddr = 0x10000;
+ const int size = sizeof(fdt);
+ uint32_t ts;
+ void *buf;
+
+ /* Original source DT */
+ ut_assertok(make_test_fdt(uts, fdt, size));
+ ts = fdt_totalsize(fdt);
+ addr = map_to_sysmem(fdt);
+ set_working_fdt_addr(addr);
+
+ /* Moved target DT location */
+ buf = map_sysmem(newaddr, size);
+ memset(buf, 0, size);
+
+ /* Test moving the working FDT to a new location */
+ ut_assertok(console_record_reset_enable());
+ ut_assertok(run_commandf("fdt move %08x %08x %x", addr, newaddr, ts));
+ ut_assert_nextline("Working FDT set to %lx", newaddr);
+ ut_assertok(ut_check_console_end(uts));
+
+ /* Compare the source and destination DTs */
+ ut_assertok(console_record_reset_enable());
+ ut_assertok(run_commandf("cmp.b %08x %08x %x", addr, newaddr, ts));
+ ut_assert_nextline("Total of %d byte(s) were the same", ts);
+ ut_assertok(ut_check_console_end(uts));
+
+ return 0;
+}
+FDT_TEST(fdt_test_move, UT_TESTF_CONSOLE_REC);
+
/* Test 'fdt get value' reading an fdt */
static int fdt_test_get_value_string(struct unit_test_state *uts,
const char *node, const char *prop,