From e8a7fe3bd5c40168d531a6a4f00a7417a278d58c Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 25 Jan 2026 15:07:04 +0200 Subject: allow reading fdt in tests --- tests/fdt/init.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/fdt/init.c (limited to 'tests/fdt/init.c') diff --git a/tests/fdt/init.c b/tests/fdt/init.c new file mode 100644 index 0000000..c6c35dd --- /dev/null +++ b/tests/fdt/init.c @@ -0,0 +1,29 @@ +#include +#include + +START(pid, tid, d0, d1, d2, d3) +{ + UNUSED(d2); + UNUSED(d3); + + check(pid == 0, "wrong src process ID"); + check(tid == 1, "wrong root thread ID"); + check(d0 == SYS_USER_SPAWNED, "wrong op"); + printf("fdt at %lx\n", d1); + + void *fdt = (void *)d1; + + int chosen_offset = fdt_path_offset(fdt, "/chosen"); + check(chosen_offset > 0, "couldn't find /chosen"); + + const char *stdout = + fdt_getprop(fdt, chosen_offset, "stdout-path", NULL); + + check(stdout != NULL, "couldn't find stdout-path"); + + /* ideally we would also parse the stdout node and check that it is some + * reasonable value, but I'm not sure if we can trust the Qemu fdt to be + * stable. The above is suspicious enough I suppose */ + printf("found stdout at: %s\n", stdout); + ok(); +} -- cgit v1.3