1*cc7d2833Sskrll /* $NetBSD: root_node.c,v 1.1.1.3 2019/12/22 12:34:05 skrll Exp $ */
2d89652e2Sskrll
3*cc7d2833Sskrll // SPDX-License-Identifier: LGPL-2.1-or-later
4b8ae3907Smacallan /*
5b8ae3907Smacallan * libfdt - Flat Device Tree manipulation
6b8ae3907Smacallan * Basic testcase for read-only access
7b8ae3907Smacallan * Copyright (C) 2006 David Gibson, IBM Corporation.
8b8ae3907Smacallan */
9b8ae3907Smacallan
10b8ae3907Smacallan #include <stdlib.h>
11b8ae3907Smacallan #include <stdio.h>
12b8ae3907Smacallan #include <string.h>
13b8ae3907Smacallan #include <stdint.h>
14b8ae3907Smacallan
15b8ae3907Smacallan #include <libfdt.h>
16b8ae3907Smacallan
17b8ae3907Smacallan #include "tests.h"
18b8ae3907Smacallan #include "testdata.h"
19b8ae3907Smacallan
main(int argc,char * argv[])20b8ae3907Smacallan int main(int argc, char *argv[])
21b8ae3907Smacallan {
22b8ae3907Smacallan void *fdt;
23b8ae3907Smacallan const struct fdt_node_header *nh;
24b8ae3907Smacallan
25b8ae3907Smacallan test_init(argc, argv);
26b8ae3907Smacallan fdt = load_blob_arg(argc, argv);
27b8ae3907Smacallan
28b8ae3907Smacallan nh = fdt_offset_ptr(fdt, 0, sizeof(*nh));
29b8ae3907Smacallan
30b8ae3907Smacallan if (! nh)
31b8ae3907Smacallan FAIL("NULL retrieving root node");
32b8ae3907Smacallan
33b8ae3907Smacallan if (fdt32_to_cpu(nh->tag) != FDT_BEGIN_NODE)
34b8ae3907Smacallan FAIL("Wrong tag on root node");
35b8ae3907Smacallan
36b8ae3907Smacallan if (strlen(nh->name) != 0)
37b8ae3907Smacallan FAIL("Wrong name for root node, \"%s\" instead of empty",
38b8ae3907Smacallan nh->name);
39b8ae3907Smacallan
40b8ae3907Smacallan PASS();
41b8ae3907Smacallan }
42