diff options
author | David Gibson <dgibson@mulberryst.seuss> | 2007-06-14 15:05:55 +1000 |
---|---|---|
committer | David Gibson <dgibson@mulberryst.seuss> | 2007-06-14 15:05:55 +1000 |
commit | 12578976fe9cef82f0c08db3f9a4f550f5085ba4 (patch) | |
tree | cba2b4ddb05edb66e92e171076d0ea476e153e61 /libfdt | |
parent | 400bd98a3a4177c8c399fd1270bf58cba43d1f35 (diff) | |
download | dtc-12578976fe9cef82f0c08db3f9a4f550f5085ba4.zip dtc-12578976fe9cef82f0c08db3f9a4f550f5085ba4.tar.gz dtc-12578976fe9cef82f0c08db3f9a4f550f5085ba4.tar.bz2 |
Merge libfdt into dtc.
Having pulled the libfdt repository into dtc, merge the makefiles and
testsuites so that they build together usefully.
Diffstat (limited to 'libfdt')
-rw-r--r-- | libfdt/.gitignore | 5 | ||||
-rw-r--r-- | libfdt/Makefile | 28 | ||||
-rw-r--r-- | libfdt/tests/.gitignore | 1 | ||||
-rw-r--r-- | libfdt/tests/Makefile | 62 | ||||
-rw-r--r-- | libfdt/tests/del_node.c | 122 | ||||
-rw-r--r-- | libfdt/tests/del_property.c | 89 | ||||
-rw-r--r-- | libfdt/tests/dumptrees.c | 49 | ||||
-rw-r--r-- | libfdt/tests/find_property.c | 42 | ||||
-rw-r--r-- | libfdt/tests/getprop.c | 43 | ||||
-rw-r--r-- | libfdt/tests/move_and_save.c | 76 | ||||
-rw-r--r-- | libfdt/tests/nop_node.c | 105 | ||||
-rw-r--r-- | libfdt/tests/nop_property.c | 71 | ||||
-rw-r--r-- | libfdt/tests/notfound.c | 73 | ||||
-rw-r--r-- | libfdt/tests/open_pack.c | 70 | ||||
-rw-r--r-- | libfdt/tests/path_offset.c | 98 | ||||
-rw-r--r-- | libfdt/tests/root_node.c | 53 | ||||
-rwxr-xr-x | libfdt/tests/run_tests.sh | 94 | ||||
-rw-r--r-- | libfdt/tests/rw_tree1.c | 91 | ||||
-rw-r--r-- | libfdt/tests/setprop.c | 78 | ||||
-rw-r--r-- | libfdt/tests/setprop_inplace.c | 72 | ||||
-rw-r--r-- | libfdt/tests/subnode_offset.c | 83 | ||||
-rw-r--r-- | libfdt/tests/sw_tree1.c | 83 | ||||
-rw-r--r-- | libfdt/tests/testdata.h | 9 | ||||
-rw-r--r-- | libfdt/tests/tests.h | 133 | ||||
-rw-r--r-- | libfdt/tests/testutils.c | 193 | ||||
-rw-r--r-- | libfdt/tests/trees.S | 116 | ||||
-rw-r--r-- | libfdt/tests/truncated_property.c | 49 |
27 files changed, 2 insertions, 1986 deletions
diff --git a/libfdt/.gitignore b/libfdt/.gitignore deleted file mode 100644 index 4b147f1..0000000 --- a/libfdt/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.d -*.o -*.a -*.so -*~ diff --git a/libfdt/Makefile b/libfdt/Makefile index c8240bb..3f68877 100644 --- a/libfdt/Makefile +++ b/libfdt/Makefile @@ -26,35 +26,12 @@ endif DEPFILES = $(LIBOBJS:%.o=%.d) -all: libs tests +all: libs -.PHONY: tests libs +.PHONY: libs libs: $(TARGETLIBS) -tests: tests/all - -tests/%: libs - $(MAKE) -C tests $* - -check: all - cd tests; ./run_tests.sh - -checkv: all - cd tests; ./run_tests.sh -v - -func: all - cd tests; ./run_tests.sh -t func - -funcv: all - cd tests; ./run_tests.sh -t func -v - -stress: all - cd tests; ./run_tests.sh -t stress - -stressv: all - cd tests; ./run_tests.sh -t stress -v - %.o: %.c @$(VECHO) CC $@ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< @@ -74,7 +51,6 @@ libfdt.a: $(LIBOBJS) clean: @$(VECHO) CLEAN rm -f *~ *.o *.so *.a *.d *.i *.s core a.out $(VERSION) - $(MAKE) -C tests clean %.d: %.c @$(CC) $(CPPFLAGS) -MM -MT "$*.o $@" $< > $@ diff --git a/libfdt/tests/.gitignore b/libfdt/tests/.gitignore deleted file mode 100644 index b60ed20..0000000 --- a/libfdt/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.dtb diff --git a/libfdt/tests/Makefile b/libfdt/tests/Makefile deleted file mode 100644 index 533c98e..0000000 --- a/libfdt/tests/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -PREFIX = /usr/local - -LIB_TESTS = root_node find_property subnode_offset path_offset getprop \ - notfound \ - setprop_inplace nop_property nop_node \ - sw_tree1 \ - move_and_save \ - open_pack rw_tree1 setprop del_property del_node -LIBTREE_TESTS = truncated_property -TESTS = $(LIB_TESTS) $(LIBTREE_TESTS) -UTILS = dumptrees - -TREES = test_tree1.dtb - -CFLAGS = -Wall -g -CPPFLAGS = -I.. -LDFLAGS = -L.. - -LIBFDT = ../libfdt.a - -ifdef V -VECHO = : -else -VECHO = echo " " -.SILENT: -endif - -DEPFILES = $(TESTS:%=%.d) testutils.d - -all: $(TESTS) $(TREES) - -%.o: %.c - @$(VECHO) CC $@ - $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< - -%.o: %.S - @$(VECHO) AS $@ - $(CC) -D__ASSEMBLY__ $(CPPFLAGS) -o $@ -c $< - -%: %.o - @$(VECHO) LD $@ - $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) - -$(LIB_TESTS): %: testutils.o $(LIBFDT) - -$(LIBTREE_TESTS): %: testutils.o trees.o $(LIBFDT) - -dumptrees: %: trees.o - -$(TREES): dumptrees - @$(VECHO) DUMPTREES - ./dumptrees >/dev/null - -clean: - @$(VECHO) CLEAN "(tests)" - rm -f *~ *.o *.so *.a *.d *.s core a.out - rm -f $(TESTS) $(UTILS) *.dtb - -%.d: %.c - @$(CC) $(CPPFLAGS) -MM -MT "$*.o $@" $< > $@ - --include $(DEPFILES) diff --git a/libfdt/tests/del_node.c b/libfdt/tests/del_node.c deleted file mode 100644 index 26bb061..0000000 --- a/libfdt/tests/del_node.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_nop_node() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt; - int subnode1_offset, subnode2_offset, subsubnode2_offset; - int err; - int oldsize, delsize, newsize; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - oldsize = fdt_totalsize(fdt); - - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); - if (subnode1_offset < 0) - FAIL("Couldn't find \"/subnode1\": %s", - fdt_strerror(subnode1_offset)); - check_getprop_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1); - - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); - if (subnode2_offset < 0) - FAIL("Couldn't find \"/subnode2\": %s", - fdt_strerror(subnode2_offset)); - check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); - - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); - if (subsubnode2_offset < 0) - FAIL("Couldn't find \"/subnode2/subsubnode\": %s", - fdt_strerror(subsubnode2_offset)); - check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); - - err = fdt_del_node(fdt, subnode1_offset); - if (err) - FAIL("fdt_del_node(subnode1): %s", fdt_strerror(err)); - - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); - if (subnode1_offset != -FDT_ERR_NOTFOUND) - FAIL("fdt_path_offset(subnode1) returned \"%s\" instead of \"%s\"", - fdt_strerror(subnode1_offset), - fdt_strerror(-FDT_ERR_NOTFOUND)); - - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); - if (subnode2_offset < 0) - FAIL("Couldn't find \"/subnode2\": %s", - fdt_strerror(subnode2_offset)); - check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); - - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); - if (subsubnode2_offset < 0) - FAIL("Couldn't find \"/subnode2/subsubnode\": %s", - fdt_strerror(subsubnode2_offset)); - check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); - - err = fdt_del_node(fdt, subnode2_offset); - if (err) - FAIL("fdt_del_node(subnode2): %s", fdt_strerror(err)); - - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); - if (subnode1_offset != -FDT_ERR_NOTFOUND) - FAIL("fdt_path_offset(subnode1) returned \"%s\" instead of \"%s\"", - fdt_strerror(subnode1_offset), - fdt_strerror(-FDT_ERR_NOTFOUND)); - - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); - if (subnode2_offset != -FDT_ERR_NOTFOUND) - FAIL("fdt_path_offset(subnode2) returned \"%s\" instead of \"%s\"", - fdt_strerror(subnode2_offset), - fdt_strerror(-FDT_ERR_NOTFOUND)); - - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); - if (subsubnode2_offset != -FDT_ERR_NOTFOUND) - FAIL("fdt_path_offset(subsubnode2) returned \"%s\" instead of \"%s\"", - fdt_strerror(subsubnode2_offset), - fdt_strerror(-FDT_ERR_NOTFOUND)); - - delsize = fdt_totalsize(fdt); - - err = fdt_pack(fdt); - if (err) - FAIL("fdt_pack(): %s", fdt_strerror(err)); - - newsize = fdt_totalsize(fdt); - - verbose_printf("oldsize = %d, delsize = %d, newsize = %d\n", - oldsize, delsize, newsize); - - if (newsize >= oldsize) - FAIL("Tree failed to shrink after deletions"); - - PASS(); -} diff --git a/libfdt/tests/del_property.c b/libfdt/tests/del_property.c deleted file mode 100644 index 35dc932..0000000 --- a/libfdt/tests/del_property.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_delprop() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt; - const uint32_t *intp; - const char *strp; - int err, lenerr; - int oldsize, delsize, newsize; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - oldsize = fdt_totalsize(fdt); - - intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1); - verbose_printf("int value was 0x%08x\n", *intp); - - err = fdt_delprop(fdt, 0, "prop-int"); - if (err) - FAIL("Failed to delete \"prop-int\": %s", fdt_strerror(err)); - - intp = fdt_getprop(fdt, 0, "prop-int", &lenerr); - if (intp) - FAIL("prop-int still present after deletion"); - if (lenerr != -FDT_ERR_NOTFOUND) - FAIL("Unexpected error on second getprop: %s", - fdt_strerror(lenerr)); - - strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, - TEST_STRING_1); - verbose_printf("string value was \"%s\"\n", strp); - err = fdt_delprop(fdt, 0, "prop-str"); - if (err) - FAIL("Failed to delete \"prop-str\": %s", fdt_strerror(err)); - - strp = fdt_getprop(fdt, 0, "prop-str", &lenerr); - if (strp) - FAIL("prop-str still present after deletion"); - if (lenerr != -FDT_ERR_NOTFOUND) - FAIL("Unexpected error on second getprop: %s", - fdt_strerror(lenerr)); - - delsize = fdt_totalsize(fdt); - - err = fdt_pack(fdt); - if (err) - FAIL("fdt_pack(): %s\n", fdt_strerror(err)); - - newsize = fdt_totalsize(fdt); - - verbose_printf("oldsize = %d, delsize = %d, newsize = %d\n", - oldsize, delsize, newsize); - - if (newsize >= oldsize) - FAIL("Tree failed to shrink after deletions"); - - PASS(); -} diff --git a/libfdt/tests/dumptrees.c b/libfdt/tests/dumptrees.c deleted file mode 100644 index 3db0e2b..0000000 --- a/libfdt/tests/dumptrees.c +++ /dev/null @@ -1,49 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> -#include <libfdt_env.h> - -#include "testdata.h" - -struct { - void *blob; - const char *filename; -} trees[] = { -#define TREE(name) { &_##name, #name ".dtb" } - TREE(test_tree1), -}; - -#define NUM_TREES (sizeof(trees) / sizeof(trees[0])) - -int main(int argc, char *argv[]) -{ - int i; - - for (i = 0; i < NUM_TREES; i++) { - void *blob = trees[i].blob; - const char *filename = trees[i].filename; - int size; - int fd; - int ret; - - size = fdt_totalsize(blob); - - printf("Tree \"%s\", %d bytes\n", filename, size); - - fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); - if (fd < 0) - perror("open()"); - - ret = write(fd, blob, size); - if (ret != size) - perror("write()"); - - close(fd); - } - exit(0); -} diff --git a/libfdt/tests/find_property.c b/libfdt/tests/find_property.c deleted file mode 100644 index ced14ae..0000000 --- a/libfdt/tests/find_property.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_property_offset() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - check_property_typed(fdt, 0, "prop-int", TEST_VALUE_1); - check_property(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, TEST_STRING_1); - - PASS(); -} diff --git a/libfdt/tests/getprop.c b/libfdt/tests/getprop.c deleted file mode 100644 index f124951..0000000 --- a/libfdt/tests/getprop.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_getprop() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1); - check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, TEST_STRING_1); - - PASS(); -} diff --git a/libfdt/tests/move_and_save.c b/libfdt/tests/move_and_save.c deleted file mode 100644 index da73157..0000000 --- a/libfdt/tests/move_and_save.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Basic testcase for read-only access - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <limits.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt, *fdt1, *fdt2, *fdt3; - void *buf; - int shuntsize; - int bufsize; - int err; - const char *inname; - char outname[PATH_MAX]; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - inname = argv[1]; - - shuntsize = ALIGN(fdt_totalsize(fdt) / 2, sizeof(uint64_t)); - bufsize = fdt_totalsize(fdt) + shuntsize; - buf = xmalloc(bufsize); - - fdt1 = buf; - err = fdt_move(fdt, fdt1, bufsize); - if (err) - FAIL("Failed to move tree into new buffer: %s", - fdt_strerror(err)); - sprintf(outname, "moved.%s", inname); - save_blob(outname, fdt1); - - fdt2 = buf + shuntsize; - err = fdt_move(fdt1, fdt2, bufsize-shuntsize); - if (err) - FAIL("Failed to shunt tree %d bytes: %s", - shuntsize, fdt_strerror(err)); - sprintf(outname, "shunted.%s", inname); - save_blob(outname, fdt2); - - fdt3 = buf; - err = fdt_move(fdt2, fdt3, bufsize); - if (err) - FAIL("Failed to deshunt tree %d bytes: %s", - shuntsize, fdt_strerror(err)); - sprintf(outname, "deshunted.%s", inname); - save_blob(outname, fdt3); - - PASS(); -} diff --git a/libfdt/tests/nop_node.c b/libfdt/tests/nop_node.c deleted file mode 100644 index 80cf4d0..0000000 --- a/libfdt/tests/nop_node.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_nop_node() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt; - int subnode1_offset, subnode2_offset, subsubnode2_offset; - int err; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); - if (subnode1_offset < 0) - FAIL("Couldn't find \"/subnode1\": %s", - fdt_strerror(subnode1_offset)); - check_getprop_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1); - - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); - if (subnode2_offset < 0) - FAIL("Couldn't find \"/subnode2\": %s", - fdt_strerror(subnode2_offset)); - check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); - - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); - if (subsubnode2_offset < 0) - FAIL("Couldn't find \"/subnode2/subsubnode\": %s", - fdt_strerror(subsubnode2_offset)); - check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); - - err = fdt_nop_node(fdt, subnode1_offset); - if (err) - FAIL("fdt_nop_node(subnode1): %s", fdt_strerror(err)); - - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); - if (subnode1_offset != -FDT_ERR_NOTFOUND) - FAIL("fdt_path_offset(subnode1) returned \"%s\" instead of \"%s\"", - fdt_strerror(subnode1_offset), - fdt_strerror(-FDT_ERR_NOTFOUND)); - - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); - if (subnode2_offset < 0) - FAIL("Couldn't find \"/subnode2\": %s", - fdt_strerror(subnode2_offset)); - check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); - - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); - if (subsubnode2_offset < 0) - FAIL("Couldn't find \"/subnode2/subsubnode\": %s", - fdt_strerror(subsubnode2_offset)); - check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); - - err = fdt_nop_node(fdt, subnode2_offset); - if (err) - FAIL("fdt_nop_node(subnode2): %s", fdt_strerror(err)); - - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); - if (subnode1_offset != -FDT_ERR_NOTFOUND) - FAIL("fdt_path_offset(subnode1) returned \"%s\" instead of \"%s\"", - fdt_strerror(subnode1_offset), - fdt_strerror(-FDT_ERR_NOTFOUND)); - - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); - if (subnode2_offset != -FDT_ERR_NOTFOUND) - FAIL("fdt_path_offset(subnode2) returned \"%s\" instead of \"%s\"", - fdt_strerror(subnode2_offset), - fdt_strerror(-FDT_ERR_NOTFOUND)); - - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); - if (subsubnode2_offset != -FDT_ERR_NOTFOUND) - FAIL("fdt_path_offset(subsubnode2) returned \"%s\" instead of \"%s\"", - fdt_strerror(subsubnode2_offset), - fdt_strerror(-FDT_ERR_NOTFOUND)); - - PASS(); -} diff --git a/libfdt/tests/nop_property.c b/libfdt/tests/nop_property.c deleted file mode 100644 index 56256c4..0000000 --- a/libfdt/tests/nop_property.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_nop_property() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt; - const uint32_t *intp; - const char *strp; - int err; - int lenerr; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1); - verbose_printf("int value was 0x%08x\n", *intp); - - err = fdt_nop_property(fdt, 0, "prop-int"); - if (err) - FAIL("Failed to nop \"prop-int\": %s", fdt_strerror(err)); - - intp = fdt_getprop(fdt, 0, "prop-int", &lenerr); - if (intp) - FAIL("prop-int still present after nopping"); - if (lenerr != -FDT_ERR_NOTFOUND) - FAIL("Unexpected error on second getprop: %s", fdt_strerror(err)); - - strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, - TEST_STRING_1); - verbose_printf("string value was \"%s\"\n", strp); - err = fdt_nop_property(fdt, 0, "prop-str"); - if (err) - FAIL("Failed to nop \"prop-str\": %s", fdt_strerror(err)); - - strp = fdt_getprop(fdt, 0, "prop-str", &lenerr); - if (strp) - FAIL("prop-str still present after nopping"); - if (lenerr != -FDT_ERR_NOTFOUND) - FAIL("Unexpected error on second getprop: %s", fdt_strerror(err)); - - PASS(); -} diff --git a/libfdt/tests/notfound.c b/libfdt/tests/notfound.c deleted file mode 100644 index a93b605..0000000 --- a/libfdt/tests/notfound.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for behaviour on searching for a non-existent node - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -void check_error(const char *s, int err) -{ - if (err != -FDT_ERR_NOTFOUND) - FAIL("%s return error %s instead of -FDT_ERR_NOTFOUND", s, - fdt_strerror(err)); -} - -int main(int argc, char *argv[]) -{ - const struct fdt_property *prop; - void *fdt; - int offset; - int subnode1_offset; - const void *val; - int lenerr; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - prop = fdt_get_property(fdt, 0, "nonexistant-property", &lenerr); - check_error("fdt_get_property(\"nonexistant-property\")", lenerr); - - val = fdt_getprop(fdt, 0, "nonexistant-property", &lenerr); - check_error("fdt_getprop(\"nonexistant-property\"", lenerr); - - subnode1_offset = fdt_subnode_offset(fdt, 0, "subnode1"); - if (subnode1_offset < 0) - FAIL("Couldn't find subnode1: %s", fdt_strerror(subnode1_offset)); - - val = fdt_getprop(fdt, subnode1_offset, "prop-str", &lenerr); - check_error("fdt_getprop(\"prop-str\")", lenerr); - - offset = fdt_subnode_offset(fdt, 0, "nonexistant-subnode"); - check_error("fdt_subnode_offset(\"nonexistant-subnode\")", offset); - - offset = fdt_subnode_offset(fdt, 0, "subsubnode"); - check_error("fdt_subnode_offset(\"subsubnode\")", offset); - - offset = fdt_path_offset(fdt, "/nonexistant-subnode"); - check_error("fdt_path_offset(\"/nonexistant-subnode\")", offset); - - PASS(); -} diff --git a/libfdt/tests/open_pack.c b/libfdt/tests/open_pack.c deleted file mode 100644 index d614024..0000000 --- a/libfdt/tests/open_pack.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Basic testcase for read-only access - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <limits.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt, *fdt1; - void *buf; - int oldsize, bufsize, packsize; - int err; - const char *inname; - char outname[PATH_MAX]; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - inname = argv[1]; - - oldsize = fdt_totalsize(fdt); - - bufsize = oldsize * 2; - - buf = xmalloc(bufsize); - - fdt1 = buf; - err = fdt_open_into(fdt, fdt1, bufsize); - if (err) - FAIL("fdt_open_into(): %s", fdt_strerror(err)); - sprintf(outname, "opened.%s", inname); - save_blob(outname, fdt1); - - err = fdt_pack(fdt1); - if (err) - FAIL("fdt_pack(): %s", fdt_strerror(err)); - sprintf(outname, "repacked.%s", inname); - save_blob(outname, fdt1); - - packsize = fdt_totalsize(fdt1); - - verbose_printf("oldsize = %d, bufsize = %d, packsize = %d\n", - oldsize, bufsize, packsize); - PASS(); -} diff --git a/libfdt/tests/path_offset.c b/libfdt/tests/path_offset.c deleted file mode 100644 index 05b0c32..0000000 --- a/libfdt/tests/path_offset.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_path_offset() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int check_subnode(void *fdt, int parent, const char *name) -{ - int offset; - struct fdt_node_header *nh; - uint32_t tag; - - verbose_printf("Checking subnode \"%s\" of %d...", name, parent); - offset = fdt_subnode_offset(fdt, parent, name); - verbose_printf("offset %d...", offset); - if (offset < 0) - FAIL("fdt_subnode_offset(\"%s\"): %s", name, fdt_strerror(offset)); - nh = fdt_offset_ptr_typed(fdt, offset, nh); - verbose_printf("pointer %p\n", nh); - if (! nh) - FAIL("NULL retrieving subnode \"%s\"", name); - - tag = fdt32_to_cpu(nh->tag); - - if (tag != FDT_BEGIN_NODE) - FAIL("Incorrect tag 0x%08x on property \"%s\"", tag, name); - if (!streq(nh->name, name)) - FAIL("Subnode name mismatch \"%s\" instead of \"%s\"", - nh->name, name); - - return offset; -} - -int main(int argc, char *argv[]) -{ - void *fdt; - int subnode1_offset, subnode2_offset; - int subnode1_offset_p, subnode2_offset_p; - int subsubnode1_offset, subsubnode2_offset; - int subsubnode1_offset_p, subsubnode2_offset_p; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - subnode1_offset = check_subnode(fdt, 0, "subnode1"); - subnode2_offset = check_subnode(fdt, 0, "subnode2"); - - subnode1_offset_p = fdt_path_offset(fdt, "/subnode1"); - subnode2_offset_p = fdt_path_offset(fdt, "/subnode2"); - - if (subnode1_offset != subnode1_offset_p) - FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)", - subnode1_offset, subnode1_offset_p); - - if (subnode2_offset != subnode2_offset_p) - FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)", - subnode2_offset, subnode2_offset_p); - - subsubnode1_offset = check_subnode(fdt, subnode1_offset, "subsubnode"); - subsubnode2_offset = check_subnode(fdt, subnode2_offset, "subsubnode"); - - subsubnode1_offset_p = fdt_path_offset(fdt, "/subnode1/subsubnode"); - subsubnode2_offset_p = fdt_path_offset(fdt, "/subnode2/subsubnode"); - - if (subsubnode1_offset != subsubnode1_offset_p) - FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)", - subsubnode1_offset, subsubnode1_offset_p); - - if (subsubnode2_offset != subsubnode2_offset_p) - FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)", - subsubnode2_offset, subsubnode2_offset_p); - - PASS(); -} diff --git a/libfdt/tests/root_node.c b/libfdt/tests/root_node.c deleted file mode 100644 index 6e2c391..0000000 --- a/libfdt/tests/root_node.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Basic testcase for read-only access - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt; - struct fdt_node_header *nh; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - nh = fdt_offset_ptr_typed(fdt, 0, nh); - - if (! nh) - FAIL("NULL retrieving root node"); - - if (fdt32_to_cpu(nh->tag) != FDT_BEGIN_NODE) - FAIL("Wrong tag on root node"); - - if (strlen(nh->name) != 0) - FAIL("Wrong name for root node, \"%s\" instead of empty", - nh->name); - - PASS(); -} diff --git a/libfdt/tests/run_tests.sh b/libfdt/tests/run_tests.sh deleted file mode 100755 index f4a5a54..0000000 --- a/libfdt/tests/run_tests.sh +++ /dev/null @@ -1,94 +0,0 @@ -#! /bin/bash - -export QUIET_TEST=1 - -ENV=/usr/bin/env - -run_test () { - echo -n "$@: " - PATH=".:$PATH" $ENV "$@" -} - -tree1_tests () { - TREE=$1 - - # Read-only tests - run_test root_node $TREE - run_test find_property $TREE - run_test subnode_offset $TREE - run_test path_offset $TREE - run_test getprop $TREE - run_test notfound $TREE - - # Write-in-place tests - run_test setprop_inplace $TREE - run_test nop_property $TREE - run_test nop_node $TREE -} - -functional_tests () { - # Make sure we don't have stale blobs lying around - rm -f *.test.dtb - - tree1_tests test_tree1.dtb - - # Sequential write tests - run_test sw_tree1 - tree1_tests sw_tree1.test.dtb - tree1_tests unfinished_tree1.test.dtb - - # fdt_move tests - for tree in test_tree1.dtb sw_tree1.test.dtb unfinished_tree1.test.dtb; do - rm -f moved.$tree shunted.$tree deshunted.$tree - run_test move_and_save $tree - tree1_tests moved.$tree - tree1_tests shunted.$tree - tree1_tests deshunted.$tree - done - - # Read-write tests - for tree in test_tree1.dtb sw_tree1.test.dtb; do - rm -f opened.$tree repacked.$tree - run_test open_pack $tree - tree1_tests opened.$tree - tree1_tests repacked.$tree - done - run_test setprop test_tree1.dtb - run_test del_property test_tree1.dtb - run_test del_node test_tree1.dtb - run_test rw_tree1 - tree1_tests rw_tree1.test.dtb - - # Tests for behaviour on various sorts of corrupted trees - run_test truncated_property -} - -stress_tests () { - ITERATIONS=10 # Number of iterations for looping tests -} - -while getopts "vdt:" ARG ; do - case $ARG in - "v") - unset QUIET_TEST - ;; - "t") - TESTSETS=$OPTARG - ;; - esac -done - -if [ -z "$TESTSETS" ]; then - TESTSETS="func stress" -fi - -for set in $TESTSETS; do - case $set in - "func") - functional_tests - ;; - "stress") - stress_tests - ;; - esac -done diff --git a/libfdt/tests/rw_tree1.c b/libfdt/tests/rw_tree1.c deleted file mode 100644 index 3fb9307..0000000 --- a/libfdt/tests/rw_tree1.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_nop_node() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -#define SPACE 65536 - -#define CHECK(code) \ - { \ - err = (code); \ - if (err) \ - FAIL(#code ": %s", fdt_strerror(err)); \ - } - -#define OFF_CHECK(off, code) \ - { \ - (off) = (code); \ - if (off < 0) \ - FAIL(#code ": %s", fdt_strerror(off)); \ - } - -int main(int argc, char *argv[]) -{ - void *fdt; - int err; - int offset; - - test_init(argc, argv); - - fdt = xmalloc(SPACE); - - /* First create empty tree with SW */ - CHECK(fdt_create(fdt, SPACE)); - - CHECK(fdt_finish_reservemap(fdt)); - CHECK(fdt_begin_node(fdt, "")); - CHECK(fdt_end_node(fdt)); - CHECK(fdt_finish(fdt)); - - verbose_printf("Built empty tree, totalsize = %d\n", - fdt_totalsize(fdt)); - - CHECK(fdt_open_into(fdt, fdt, SPACE)); - - CHECK(fdt_setprop_typed(fdt, 0, "prop-int", TEST_VALUE_1)); - CHECK(fdt_setprop_string(fdt, 0, "prop-str", TEST_STRING_1)); - - OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode1")); - CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1)); - OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode")); - CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1)); - - OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode2")); - CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2)); - OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode")); - - CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2)); - - CHECK(fdt_pack(fdt)); - - save_blob("rw_tree1.test.dtb", fdt); - - PASS(); -} diff --git a/libfdt/tests/setprop.c b/libfdt/tests/setprop.c deleted file mode 100644 index 7f9be3e..0000000 --- a/libfdt/tests/setprop.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_setprop() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -#define SPACE 65536 -#define NEW_STRING "here is quite a long test string, blah blah blah" - -int main(int argc, char *argv[]) -{ - void *fdt; - void *buf; - const uint32_t *intp; - const char *strp; - int err; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - buf = xmalloc(SPACE); - - err = fdt_open_into(fdt, buf, SPACE); - if (err) - FAIL("fdt_open_into(): %s", fdt_strerror(err)); - - fdt = buf; - - intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1); - - verbose_printf("Old int value was 0x%08x\n", *intp); - err = fdt_setprop_string(fdt, 0, "prop-int", NEW_STRING); - if (err) - FAIL("Failed to set \"prop-int\" to \"%s\": %s", - NEW_STRING, fdt_strerror(err)); - - strp = check_getprop_string(fdt, 0, "prop-int", NEW_STRING); - verbose_printf("New value is \"%s\"\n", strp); - - strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, - TEST_STRING_1); - - verbose_printf("Old string value was \"%s\"\n", strp); - err = fdt_setprop(fdt, 0, "prop-str", NULL, 0); - if (err) - FAIL("Failed to empty \"prop-str\": %s", - fdt_strerror(err)); - - check_getprop(fdt, 0, "prop-str", 0, NULL); - - PASS(); -} diff --git a/libfdt/tests/setprop_inplace.c b/libfdt/tests/setprop_inplace.c deleted file mode 100644 index 59c1209..0000000 --- a/libfdt/tests/setprop_inplace.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_setprop_inplace() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt; - const uint32_t *intp; - const char *strp; - char *xstr; - int xlen, i; - int err; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1); - - verbose_printf("Old int value was 0x%08x\n", *intp); - err = fdt_setprop_inplace_typed(fdt, 0, "prop-int", ~TEST_VALUE_1); - if (err) - FAIL("Failed to set \"prop-int\" to 0x08%x: %s", - ~TEST_VALUE_1, fdt_strerror(err)); - intp = check_getprop_typed(fdt, 0, "prop-int", ~TEST_VALUE_1); - verbose_printf("New int value is 0x%08x\n", *intp); - - strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, - TEST_STRING_1); - - verbose_printf("Old string value was \"%s\"\n", strp); - xstr = strdup(strp); - xlen = strlen(xstr); - for (i = 0; i < xlen; i++) - xstr[i] = toupper(xstr[i]); - err = fdt_setprop_inplace(fdt, 0, "prop-str", xstr, xlen+1); - if (err) - FAIL("Failed to set \"prop-str\" to \"%s\": %s", - xstr, fdt_strerror(err)); - - strp = check_getprop(fdt, 0, "prop-str", xlen+1, xstr); - verbose_printf("New string value is \"%s\"\n", strp); - - PASS(); -} diff --git a/libfdt/tests/subnode_offset.c b/libfdt/tests/subnode_offset.c deleted file mode 100644 index d4edfe4..0000000 --- a/libfdt/tests/subnode_offset.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_subnode_offset() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int check_subnode(struct fdt_header *fdt, int parent, const char *name) -{ - int offset; - struct fdt_node_header *nh; - uint32_t tag; - - verbose_printf("Checking subnode \"%s\" of %d...", name, parent); - offset = fdt_subnode_offset(fdt, parent, name); - verbose_printf("offset %d...", offset); - if (offset < 0) - FAIL("fdt_subnode_offset(\"%s\"): %s", name, fdt_strerror(offset)); - nh = fdt_offset_ptr_typed(fdt, offset, nh); - verbose_printf("pointer %p\n", nh); - if (! nh) - FAIL("NULL retrieving subnode \"%s\"", name); - - tag = fdt32_to_cpu(nh->tag); - - if (tag != FDT_BEGIN_NODE) - FAIL("Incorrect tag 0x%08x on property \"%s\"", tag, name); - if (!streq(nh->name, name)) - FAIL("Subnode name mismatch \"%s\" instead of \"%s\"", - nh->name, name); - - return offset; -} - -int main(int argc, char *argv[]) -{ - void *fdt; - int subnode1_offset, subnode2_offset; - int subsubnode1_offset, subsubnode2_offset; - - test_init(argc, argv); - fdt = load_blob_arg(argc, argv); - - subnode1_offset = check_subnode(fdt, 0, "subnode1"); - subnode2_offset = check_subnode(fdt, 0, "subnode2"); - - if (subnode1_offset == subnode2_offset) - FAIL("Different subnodes have same offset"); - - check_property_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1); - check_property_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); - - subsubnode1_offset = check_subnode(fdt, subnode1_offset, "subsubnode"); - subsubnode2_offset = check_subnode(fdt, subnode2_offset, "subsubnode"); - - check_property_typed(fdt, subsubnode1_offset, "prop-int", TEST_VALUE_1); - check_property_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); - - PASS(); -} diff --git a/libfdt/tests/sw_tree1.c b/libfdt/tests/sw_tree1.c deleted file mode 100644 index 7b54359..0000000 --- a/libfdt/tests/sw_tree1.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for fdt_nop_node() - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -#define SPACE 65536 - -#define CHECK(code) \ - { \ - err = (code); \ - if (err) \ - FAIL(#code ": %s", fdt_strerror(err)); \ - } - -int main(int argc, char *argv[]) -{ - void *fdt; - int err; - - test_init(argc, argv); - - fdt = xmalloc(SPACE); - CHECK(fdt_create(fdt, SPACE)); - - CHECK(fdt_finish_reservemap(fdt)); - CHECK(fdt_begin_node(fdt, "")); - CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1)); - CHECK(fdt_property_string(fdt, "prop-str", TEST_STRING_1)); - - CHECK(fdt_begin_node(fdt, "subnode1")); - CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1)); - CHECK(fdt_begin_node(fdt, "subsubnode")); - CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1)); - CHECK(fdt_end_node(fdt)); - CHECK(fdt_end_node(fdt)); - - CHECK(fdt_begin_node(fdt, "subnode2")); - CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_2)); - CHECK(fdt_begin_node(fdt, "subsubnode")); - CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_2)); - CHECK(fdt_end_node(fdt)); - CHECK(fdt_end_node(fdt)); - - CHECK(fdt_end_node(fdt)); - - save_blob("unfinished_tree1.test.dtb", fdt); - - CHECK(fdt_finish(fdt)); - - verbose_printf("Completed tree, totalsize = %d\n", - fdt_totalsize(fdt)); - - save_blob("sw_tree1.test.dtb", fdt); - - PASS(); -} diff --git a/libfdt/tests/testdata.h b/libfdt/tests/testdata.h deleted file mode 100644 index 822c69a..0000000 --- a/libfdt/tests/testdata.h +++ /dev/null @@ -1,9 +0,0 @@ -#define TEST_VALUE_1 0xdeadbeef -#define TEST_VALUE_2 0xabcd1234 - -#define TEST_STRING_1 "hello world" - -#ifndef __ASSEMBLY__ -extern struct fdt_header _test_tree1; -extern struct fdt_header _truncated_property; -#endif /* ! __ASSEMBLY */ diff --git a/libfdt/tests/tests.h b/libfdt/tests/tests.h deleted file mode 100644 index ace7ba3..0000000 --- a/libfdt/tests/tests.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef _TESTS_H -#define _TESTS_H -/* - * libfdt - Flat Device Tree manipulation - * Testcase definitions - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#define DEBUG - -/* Test return codes */ -#define RC_PASS 0 -#define RC_CONFIG 1 -#define RC_FAIL 2 -#define RC_BUG 99 - -extern int verbose_test; -extern char *test_name; -void test_init(int argc, char *argv[]); - -#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) -#define PALIGN(p, a) ((void *)ALIGN((unsigned long)(p), (a))) - -#define streq(s1, s2) (strcmp((s1),(s2)) == 0) - -/* Each test case must define this function */ -void cleanup(void); - -#define verbose_printf(...) \ - if (verbose_test) { \ - printf(__VA_ARGS__); \ - fflush(stdout); \ - } -#define ERR "ERR: " -#define ERROR(fmt, args...) fprintf(stderr, ERR fmt, ## args) - - -#define PASS() \ - do { \ - cleanup(); \ - printf("PASS\n"); \ - exit(RC_PASS); \ - } while (0) - -#define PASS_INCONCLUSIVE() \ - do { \ - cleanup(); \ - printf("PASS (inconclusive)\n"); \ - exit(RC_PASS); \ - } while (0) - -#define IRRELEVANT() \ - do { \ - cleanup(); \ - printf("PASS (irrelevant)\n"); \ - exit(RC_PASS); \ - } while (0) - -/* Look out, gcc extension below... */ -#define FAIL(fmt, ...) \ - do { \ - cleanup(); \ - printf("FAIL\t" fmt "\n", ##__VA_ARGS__); \ - exit(RC_FAIL); \ - } while (0) - -#define CONFIG(fmt, ...) \ - do { \ - cleanup(); \ - printf("Bad configuration: " fmt "\n", ##__VA_ARGS__); \ - exit(RC_CONFIG); \ - } while (0) - -#define TEST_BUG(fmt, ...) \ - do { \ - cleanup(); \ - printf("BUG in testsuite: " fmt "\n", ##__VA_ARGS__); \ - exit(RC_BUG); \ - } while (0) - -static inline void *xmalloc(size_t size) -{ - void *p = malloc(size); - if (! p) - FAIL("malloc() failure"); - return p; -} - -static inline void *xrealloc(void *p, size_t size) -{ - p = realloc(p, size); - if (! p) - FAIL("realloc() failure"); - return p; -} - -void check_property(void *fdt, int nodeoffset, const char *name, - int len, const void *val); -#define check_property_typed(fdt, nodeoffset, name, val) \ - ({ \ - typeof(val) x = val; \ - check_property(fdt, nodeoffset, name, sizeof(x), &x); \ - }) - - -const void *check_getprop(void *fdt, int nodeoffset, const char *name, - int len, const void *val); -#define check_getprop_typed(fdt, nodeoffset, name, val) \ - ({ \ - typeof(val) x = val; \ - check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \ - }) -#define check_getprop_string(fdt, nodeoffset, name, s) \ - check_getprop((fdt), (nodeoffset), (name), strlen(s)+1, (s)) -//void *load_blob(const char *filename); -void *load_blob_arg(int argc, char *argv[]); -void save_blob(const char *filename, void *blob); - -#endif /* _TESTS_H */ diff --git a/libfdt/tests/testutils.c b/libfdt/tests/testutils.c deleted file mode 100644 index fcb1c88..0000000 --- a/libfdt/tests/testutils.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase common utility functions - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#define _GNU_SOURCE /* for strsignal() */ - -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <limits.h> -#include <string.h> -#include <errno.h> -#include <signal.h> -#include <unistd.h> -#include <fcntl.h> - -#include <libfdt.h> - -#include "tests.h" - -int verbose_test = 1; -char *test_name; - -void __attribute__((weak)) cleanup(void) -{ -} - -static void sigint_handler(int signum, siginfo_t *si, void *uc) -{ - cleanup(); - fprintf(stderr, "%s: %s (pid=%d)\n", test_name, - strsignal(signum), getpid()); - exit(RC_BUG); -} - -void test_init(int argc, char *argv[]) -{ - int err; - struct sigaction sa_int = { - .sa_sigaction = sigint_handler, - }; - - test_name = argv[0]; - - err = sigaction(SIGINT, &sa_int, NULL); - if (err) - FAIL("Can't install SIGINT handler"); - - if (getenv("QUIET_TEST")) - verbose_test = 0; - - verbose_printf("Starting testcase \"%s\", pid %d\n", - test_name, getpid()); -} - -void check_property(void *fdt, int nodeoffset, const char *name, - int len, const void *val) -{ - const struct fdt_property *prop; - int retlen; - uint32_t tag, nameoff, proplen; - const char *propname; - - verbose_printf("Checking property \"%s\"...", name); - prop = fdt_get_property(fdt, nodeoffset, name, &retlen); - verbose_printf("pointer %p\n", prop); - if (! prop) - FAIL("Error retreiving \"%s\" pointer: %s", name, - fdt_strerror(retlen)); - - tag = fdt32_to_cpu(prop->tag); - nameoff = fdt32_to_cpu(prop->nameoff); - proplen = fdt32_to_cpu(prop->len); - - if (tag != FDT_PROP) - FAIL("Incorrect tag 0x%08x on property \"%s\"", tag, name); - - propname = fdt_string(fdt, nameoff); - if (!propname || !streq(propname, name)) - FAIL("Property name mismatch \"%s\" instead of \"%s\"", - propname, name); - if (proplen != retlen) - FAIL("Length retrieved for \"%s\" by fdt_get_property()" - " differs from stored length (%d != %d)", - name, retlen, proplen); - if (proplen != len) - FAIL("Size mismatch on property \"%s\": %d insead of %d", - name, proplen, len); - if (memcmp(val, prop->data, len) != 0) - FAIL("Data mismatch on property \"%s\"", name); - -} - -const void *check_getprop(void *fdt, int nodeoffset, const char *name, - int len, const void *val) -{ - const void *propval; - int proplen; - - propval = fdt_getprop(fdt, nodeoffset, name, &proplen); - if (! propval) - FAIL("fdt_getprop(\"%s\"): %s", name, fdt_strerror(proplen)); - - if (proplen != len) - FAIL("Size mismatch on property \"%s\": %d insead of %d", - name, proplen, len); - if (memcmp(val, propval, len) != 0) - FAIL("Data mismatch on property \"%s\"", name); - - return propval; -} - -#define CHUNKSIZE 128 - -void *load_blob(const char *filename) -{ - int fd; - int offset = 0; - int bufsize = 1024; - char *p = NULL; - int ret; - - fd = open(filename, O_RDONLY); - if (fd < 0) - CONFIG("Couldn't open blob from \"%s\": %s", filename, - strerror(errno)); - - p = xmalloc(bufsize); - do { - if (offset == bufsize) { - bufsize *= 2; - p = xrealloc(p, bufsize); - } - - ret = read(fd, &p[offset], bufsize - offset); - if (ret < 0) - CONFIG("Couldn't read from \"%s\": %s", filename, - strerror(errno)); - - offset += ret; - } while (ret != 0); - - return p; -} - -void *load_blob_arg(int argc, char *argv[]) -{ - if (argc != 2) - CONFIG("Usage: %s <dtb file>", argv[0]); - return load_blob(argv[1]); -} - -void save_blob(const char *filename, void *fdt) -{ - int fd; - int totalsize; - int offset; - void *p; - int ret; - - fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); - if (fd < 0) - CONFIG("Couldn't open \"%s\" to write blob: %s", filename, - strerror(errno)); - - totalsize = fdt_totalsize(fdt); - offset = 0; - p = fdt; - - while (offset < totalsize) { - ret = write(fd, p + offset, totalsize - offset); - if (ret < 0) - CONFIG("Couldn't write to \"%s\": %s", filename, - strerror(errno)); - offset += ret; - } -} diff --git a/libfdt/tests/trees.S b/libfdt/tests/trees.S deleted file mode 100644 index 6057668..0000000 --- a/libfdt/tests/trees.S +++ /dev/null @@ -1,116 +0,0 @@ -#include <fdt.h> -#include "testdata.h" - -#define FDTLONG(val) \ - .byte ((val) >> 24) & 0xff ; \ - .byte ((val) >> 16) & 0xff ; \ - .byte ((val) >> 8) & 0xff ; \ - .byte (val) & 0xff - -#define FDTQUAD(val) \ - .byte ((val) >> 56) & 0xff ; \ - .byte ((val) >> 48) & 0xff ; \ - .byte ((val) >> 40) & 0xff ; \ - .byte ((val) >> 32) & 0xff ; \ - .byte ((val) >> 24) & 0xff ; \ - .byte ((val) >> 16) & 0xff ; \ - .byte ((val) >> 8) & 0xff ; \ - .byte (val) & 0xff - -#define TREE_HDR(tree) \ - .balign 4 ; \ - .globl _##tree ; \ -_##tree: \ -tree: \ - FDTLONG(FDT_MAGIC) ; \ - FDTLONG(tree##_end - tree) ; \ - FDTLONG(tree##_struct - tree) ; \ - FDTLONG(tree##_strings - tree) ; \ - FDTLONG(tree##_rsvmap - tree) ; \ - FDTLONG(0x11) ; \ - FDTLONG(0x10) ; \ - FDTLONG(0) ; \ - FDTLONG(tree##_end - tree##_strings) ; \ - FDTLONG(tree##_strings - tree##_struct) ; - -#define RSVMAP_ENTRY(addr, len) \ - FDTQUAD(addr) ; \ - FDTQUAD(len) ; - -#define PROPHDR(tree, name, len) \ - FDTLONG(FDT_PROP) ; \ - FDTLONG(len) ; \ - FDTLONG(tree##_##name - tree##_strings) ; - -#define PROP_INT(tree, name, val) \ - PROPHDR(tree, name, 4) \ - /* For ease of testing the property values go in native-endian */ \ - .long val - -#define PROP_STR(tree, name, str) \ - PROPHDR(tree, name, 55f - 54f) \ -54: \ - .string str ; \ -55: \ - .balign 4 - -#define BEGIN_NODE(name) \ - FDTLONG(FDT_BEGIN_NODE) ; \ - .string name ; \ - .balign 4 - -#define END_NODE \ - FDTLONG(FDT_END_NODE) ; - -#define STRING(tree, name, str) \ -tree##_##name: \ - .string str - - .data - - TREE_HDR(test_tree1) - -test_tree1_rsvmap: - RSVMAP_ENTRY(0, 0) - -test_tree1_struct: - BEGIN_NODE("") - PROP_INT(test_tree1, prop_int, TEST_VALUE_1) - PROP_STR(test_tree1, prop_str, TEST_STRING_1) - - BEGIN_NODE("subnode1") - PROP_INT(test_tree1, prop_int, TEST_VALUE_1) - - BEGIN_NODE("subsubnode") - PROP_INT(test_tree1, prop_int, TEST_VALUE_1) - END_NODE - END_NODE - - BEGIN_NODE("subnode2") - PROP_INT(test_tree1, prop_int, TEST_VALUE_2) - - BEGIN_NODE("subsubnode") - PROP_INT(test_tree1, prop_int, TEST_VALUE_2) - END_NODE - END_NODE - - END_NODE - FDTLONG(FDT_END) - -test_tree1_strings: - STRING(test_tree1, prop_int, "prop-int") - STRING(test_tree1, prop_str, "prop-str") -test_tree1_end: - - TREE_HDR(truncated_property) -truncated_property_rsvmap: - RSVMAP_ENTRY(0, 0) - -truncated_property_struct: - BEGIN_NODE("") - PROPHDR(truncated_property, prop_truncated, 4) - /* Oops, no actual property data here */ - -truncated_property_strings: - STRING(truncated_property, prop_truncated, "truncated") -truncated_property_end: diff --git a/libfdt/tests/truncated_property.c b/libfdt/tests/truncated_property.c deleted file mode 100644 index 5642d8d..0000000 --- a/libfdt/tests/truncated_property.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * libfdt - Flat Device Tree manipulation - * Testcase for misbehaviour on a truncated property - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <stdint.h> - -#include <fdt.h> -#include <libfdt.h> - -#include "tests.h" -#include "testdata.h" - -int main(int argc, char *argv[]) -{ - void *fdt = &_truncated_property; - const void *prop; - int err; - int len; - - test_init(argc, argv); - - prop = fdt_getprop(fdt, 0, "truncated", &len); - if (prop) - FAIL("fdt_getprop() succeeded on truncated property"); - if (len != -FDT_ERR_BADSTRUCTURE) - FAIL("fdt_getprop() failed with \"%s\" instead of \"%s\"", - fdt_strerror(err), fdt_strerror(-FDT_ERR_BADSTRUCTURE)); - - PASS(); -} |