diff options
author | Warner Losh <imp@FreeBSD.org> | 2014-01-27 06:20:36 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2014-01-27 06:20:36 +0000 |
commit | 939bdb9f6a0dad490702c3009bb8714579e1e765 (patch) | |
tree | 4405597d1484d0e28336fa7f4f113d502f37469f /tests | |
parent | ab1c86b34d2455fbd8cf2a9a404b0d7fd4ad28b1 (diff) | |
download | src-939bdb9f6a0dad490702c3009bb8714579e1e765.tar.gz src-939bdb9f6a0dad490702c3009bb8714579e1e765.zip |
Import dtc git at 6a15eb2350426d285130e4c9d84c0bdb6575547a (last rev before bison became required)
Notes
Notes:
svn path=/vendor/dtc/dist/; revision=261202
Diffstat (limited to 'tests')
73 files changed, 233 insertions, 107 deletions
diff --git a/tests/Makefile.tests b/tests/Makefile.tests index 179546683619..dafb61848744 100644 --- a/tests/Makefile.tests +++ b/tests/Makefile.tests @@ -12,7 +12,7 @@ LIB_TESTS_L = get_mem_rsv \ sw_tree1 \ move_and_save mangle-layout nopulate \ open_pack rw_tree1 set_name setprop del_property del_node \ - appendprop1 appendprop2 \ + appendprop1 appendprop2 propname_escapes \ string_escapes references path-references phandle_format \ boot-cpuid incbin \ extra-terminating-null \ @@ -20,7 +20,8 @@ LIB_TESTS_L = get_mem_rsv \ dtb_reverse dtbs_equal_unordered \ add_subnode_with_nops path_offset_aliases \ utilfdt_test \ - integer-expressions + integer-expressions \ + subnode_iterate LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%) LIBTREE_TESTS_L = truncated_property diff --git a/tests/add_subnode_with_nops.c b/tests/add_subnode_with_nops.c index 4fb8f0245523..95ddf6a5928c 100644 --- a/tests/add_subnode_with_nops.c +++ b/tests/add_subnode_with_nops.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/aliases.dts b/tests/aliases.dts index 39d88ffc8594..853479aee766 100644 --- a/tests/aliases.dts +++ b/tests/aliases.dts @@ -1,6 +1,9 @@ /dts-v1/; / { + #address-cells = <1>; + #size-cells = <0>; + aliases { s1 = &sub1; ss1 = &subsub1; @@ -9,6 +12,7 @@ sub1: subnode@1 { compatible = "subnode1"; + reg = <1>; subsub1: subsubnode { compatible = "subsubnode1", "subsubnode"; diff --git a/tests/appendprop1.c b/tests/appendprop1.c index d716f7afde6f..9d6b3add9d43 100644 --- a/tests/appendprop1.c +++ b/tests/appendprop1.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/appendprop2.c b/tests/appendprop2.c index 7eb243dfa36e..ca1446c513b4 100644 --- a/tests/appendprop2.c +++ b/tests/appendprop2.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/asm_tree_dump.c b/tests/asm_tree_dump.c index 5ff50872c8ef..bd12edaa880d 100644 --- a/tests/asm_tree_dump.c +++ b/tests/asm_tree_dump.c @@ -26,7 +26,6 @@ #include <dlfcn.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/boot-cpuid.c b/tests/boot-cpuid.c index 7b5433dbacbf..ca39f4b69294 100644 --- a/tests/boot-cpuid.c +++ b/tests/boot-cpuid.c @@ -21,7 +21,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/char_literal.c b/tests/char_literal.c index 150f2a0c1488..d7a4773419a0 100644 --- a/tests/char_literal.c +++ b/tests/char_literal.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/del_node.c b/tests/del_node.c index afad5027b791..45cb06016dc5 100644 --- a/tests/del_node.c +++ b/tests/del_node.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/del_property.c b/tests/del_property.c index 449eca6150c6..42fd7cb1c15e 100644 --- a/tests/del_property.c +++ b/tests/del_property.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/dtb_reverse.c b/tests/dtb_reverse.c index 25e1eef81775..527fd71336d7 100644 --- a/tests/dtb_reverse.c +++ b/tests/dtb_reverse.c @@ -24,7 +24,6 @@ #include <stdint.h> #include <limits.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/dtbs_equal_ordered.c b/tests/dtbs_equal_ordered.c index 1db25f45265a..12495dea483e 100644 --- a/tests/dtbs_equal_ordered.c +++ b/tests/dtbs_equal_ordered.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/dtbs_equal_unordered.c b/tests/dtbs_equal_unordered.c index df5331883b15..20b4356f92f6 100644 --- a/tests/dtbs_equal_unordered.c +++ b/tests/dtbs_equal_unordered.c @@ -24,7 +24,6 @@ #include <stdint.h> #include <limits.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/dumptrees.c b/tests/dumptrees.c index fa1f56368413..bebf553c9bfe 100644 --- a/tests/dumptrees.c +++ b/tests/dumptrees.c @@ -25,9 +25,7 @@ #include <fcntl.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> -#include <libfdt_env.h> #include "testdata.h" diff --git a/tests/extra-terminating-null.c b/tests/extra-terminating-null.c index 8a2043f3dd76..dc1fe89ab053 100644 --- a/tests/extra-terminating-null.c +++ b/tests/extra-terminating-null.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/fdtget-runtest.sh b/tests/fdtget-runtest.sh index c3a355951dff..8d8b0587602e 100755 --- a/tests/fdtget-runtest.sh +++ b/tests/fdtget-runtest.sh @@ -8,7 +8,7 @@ rm -f $LOG $EXPECT trap "rm -f $LOG $EXPECT" 0 expect="$1" -/bin/echo -e $expect >$EXPECT +printf '%b\n' "$expect" > $EXPECT shift verbose_run_log_check "$LOG" $VALGRIND $DTGET "$@" diff --git a/tests/find_property.c b/tests/find_property.c index 74a696587c32..4dc3030e37e3 100644 --- a/tests/find_property.c +++ b/tests/find_property.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/get_alias.c b/tests/get_alias.c index 1e0faf474fe7..506079575153 100644 --- a/tests/get_alias.c +++ b/tests/get_alias.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/get_mem_rsv.c b/tests/get_mem_rsv.c index 554c78868f94..181263935899 100644 --- a/tests/get_mem_rsv.c +++ b/tests/get_mem_rsv.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/get_name.c b/tests/get_name.c index 0262a120d1f3..c6ca9f9bbf8c 100644 --- a/tests/get_name.c +++ b/tests/get_name.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/get_path.c b/tests/get_path.c index 1e05f7c21163..735297659379 100644 --- a/tests/get_path.c +++ b/tests/get_path.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/get_phandle.c b/tests/get_phandle.c index 5735733fadbf..2079591d4c49 100644 --- a/tests/get_phandle.c +++ b/tests/get_phandle.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/getprop.c b/tests/getprop.c index 239856e7c958..6255badb3fac 100644 --- a/tests/getprop.c +++ b/tests/getprop.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/incbin.c b/tests/incbin.c index 76d86262644c..4100ba029971 100644 --- a/tests/incbin.c +++ b/tests/incbin.c @@ -23,7 +23,6 @@ #include <stdint.h> #include <errno.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/include1.dts b/tests/include1.dts index 893aaffe7496..0b4b773e654d 100644 --- a/tests/include1.dts +++ b/tests/include1.dts @@ -8,12 +8,17 @@ /include/ "include5.dts" = <0xdeadbeef>; prop-int64 /include/ "include5a.dts"; prop-str = /include/ "include6.dts"; + #address-cells = <1>; + #size-cells = <0>; /include/ "include7.dts" subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; /include/ "include8.dts" phandle = <0x2001>; diff --git a/tests/include7.dts b/tests/include7.dts index dba5e470559a..2f6eb890f1fa 100644 --- a/tests/include7.dts +++ b/tests/include7.dts @@ -1,5 +1,6 @@ subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { diff --git a/tests/include8.dts b/tests/include8.dts index ec7006437657..7532ef51d7ee 100644 --- a/tests/include8.dts +++ b/tests/include8.dts @@ -1 +1,2 @@ -subsubnode@0 {
\ No newline at end of file +subsubnode@0 { + reg = <0>; diff --git a/tests/integer-expressions.c b/tests/integer-expressions.c index 5ba1566ab8e2..57e2ff670ded 100644 --- a/tests/integer-expressions.c +++ b/tests/integer-expressions.c @@ -25,7 +25,6 @@ #include <errno.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/mangle-layout.c b/tests/mangle-layout.c index 3b19788bd72a..a76e51e31b55 100644 --- a/tests/mangle-layout.c +++ b/tests/mangle-layout.c @@ -24,7 +24,6 @@ #include <limits.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/move_and_save.c b/tests/move_and_save.c index 410ccb3be715..393b60ac1936 100644 --- a/tests/move_and_save.c +++ b/tests/move_and_save.c @@ -24,7 +24,6 @@ #include <limits.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/node_check_compatible.c b/tests/node_check_compatible.c index 23abbf529d9e..4bdf09194c8b 100644 --- a/tests/node_check_compatible.c +++ b/tests/node_check_compatible.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/node_offset_by_compatible.c b/tests/node_offset_by_compatible.c index 23179300f012..f62b591ce249 100644 --- a/tests/node_offset_by_compatible.c +++ b/tests/node_offset_by_compatible.c @@ -23,7 +23,6 @@ #include <stdint.h> #include <stdarg.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/node_offset_by_phandle.c b/tests/node_offset_by_phandle.c index a8442f15a6b0..becff0fd5a1a 100644 --- a/tests/node_offset_by_phandle.c +++ b/tests/node_offset_by_phandle.c @@ -23,7 +23,6 @@ #include <stdint.h> #include <stdarg.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/node_offset_by_prop_value.c b/tests/node_offset_by_prop_value.c index 0f2a34512ae2..9212a4efeffc 100644 --- a/tests/node_offset_by_prop_value.c +++ b/tests/node_offset_by_prop_value.c @@ -23,7 +23,6 @@ #include <stdint.h> #include <stdarg.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/nop_node.c b/tests/nop_node.c index ea3a18f6acb5..c316444f6dce 100644 --- a/tests/nop_node.c +++ b/tests/nop_node.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/nop_property.c b/tests/nop_property.c index e6ef4d973149..644b0a665e6d 100644 --- a/tests/nop_property.c +++ b/tests/nop_property.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/nopulate.c b/tests/nopulate.c index 3cbbe2113c79..cd79872bc4a9 100644 --- a/tests/nopulate.c +++ b/tests/nopulate.c @@ -24,7 +24,6 @@ #include <limits.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/notfound.c b/tests/notfound.c index 4d55b886ba7a..dc623d624672 100644 --- a/tests/notfound.c +++ b/tests/notfound.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/open_pack.c b/tests/open_pack.c index 0a5a3fcc8392..407ef6c542a0 100644 --- a/tests/open_pack.c +++ b/tests/open_pack.c @@ -24,7 +24,6 @@ #include <limits.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/parent_offset.c b/tests/parent_offset.c index e7affcc39afc..d4ab3cff3052 100644 --- a/tests/parent_offset.c +++ b/tests/parent_offset.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/path-references.c b/tests/path-references.c index 9f363b3af3cb..0746b3f7e324 100644 --- a/tests/path-references.c +++ b/tests/path-references.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/path_offset.c b/tests/path_offset.c index d3e1f8ebbac0..4e5b7a11f70d 100644 --- a/tests/path_offset.c +++ b/tests/path_offset.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/path_offset_aliases.c b/tests/path_offset_aliases.c index 3682da489a87..78d5a46967c8 100644 --- a/tests/path_offset_aliases.c +++ b/tests/path_offset_aliases.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/phandle_format.c b/tests/phandle_format.c index 7e4d81630e08..5874ae79291c 100644 --- a/tests/phandle_format.c +++ b/tests/phandle_format.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/references.c b/tests/references.c index b20f21fdeca0..c9d05a2f2962 100644 --- a/tests/references.c +++ b/tests/references.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/root_node.c b/tests/root_node.c index 3f478299f9c6..58aebf6b48c9 100644 --- a/tests/root_node.c +++ b/tests/root_node.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/run_tests.sh b/tests/run_tests.sh index f5eebd6ffcfe..97e016b1aef9 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -7,6 +7,7 @@ if [ -z "$CC" ]; then fi export QUIET_TEST=1 +STOP_ON_FAIL=0 export VALGRIND= VGCODE=126 @@ -24,6 +25,9 @@ base_run_test() { tot_pass=$((tot_pass + 1)) else ret="$?" + if [ "$STOP_ON_FAIL" -eq 1 ]; then + exit 1 + fi if [ "$ret" -eq 1 ]; then tot_config=$((tot_config + 1)) elif [ "$ret" -eq 2 ]; then @@ -80,7 +84,7 @@ wrap_test () { } run_wrap_test () { - echo -n "$@: " + shorten_echo "$@: " base_run_test wrap_test "$@" } @@ -190,6 +194,14 @@ libfdt_tests () { tree1_tests unfinished_tree1.test.dtb run_test dtbs_equal_ordered test_tree1.dtb sw_tree1.test.dtb + # Resizing tests + for mode in resize realloc; do + run_test sw_tree1 $mode + tree1_tests sw_tree1.test.dtb + tree1_tests unfinished_tree1.test.dtb + run_test dtbs_equal_ordered test_tree1.dtb sw_tree1.test.dtb + done + # 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 @@ -241,6 +253,9 @@ libfdt_tests () { tree1_tests_rw noppy.$basetree done + run_dtc_test -I dts -O dtb -o subnode_iterate.dtb subnode_iterate.dts + run_test subnode_iterate subnode_iterate.dtb + # Tests for behaviour on various sorts of corrupted trees run_test truncated_property @@ -254,6 +269,11 @@ dtc_tests () { tree1_tests_rw dtc_tree1.test.dtb run_test dtbs_equal_ordered dtc_tree1.test.dtb test_tree1.dtb + run_dtc_test -I dts -O dtb -o dtc_escapes.test.dtb propname_escapes.dts + run_test propname_escapes dtc_escapes.test.dtb + + run_dtc_test -I dts -O dtb -o line_directives.test.dtb line_directives.dts + run_dtc_test -I dts -O dtb -o dtc_escapes.test.dtb escapes.dts run_test string_escapes dtc_escapes.test.dtb @@ -367,6 +387,13 @@ dtc_tests () { run_dtc_test -I dts -O dtb -o dtc_tree1_merge_path.test.dtb test_tree1_merge_path.dts tree1_tests dtc_tree1_merge_path.test.dtb test_tree1.dtb + # Check prop/node delete functionality + run_dtc_test -I dts -O dtb -o dtc_tree1_delete.test.dtb test_tree1_delete.dts + tree1_tests dtc_tree1_delete.test.dtb + + run_dtc_test -I dts -O dts -o delete_reinstate_multilabel.dts.test.dts delete_reinstate_multilabel.dts + run_wrap_test cmp delete_reinstate_multilabel.dts.test.dts delete_reinstate_multilabel_ref.dts + # Check some checks check_tests dup-nodename.dts duplicate_node_names check_tests dup-propname.dts duplicate_property_names @@ -486,9 +513,10 @@ fdtget_tests () { # run_fdtget_test <expected-result> [<flags>] <file> <node> <property> run_fdtget_test "MyBoardName" $dtb / model + run_fdtget_test "MyBoardName MyBoardFamilyName" $dtb / compatible run_fdtget_test "77 121 66 111 \ 97 114 100 78 97 109 101 0 77 121 66 111 97 114 100 70 97 109 105 \ -108 121 78 97 109 101 0" $dtb / compatible +108 121 78 97 109 101 0" -t bu $dtb / compatible run_fdtget_test "MyBoardName MyBoardFamilyName" -t s $dtb / compatible run_fdtget_test 32768 $dtb /cpus/PowerPC,970@1 d-cache-size run_fdtget_test 8000 -tx $dtb /cpus/PowerPC,970@1 d-cache-size @@ -533,8 +561,8 @@ fdtput_tests () { -tx "a0b0c0d deeaae ef000000" run_fdtput_test "$(cat $text)" $dtb /randomnode blob -ts "$(cat $text)" - # This should be larger than available space in the fdt - run_wrap_error_test $DTPUT $dtb /randomnode blob -ts "$(cat $text $text)" + # Test expansion of the blob when insufficient room for property + run_fdtput_test "$(cat $text $text)" $dtb /randomnode blob -ts "$(cat $text $text)" # Start again with a fresh dtb run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts @@ -556,7 +584,9 @@ fdtput_tests () { run_fdtput_test "fine wine" $dtb /blackadder/the-second/potato drink \ "-ts" "fine wine" run_wrap_test $DTPUT $dtb -p /you/are/drunk/sir/winston slurp -ts twice - run_wrap_error_test $DTPUT $dtb -cp "$(cat $text $text)/longish" + + # Test expansion of the blob when insufficent room for a new node + run_wrap_test $DTPUT $dtb -cp "$(cat $text $text)/longish" # Allowed to create an existing node with -p run_wrap_test $DTPUT $dtb -cp /chosen @@ -569,7 +599,7 @@ utilfdt_tests () { run_test utilfdt_test } -while getopts "vt:m" ARG ; do +while getopts "vt:me" ARG ; do case $ARG in "v") unset QUIET_TEST @@ -580,6 +610,9 @@ while getopts "vt:m" ARG ; do "m") VALGRIND="valgrind --tool=memcheck -q --error-exitcode=$VGCODE" ;; + "e") + STOP_ON_FAIL=1 + ;; esac done diff --git a/tests/rw_tree1.c b/tests/rw_tree1.c index 103a24d7769f..efd471892f1c 100644 --- a/tests/rw_tree1.c +++ b/tests/rw_tree1.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/set_name.c b/tests/set_name.c index 5d1149e002cd..986158733a58 100644 --- a/tests/set_name.c +++ b/tests/set_name.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/setprop.c b/tests/setprop.c index 9f2bc883b25e..d089f8d5ab5e 100644 --- a/tests/setprop.c +++ b/tests/setprop.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/setprop_inplace.c b/tests/setprop_inplace.c index 82d895138d5d..daef182d0b28 100644 --- a/tests/setprop_inplace.c +++ b/tests/setprop_inplace.c @@ -25,7 +25,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/sized_cells.c b/tests/sized_cells.c index 847ec96ba4ad..94da03b8a077 100644 --- a/tests/sized_cells.c +++ b/tests/sized_cells.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/string_escapes.c b/tests/string_escapes.c index 30eb6a8d3d4d..8cdee4bb34fe 100644 --- a/tests/string_escapes.c +++ b/tests/string_escapes.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/subnode_offset.c b/tests/subnode_offset.c index e58c192f7ab1..231fcb50a26c 100644 --- a/tests/subnode_offset.c +++ b/tests/subnode_offset.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/supernode_atdepth_offset.c b/tests/supernode_atdepth_offset.c index 73f41aecf93c..43e120d79e4e 100644 --- a/tests/supernode_atdepth_offset.c +++ b/tests/supernode_atdepth_offset.c @@ -22,7 +22,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c index 5c71414692a5..6d4c53102967 100644 --- a/tests/sw_tree1.c +++ b/tests/sw_tree1.c @@ -24,7 +24,6 @@ #include <ctype.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" @@ -32,24 +31,92 @@ #define SPACE 65536 -#define CHECK(code) \ - { \ - err = (code); \ - if (err) \ - FAIL(#code ": %s", fdt_strerror(err)); \ +static enum { + FIXED = 0, + RESIZE, + REALLOC, +} alloc_mode; + +static void realloc_fdt(void **fdt, size_t *size, bool created) +{ + switch (alloc_mode) { + case FIXED: + if (!(*fdt)) + fdt = xmalloc(*size); + else + FAIL("Ran out of space"); + return; + + case RESIZE: + if (!(*fdt)) { + fdt = xmalloc(SPACE); + } else if (*size < SPACE) { + *size += 1; + fdt_resize(*fdt, *fdt, *size); + } else { + FAIL("Ran out of space"); + } + return; + + case REALLOC: + *size += 1; + *fdt = xrealloc(*fdt, *size); + if (created) + fdt_resize(*fdt, *fdt, *size); + return; + + default: + CONFIG("Bad allocation mode"); } +} + +#define CHECK(code) \ + do { \ + err = (code); \ + if (err == -FDT_ERR_NOSPACE) \ + realloc_fdt(&fdt, &size, created); \ + else if (err) \ + FAIL(#code ": %s", fdt_strerror(err)); \ + } while (err != 0) int main(int argc, char *argv[]) { - void *fdt; + void *fdt = NULL; + size_t size; int err; + bool created = false; test_init(argc, argv); - fdt = xmalloc(SPACE); - CHECK(fdt_create(fdt, SPACE)); + if (argc == 1) { + alloc_mode = FIXED; + size = SPACE; + } else if (argc == 2) { + if (streq(argv[1], "resize")) { + alloc_mode = REALLOC; + size = 0; + } else if (streq(argv[1], "realloc")) { + alloc_mode = REALLOC; + size = 0; + } else { + char *endp; + + size = strtoul(argv[1], &endp, 0); + if (*endp == '\0') + alloc_mode = FIXED; + else + CONFIG("Bad allocation mode \"%s\" specified", + argv[1]); + } + } + + fdt = xmalloc(size); + CHECK(fdt_create(fdt, size)); + + created = true; CHECK(fdt_add_reservemap_entry(fdt, TEST_ADDR_1, TEST_SIZE_1)); + CHECK(fdt_add_reservemap_entry(fdt, TEST_ADDR_2, TEST_SIZE_2)); CHECK(fdt_finish_reservemap(fdt)); @@ -58,9 +125,12 @@ int main(int argc, char *argv[]) CHECK(fdt_property_u32(fdt, "prop-int", TEST_VALUE_1)); CHECK(fdt_property_u64(fdt, "prop-int64", TEST_VALUE64_1)); CHECK(fdt_property_string(fdt, "prop-str", TEST_STRING_1)); + CHECK(fdt_property_u32(fdt, "#address-cells", 1)); + CHECK(fdt_property_u32(fdt, "#size-cells", 0)); CHECK(fdt_begin_node(fdt, "subnode@1")); CHECK(fdt_property_string(fdt, "compatible", "subnode1")); + CHECK(fdt_property_u32(fdt, "reg", 1)); CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1)); CHECK(fdt_begin_node(fdt, "subsubnode")); CHECK(fdt_property(fdt, "compatible", "subsubnode1\0subsubnode", @@ -72,9 +142,13 @@ int main(int argc, char *argv[]) CHECK(fdt_end_node(fdt)); CHECK(fdt_begin_node(fdt, "subnode@2")); + CHECK(fdt_property_u32(fdt, "reg", 2)); CHECK(fdt_property_cell(fdt, "linux,phandle", PHANDLE_1)); CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_2)); + CHECK(fdt_property_u32(fdt, "#address-cells", 1)); + CHECK(fdt_property_u32(fdt, "#size-cells", 0)); CHECK(fdt_begin_node(fdt, "subsubnode@0")); + CHECK(fdt_property_u32(fdt, "reg", 0)); CHECK(fdt_property_cell(fdt, "phandle", PHANDLE_2)); CHECK(fdt_property(fdt, "compatible", "subsubnode2\0subsubnode", 23)); diff --git a/tests/test_tree1.dts b/tests/test_tree1.dts index cf530ce4ba01..c7b170c5af60 100644 --- a/tests/test_tree1.dts +++ b/tests/test_tree1.dts @@ -1,38 +1,3 @@ /dts-v1/; -/memreserve/ 0xdeadbeef00000000 0x100000; -/memreserve/ 123456789 010000; - -/ { - compatible = "test_tree1"; - prop-int = <0xdeadbeef>; - prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>; - prop-str = "hello world"; - - subnode@1 { - compatible = "subnode1"; - prop-int = [deadbeef]; - - subsubnode { - compatible = "subsubnode1", "subsubnode"; - prop-int = <0xdeadbeef>; - }; - - ss1 { - }; - }; - - subnode@2 { - linux,phandle = <0x2000>; - prop-int = <123456789>; - - ssn0: subsubnode@0 { - phandle = <0x2001>; - compatible = "subsubnode2", "subsubnode"; - prop-int = <0726746425>; - }; - - ss2 { - }; - }; -}; +/include/ "test_tree1_body.dtsi" diff --git a/tests/test_tree1_merge.dts b/tests/test_tree1_merge.dts index ded08d871435..b100c12debb5 100644 --- a/tests/test_tree1_merge.dts +++ b/tests/test_tree1_merge.dts @@ -6,9 +6,12 @@ compatible = "test_tree1"; prop-int = "wrong!"; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; subsubnode { compatible = "subsubnode1", "subsubnode"; @@ -20,8 +23,11 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; ss2 { }; @@ -36,6 +42,7 @@ }; subnode@2 { ssn0: subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/test_tree1_merge_labelled.dts b/tests/test_tree1_merge_labelled.dts index 29953b0aa1b3..fcf5dc45aeef 100644 --- a/tests/test_tree1_merge_labelled.dts +++ b/tests/test_tree1_merge_labelled.dts @@ -8,9 +8,12 @@ prop-int = <0xdeadbeef>; prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -23,10 +26,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; ssn0: subsubnode@0 { + reg = <0>; phandle = <0x2001>; prop-int = <0xbad>; }; diff --git a/tests/test_tree1_merge_path.dts b/tests/test_tree1_merge_path.dts index 168d066fad08..c2ad829727db 100644 --- a/tests/test_tree1_merge_path.dts +++ b/tests/test_tree1_merge_path.dts @@ -8,9 +8,12 @@ prop-int = <0xdeadbeef>; prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -23,10 +26,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; ssn0: subsubnode@0 { + reg = <0>; phandle = <0x2001>; prop-int = <0xbad>; }; diff --git a/tests/test_tree1_wrong1.dts b/tests/test_tree1_wrong1.dts index d71820a23864..900d38582912 100644 --- a/tests/test_tree1_wrong1.dts +++ b/tests/test_tree1_wrong1.dts @@ -6,9 +6,12 @@ compatible = "test_tree1"; prop-int = <0xdeadbeef>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -21,10 +24,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/test_tree1_wrong2.dts b/tests/test_tree1_wrong2.dts index ac27023c3c9a..099752b374aa 100644 --- a/tests/test_tree1_wrong2.dts +++ b/tests/test_tree1_wrong2.dts @@ -6,9 +6,12 @@ / { compatible = "test_tree1"; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -21,10 +24,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/test_tree1_wrong3.dts b/tests/test_tree1_wrong3.dts index 80be2fac8f63..069353a9400c 100644 --- a/tests/test_tree1_wrong3.dts +++ b/tests/test_tree1_wrong3.dts @@ -7,9 +7,12 @@ compatible = "test_tree1"; prop-int = <0xdeadbeef>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; subsubnode { compatible = "subsubnode1", "subsubnode"; @@ -21,10 +24,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/test_tree1_wrong4.dts b/tests/test_tree1_wrong4.dts index 09bb13b8cb89..2c5641618e4a 100644 --- a/tests/test_tree1_wrong4.dts +++ b/tests/test_tree1_wrong4.dts @@ -7,9 +7,12 @@ compatible = "test_tree1"; prop-int = <0xdeadbeef>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -22,10 +25,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/test_tree1_wrong5.dts b/tests/test_tree1_wrong5.dts index ef4c4f7b772d..6ddd72d52e1b 100644 --- a/tests/test_tree1_wrong5.dts +++ b/tests/test_tree1_wrong5.dts @@ -7,9 +7,12 @@ compatible = "test_tree1"; prop-int = <0xdeadbefe>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -22,10 +25,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/test_tree1_wrong6.dts b/tests/test_tree1_wrong6.dts index 98d6eda7fb56..36b4e1f66fe5 100644 --- a/tests/test_tree1_wrong6.dts +++ b/tests/test_tree1_wrong6.dts @@ -7,9 +7,12 @@ compatible = "test_tree1"; prop-int = <0xdeadbeef>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -23,10 +26,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/test_tree1_wrong7.dts b/tests/test_tree1_wrong7.dts index f57ace09a30f..54150e6d9fb8 100644 --- a/tests/test_tree1_wrong7.dts +++ b/tests/test_tree1_wrong7.dts @@ -7,9 +7,12 @@ compatible = "test_tree1"; prop-int = <0xdeadbeef>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -22,10 +25,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/test_tree1_wrong8.dts b/tests/test_tree1_wrong8.dts index 811ce6c0e536..7a28a9f2953a 100644 --- a/tests/test_tree1_wrong8.dts +++ b/tests/test_tree1_wrong8.dts @@ -7,9 +7,12 @@ compatible = "test_tree1"; prop-int = <0xdeadbeef>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -24,8 +27,12 @@ subnode@2 { linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/test_tree1_wrong9.dts b/tests/test_tree1_wrong9.dts index 6ff6fab22dd2..f6486fa9337d 100644 --- a/tests/test_tree1_wrong9.dts +++ b/tests/test_tree1_wrong9.dts @@ -8,9 +8,12 @@ compatible = "test_tree1"; prop-int = <0xdeadbeef>; prop-str = "hello world"; + #address-cells = <1>; + #size-cells = <0>; subnode@1 { compatible = "subnode1"; + reg = <1>; prop-int = [deadbeef]; subsubnode { @@ -23,10 +26,14 @@ }; subnode@2 { + reg = <2>; linux,phandle = <0x2000>; prop-int = <123456789>; + #address-cells = <1>; + #size-cells = <0>; subsubnode@0 { + reg = <0>; phandle = <0x2001>; compatible = "subsubnode2", "subsubnode"; prop-int = <0726746425>; diff --git a/tests/trees.S b/tests/trees.S index cae018760e58..2389cd379621 100644 --- a/tests/trees.S +++ b/tests/trees.S @@ -92,9 +92,12 @@ test_tree1_struct: PROP_INT(test_tree1, prop_int, TEST_VALUE_1) PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1) PROP_STR(test_tree1, prop_str, TEST_STRING_1) + PROP_INT(test_tree1, address_cells, 1) + PROP_INT(test_tree1, size_cells, 0) BEGIN_NODE("subnode@1") PROP_STR(test_tree1, compatible, "subnode1") + PROP_INT(test_tree1, reg, 1) PROP_INT(test_tree1, prop_int, TEST_VALUE_1) BEGIN_NODE("subsubnode") @@ -108,10 +111,14 @@ test_tree1_struct: END_NODE BEGIN_NODE("subnode@2") + PROP_INT(test_tree1, reg, 2) PROP_INT(test_tree1, linux_phandle, PHANDLE_1) PROP_INT(test_tree1, prop_int, TEST_VALUE_2) + PROP_INT(test_tree1, address_cells, 1) + PROP_INT(test_tree1, size_cells, 0) BEGIN_NODE("subsubnode@0") + PROP_INT(test_tree1, reg, 0) PROP_INT(test_tree1, phandle, PHANDLE_2) PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode") PROP_INT(test_tree1, prop_int, TEST_VALUE_2) @@ -133,6 +140,9 @@ test_tree1_strings: STRING(test_tree1, prop_str, "prop-str") STRING(test_tree1, linux_phandle, "linux,phandle") STRING(test_tree1, phandle, "phandle") + STRING(test_tree1, reg, "reg") + STRING(test_tree1, address_cells, "#address-cells") + STRING(test_tree1, size_cells, "#size-cells") test_tree1_strings_end: test_tree1_end: diff --git a/tests/truncated_property.c b/tests/truncated_property.c index 56daa2276be9..f820d99e3f5d 100644 --- a/tests/truncated_property.c +++ b/tests/truncated_property.c @@ -23,7 +23,6 @@ #include <string.h> #include <stdint.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" diff --git a/tests/utilfdt_test.c b/tests/utilfdt_test.c index 36b4aa54de49..274c3d68e953 100644 --- a/tests/utilfdt_test.c +++ b/tests/utilfdt_test.c @@ -24,7 +24,6 @@ #include <stdint.h> #include <stdarg.h> -#include <fdt.h> #include <libfdt.h> #include <util.h> diff --git a/tests/value-labels.c b/tests/value-labels.c index abe272164927..dcf20593d5c1 100644 --- a/tests/value-labels.c +++ b/tests/value-labels.c @@ -26,7 +26,6 @@ #include <dlfcn.h> -#include <fdt.h> #include <libfdt.h> #include "tests.h" |