diff options
Diffstat (limited to 'test/cmd/fdt.c')
| -rw-r--r-- | test/cmd/fdt.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 96a8488e172..4c3c6308ab4 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -10,6 +10,7 @@ #include <fdt_support.h> #include <mapmem.h> #include <asm/global_data.h> +#include <dm/uclass.h> #include <linux/libfdt.h> #include <test/ut.h> @@ -264,7 +265,7 @@ FDT_TEST(fdt_test_addr_resize, UTF_CONSOLE); static int fdt_test_move(struct unit_test_state *uts) { char fdt[256]; - ulong addr, newaddr = 0x10000; + ulong addr, newaddr; const int size = sizeof(fdt); uint32_t ts; void *buf; @@ -274,8 +275,10 @@ static int fdt_test_move(struct unit_test_state *uts) ts = fdt_totalsize(fdt); /* Moved target DT location */ - buf = map_sysmem(newaddr, size); + buf = memalign(8, size); + ut_assertnonnull(buf); memset(buf, 0, size); + newaddr = map_to_sysmem(buf); /* Test moving the working FDT to a new location */ ut_assertok(run_commandf("fdt move %08lx %08lx %x", addr, newaddr, ts)); @@ -287,6 +290,8 @@ static int fdt_test_move(struct unit_test_state *uts) ut_assert_nextline("Total of %d byte(s) were the same", ts); ut_assert_console_end(); + free(buf); + return 0; } FDT_TEST(fdt_test_move, UTF_CONSOLE); @@ -1267,6 +1272,7 @@ static int fdt_test_chosen(struct unit_test_state *uts) { const char *env_bootargs = env_get("bootargs"); char fdt[8192]; + struct udevice *dev; ulong addr; ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt), &addr)); @@ -1280,11 +1286,16 @@ static int fdt_test_chosen(struct unit_test_state *uts) /* Test add new chosen node without initrd */ ut_assertok(run_commandf("fdt chosen")); ut_assertok(run_commandf("fdt print /chosen")); - ut_assert_nextline("chosen {"); + ut_assert(0 < console_record_readline(uts->actual_str, + sizeof(uts->actual_str))); + if (!strcmp("No RNG device", uts->actual_str)) + ut_assert(0 < console_record_readline(uts->actual_str, + sizeof(uts->actual_str))); + ut_asserteq_str("chosen {", uts->actual_str); ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version string */ if (env_bootargs) ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs); - if (IS_ENABLED(CONFIG_DM_RNG) && + if (!uclass_get_device(UCLASS_RNG, 0, &dev) && !IS_ENABLED(CONFIG_MEASURED_BOOT) && !IS_ENABLED(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT)) ut_assert_nextlinen("\tkaslr-seed = "); @@ -1294,7 +1305,12 @@ static int fdt_test_chosen(struct unit_test_state *uts) /* Test add new chosen node with initrd */ ut_assertok(run_commandf("fdt chosen 0x1234 0x5678")); ut_assertok(run_commandf("fdt print /chosen")); - ut_assert_nextline("chosen {"); + ut_assert(0 < console_record_readline(uts->actual_str, + sizeof(uts->actual_str))); + if (!strcmp("No RNG device", uts->actual_str)) + ut_assert(0 < console_record_readline(uts->actual_str, + sizeof(uts->actual_str))); + ut_asserteq_str("chosen {", uts->actual_str); ut_assert_nextline("\tlinux,initrd-end = <0x%08x 0x%08x>;", upper_32_bits(0x1234 + 0x5678 - 1), lower_32_bits(0x1234 + 0x5678 - 1)); @@ -1303,7 +1319,7 @@ static int fdt_test_chosen(struct unit_test_state *uts) ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version string */ if (env_bootargs) ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs); - if (IS_ENABLED(CONFIG_DM_RNG) && + if (!uclass_get_device(UCLASS_RNG, 0, &dev) && !IS_ENABLED(CONFIG_MEASURED_BOOT) && !IS_ENABLED(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT)) ut_assert_nextlinen("\tkaslr-seed = "); @@ -1319,6 +1335,9 @@ static int fdt_test_apply(struct unit_test_state *uts) char fdt[8192], fdto[8192]; ulong addr, addro; + if (!IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY)) + return -EAGAIN; + /* Create base DT with __symbols__ node */ ut_assertok(fdt_create(fdt, sizeof(fdt))); ut_assertok(fdt_finish_reservemap(fdt)); |
