aboutsummaryrefslogtreecommitdiff
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-08 11:40:57 -0800
commit05728722dd9da35213d53f3fbcb1794f9f0369ad (patch)
tree7171dff121c70d0741f1e2104752eeba7e6e2adf
parentf1df20a13536ef8912b787998c072cbd7c513151 (diff)
downloadu-boot-05728722dd9da35213d53f3fbcb1794f9f0369ad.zip
u-boot-05728722dd9da35213d53f3fbcb1794f9f0369ad.tar.gz
u-boot-05728722dd9da35213d53f3fbcb1794f9f0369ad.tar.bz2
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>
-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 69a69c5..023b83e 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,