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