aboutsummaryrefslogtreecommitdiff
path: root/test/cmd
diff options
context:
space:
mode:
authorMarek Vasut2023-03-02 04:08:40 +0100
committerSimon Glass2023-03-08 13:15:13 -0800
commit26281517c654f6272868e2c6c60d9aab7fd985a7 (patch)
tree58c3e1b8a4d512c5ff1c9ffdd4748435dc2d976e /test/cmd
parente46a438c5920c21833ac3bf4c2d4d9cc7736ea1a (diff)
test: cmd: fdt: Test fdt bootcpu
Add 'fdt bootcpu' test which works as follows: - Create basic FDT, map it to sysmem - Print the FDT bootcpu - Set the FDT bootcpu and read the value back using 'fdt header get' - Perform the previous step twice to validate bootcpu overwrite 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/cmd')
-rw-r--r--test/cmd/fdt.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index cb86fc02a7f..cdbaf8c4250 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -931,6 +931,39 @@ static int fdt_test_rm(struct unit_test_state *uts)
}
FDT_TEST(fdt_test_rm, UT_TESTF_CONSOLE_REC);
+static int fdt_test_bootcpu(struct unit_test_state *uts)
+{
+ char fdt[256];
+ ulong addr;
+ int i;
+
+ ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+ addr = map_to_sysmem(fdt);
+ set_working_fdt_addr(addr);
+
+ /* Test getting default bootcpu entry */
+ ut_assertok(console_record_reset_enable());
+ ut_assertok(run_commandf("fdt header get bootcpu boot_cpuid_phys"));
+ ut_asserteq(0, env_get_ulong("bootcpu", 10, 0x1234));
+ ut_assertok(ut_check_console_end(uts));
+
+ /* Test setting and getting new bootcpu entry, twice, to test overwrite */
+ for (i = 42; i <= 43; i++) {
+ ut_assertok(console_record_reset_enable());
+ ut_assertok(run_commandf("fdt bootcpu %d", i));
+ ut_assertok(ut_check_console_end(uts));
+
+ /* Test getting new bootcpu entry */
+ ut_assertok(console_record_reset_enable());
+ ut_assertok(run_commandf("fdt header get bootcpu boot_cpuid_phys"));
+ ut_asserteq(i, env_get_ulong("bootcpu", 10, 0x1234));
+ ut_assertok(ut_check_console_end(uts));
+ }
+
+ return 0;
+}
+FDT_TEST(fdt_test_bootcpu, UT_TESTF_CONSOLE_REC);
+
int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);