From: Marek Vasut Date: Thu, 2 Mar 2023 03:08:30 +0000 (+0100) Subject: test: cmd: fdt: Test fdt move X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=05728722dd9da35213d53f3fbcb1794f9f0369ad;p=u-boot.git 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 Reviewed-by: Simon Glass --- 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,