2019-06-21 05:19:41 +08:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
2006-11-27 13:21:28 +08:00
|
|
|
/*
|
|
|
|
* libfdt - Flat Device Tree manipulation
|
|
|
|
* Basic testcase for read-only access
|
|
|
|
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2007-03-23 12:16:54 +08:00
|
|
|
#include <stdint.h>
|
2006-11-27 13:21:28 +08:00
|
|
|
|
|
|
|
#include <libfdt.h>
|
|
|
|
|
|
|
|
#include "tests.h"
|
|
|
|
#include "testdata.h"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2006-12-15 12:12:47 +08:00
|
|
|
void *fdt;
|
2007-11-19 14:26:22 +08:00
|
|
|
const struct fdt_node_header *nh;
|
2006-11-27 13:21:28 +08:00
|
|
|
|
|
|
|
test_init(argc, argv);
|
2006-11-28 14:20:01 +08:00
|
|
|
fdt = load_blob_arg(argc, argv);
|
2007-09-18 09:44:04 +08:00
|
|
|
|
2007-11-19 14:26:22 +08:00
|
|
|
nh = fdt_offset_ptr(fdt, 0, sizeof(*nh));
|
2006-11-27 13:21:28 +08:00
|
|
|
|
|
|
|
if (! nh)
|
|
|
|
FAIL("NULL retrieving root node");
|
|
|
|
|
2006-12-04 09:52:45 +08:00
|
|
|
if (fdt32_to_cpu(nh->tag) != FDT_BEGIN_NODE)
|
2006-11-27 13:21:28 +08:00
|
|
|
FAIL("Wrong tag on root node");
|
|
|
|
|
|
|
|
if (strlen(nh->name) != 0)
|
|
|
|
FAIL("Wrong name for root node, \"%s\" instead of empty",
|
|
|
|
nh->name);
|
|
|
|
|
|
|
|
PASS();
|
|
|
|
}
|