1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /*
3 * libfdt - Flat Device Tree manipulation
4 * Testcase for fdt_getprop_by_offset()
5 * Copyright (C) 2006 David Gibson, IBM Corporation.
6 */
7
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <stdint.h>
12
13 #include <libfdt.h>
14
15 #include "tests.h"
16 #include "testdata.h"
17
main(int argc,char * argv[])18 int main(int argc, char *argv[])
19 {
20 bool found_prop_int = false;
21 bool found_prop_str = false;
22 int poffset;
23 void *fdt;
24
25 test_init(argc, argv);
26 fdt = load_blob_arg(argc, argv);
27
28 fdt_for_each_property_offset(poffset, fdt, 0) {
29 if (check_get_prop_offset_cell(fdt, poffset, "prop-int",
30 TEST_VALUE_1))
31 found_prop_int = true;
32 if (check_get_prop_offset(fdt, poffset, "prop-str",
33 strlen(TEST_STRING_1) + 1,
34 TEST_STRING_1))
35 found_prop_str = true;
36 }
37 if (!found_prop_int)
38 FAIL("Property 'prop-int' not found");
39 if (!found_prop_str)
40 FAIL("Property 'prop-str' not found");
41
42 PASS();
43 }
44