1 /* $NetBSD: get_prop_offset.c,v 1.1.1.1 2019/12/22 12:34:06 skrll Exp $ */
2
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 /*
5 * libfdt - Flat Device Tree manipulation
6 * Testcase for fdt_getprop_by_offset()
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
main(int argc,char * argv[])20 int main(int argc, char *argv[])
21 {
22 bool found_prop_int = false;
23 bool found_prop_str = false;
24 int poffset;
25 void *fdt;
26
27 test_init(argc, argv);
28 fdt = load_blob_arg(argc, argv);
29
30 fdt_for_each_property_offset(poffset, fdt, 0) {
31 if (check_get_prop_offset_cell(fdt, poffset, "prop-int",
32 TEST_VALUE_1))
33 found_prop_int = true;
34 if (check_get_prop_offset(fdt, poffset, "prop-str",
35 strlen(TEST_STRING_1) + 1,
36 TEST_STRING_1))
37 found_prop_str = true;
38 }
39 if (!found_prop_int)
40 FAIL("Property 'prop-int' not found");
41 if (!found_prop_str)
42 FAIL("Property 'prop-str' not found");
43
44 PASS();
45 }
46