• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /*
3  * libfdt - Flat Device Tree manipulation
4  *	Testcase for fdt_nop_property()
5  * Copyright (C) 2006 David Gibson, IBM Corporation.
6  */
7 
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <ctype.h>
12 #include <stdint.h>
13 
14 #include <libfdt.h>
15 
16 #include "tests.h"
17 #include "testdata.h"
18 
main(int argc,char * argv[])19 int main(int argc, char *argv[])
20 {
21 	void *fdt;
22 	const uint32_t *intp;
23 	const char *strp;
24 	int err;
25 	int lenerr;
26 
27 	test_init(argc, argv);
28 	fdt = load_blob_arg(argc, argv);
29 
30 	intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
31 	verbose_printf("int value was 0x%08x\n", *intp);
32 
33 	err = fdt_nop_property(fdt, 0, "prop-int");
34 	if (err)
35 		FAIL("Failed to nop \"prop-int\": %s", fdt_strerror(err));
36 
37 	intp = fdt_getprop(fdt, 0, "prop-int", &lenerr);
38 	if (intp)
39 		FAIL("prop-int still present after nopping");
40 	if (lenerr != -FDT_ERR_NOTFOUND)
41 		FAIL("Unexpected error on second getprop: %s", fdt_strerror(err));
42 
43 	strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1,
44 			     TEST_STRING_1);
45 	verbose_printf("string value was \"%s\"\n", strp);
46 	err = fdt_nop_property(fdt, 0, "prop-str");
47 	if (err)
48 		FAIL("Failed to nop \"prop-str\": %s", fdt_strerror(err));
49 
50 	strp = fdt_getprop(fdt, 0, "prop-str", &lenerr);
51 	if (strp)
52 		FAIL("prop-str still present after nopping");
53 	if (lenerr != -FDT_ERR_NOTFOUND)
54 		FAIL("Unexpected error on second getprop: %s", fdt_strerror(err));
55 
56 	PASS();
57 }
58