2 * libfdt - Flat Device Tree manipulation
3 * Testcase for fdt_setprop_inplace()
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 int main(int argc, char *argv[])
37 const uint64_t *int64p;
43 test_init(argc, argv);
44 fdt = load_blob_arg(argc, argv);
46 intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
48 verbose_printf("Old int value was 0x%08x\n", *intp);
49 err = fdt_setprop_inplace_cell(fdt, 0, "prop-int", ~TEST_VALUE_1);
51 FAIL("Failed to set \"prop-int\" to 0x%08x: %s",
52 ~TEST_VALUE_1, fdt_strerror(err));
53 intp = check_getprop_cell(fdt, 0, "prop-int", ~TEST_VALUE_1);
54 verbose_printf("New int value is 0x%08x\n", *intp);
56 strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1,
60 int64p = check_getprop_64(fdt, 0, "prop-int64", TEST_VALUE64_1);
62 verbose_printf("Old int64 value was 0x%016" PRIx64 "\n", *int64p);
63 err = fdt_setprop_inplace_u64(fdt, 0, "prop-int64", ~TEST_VALUE64_1);
65 FAIL("Failed to set \"prop-int64\" to 0x%016llx: %s",
66 ~TEST_VALUE64_1, fdt_strerror(err));
67 int64p = check_getprop_64(fdt, 0, "prop-int64", ~TEST_VALUE64_1);
68 verbose_printf("New int64 value is 0x%016" PRIx64 "\n", *int64p);
70 strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1,
73 verbose_printf("Old string value was \"%s\"\n", strp);
76 for (i = 0; i < xlen; i++)
77 xstr[i] = toupper(xstr[i]);
78 err = fdt_setprop_inplace(fdt, 0, "prop-str", xstr, xlen+1);
80 FAIL("Failed to set \"prop-str\" to \"%s\": %s",
81 xstr, fdt_strerror(err));
83 strp = check_getprop(fdt, 0, "prop-str", xlen+1, xstr);
84 verbose_printf("New string value is \"%s\"\n", strp);