aboutsummaryrefslogtreecommitdiff
path: root/tests/fdt/init.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2026-01-25 15:07:04 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2026-01-25 15:07:04 +0200
commite8a7fe3bd5c40168d531a6a4f00a7417a278d58c (patch)
treeddbbead310cd8951ea277eb4e1a13dff7d1a3dd9 /tests/fdt/init.c
parent783e615ca031045eaa979532fc2c2b762ed8593f (diff)
downloadkmi-e8a7fe3bd5c40168d531a6a4f00a7417a278d58c.tar.gz
kmi-e8a7fe3bd5c40168d531a6a4f00a7417a278d58c.zip
allow reading fdt in tests
Diffstat (limited to 'tests/fdt/init.c')
-rw-r--r--tests/fdt/init.c29
1 files changed, 29 insertions, 0 deletions
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 <common/test.h>
+#include <libfdt.h>
+
+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();
+}