aboutsummaryrefslogtreecommitdiff
path: root/tests/fdt/init.c
blob: c6c35dd4a6470850f2b660d9535b1521093b5220 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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();
}