2
* libfdt - Flat Device Tree manipulation
3
* Testcase for fdt_setprop()
4
* Copyright (C) 2006 David Gibson, IBM Corporation.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public License
8
* as published by the Free Software Foundation; either version 2.1 of
9
* the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33
#define NEW_STRING "here is quite a long test string, blah blah blah"
35
int main(int argc, char *argv[])
43
test_init(argc, argv);
44
fdt = load_blob_arg(argc, argv);
48
err = fdt_open_into(fdt, buf, SPACE);
50
FAIL("fdt_open_into(): %s", fdt_strerror(err));
54
intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
56
verbose_printf("Old int value was 0x%08x\n", *intp);
57
err = fdt_setprop_string(fdt, 0, "prop-int", NEW_STRING);
59
FAIL("Failed to set \"prop-int\" to \"%s\": %s",
60
NEW_STRING, fdt_strerror(err));
62
strp = check_getprop_string(fdt, 0, "prop-int", NEW_STRING);
63
verbose_printf("New value is \"%s\"\n", strp);
65
strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1,
68
verbose_printf("Old string value was \"%s\"\n", strp);
69
err = fdt_setprop_empty(fdt, 0, "prop-str");
71
FAIL("Failed to empty \"prop-str\": %s",
74
check_getprop(fdt, 0, "prop-str", 0, NULL);
76
err = fdt_setprop_u32(fdt, 0, "prop-u32", TEST_VALUE_2);
78
FAIL("Failed to set \"prop-u32\" to 0x%08x: %s",
79
TEST_VALUE_2, fdt_strerror(err));
80
check_getprop_cell(fdt, 0, "prop-u32", TEST_VALUE_2);
82
err = fdt_setprop_cell(fdt, 0, "prop-cell", TEST_VALUE_2);
84
FAIL("Failed to set \"prop-cell\" to 0x%08x: %s",
85
TEST_VALUE_2, fdt_strerror(err));
86
check_getprop_cell(fdt, 0, "prop-cell", TEST_VALUE_2);
88
err = fdt_setprop_u64(fdt, 0, "prop-u64", TEST_VALUE64_1);
90
FAIL("Failed to set \"prop-u64\" to 0x%016llx: %s",
91
TEST_VALUE64_1, fdt_strerror(err));
92
check_getprop_64(fdt, 0, "prop-u64", TEST_VALUE64_1);