aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2012-07-24 02:58:10 +0000
committerWarner Losh <imp@FreeBSD.org>2012-07-24 02:58:10 +0000
commitbae61446cfa6a4b67c0197a6c7535190b80c8a3d (patch)
tree0adf736d61fa3f379fec96cd67783a6029af264e /tests
parentb7b62f41399c6bc3ef3f9583dbc35cbd0a28101f (diff)
downloadsrc-bae61446cfa6a4b67c0197a6c7535190b80c8a3d.tar.gz
src-bae61446cfa6a4b67c0197a6c7535190b80c8a3d.zip
Import dtc from git://git.jdl.com/software/dtc
hash f807af192828222dee7a5c9f94d999673bb4d8a1
Notes
Notes: svn path=/vendor/dtc/dist/; revision=238733
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.tests21
-rw-r--r--tests/dtbs_equal_ordered.c87
-rwxr-xr-xtests/dtc-checkfails.sh31
-rw-r--r--tests/extra-terminating-null.c2
-rw-r--r--tests/get_alias.c2
-rw-r--r--tests/include1.dts1
-rw-r--r--tests/mangle-layout.c7
-rw-r--r--tests/notfound.c8
-rw-r--r--tests/open_pack.c2
-rw-r--r--tests/path_offset.c4
-rw-r--r--tests/path_offset_aliases.c2
-rwxr-xr-xtests/run_tests.sh299
-rw-r--r--tests/rw_tree1.c15
-rw-r--r--tests/setprop.c18
-rw-r--r--tests/setprop_inplace.c18
-rw-r--r--tests/subnode_offset.c6
-rw-r--r--tests/sw_tree1.c3
-rw-r--r--tests/test_tree1.dts3
-rw-r--r--tests/testdata.h8
-rw-r--r--tests/tests.h23
-rwxr-xr-xtests/tests.sh29
-rw-r--r--tests/testutils.c59
-rw-r--r--tests/trees.S6
-rw-r--r--tests/value-labels.c4
24 files changed, 498 insertions, 160 deletions
diff --git a/tests/Makefile.tests b/tests/Makefile.tests
index ac21adee3da4..179546683619 100644
--- a/tests/Makefile.tests
+++ b/tests/Makefile.tests
@@ -5,16 +5,22 @@ LIB_TESTS_L = get_mem_rsv \
node_offset_by_prop_value node_offset_by_phandle \
node_check_compatible node_offset_by_compatible \
get_alias \
+ char_literal \
+ sized_cells \
notfound \
setprop_inplace nop_property nop_node \
sw_tree1 \
move_and_save mangle-layout nopulate \
open_pack rw_tree1 set_name setprop del_property del_node \
+ appendprop1 appendprop2 \
string_escapes references path-references phandle_format \
boot-cpuid incbin \
extra-terminating-null \
dtbs_equal_ordered \
- add_subnode_with_nops path_offset_aliases
+ dtb_reverse dtbs_equal_unordered \
+ add_subnode_with_nops path_offset_aliases \
+ utilfdt_test \
+ integer-expressions
LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%)
LIBTREE_TESTS_L = truncated_property
@@ -40,13 +46,14 @@ TESTS_CLEANFILES = $(TESTS) $(TESTS_CLEANFILES_L:%=$(TESTS_PREFIX)%)
.PHONY: tests
tests: $(TESTS) $(TESTS_TREES)
-$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o $(LIBFDT_archive)
+$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_archive)
-$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o $(LIBFDT_archive)
+$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_archive)
@$(VECHO) LD [libdl] $@
$(LINK.c) -o $@ $^ -ldl
-$(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o $(LIBFDT_archive)
+$(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o \
+ util.o $(LIBFDT_archive)
$(TESTS_PREFIX)dumptrees: $(TESTS_PREFIX)trees.o
@@ -59,13 +66,13 @@ tests_clean:
rm -f $(STD_CLEANFILES:%=$(TESTS_PREFIX)%)
rm -f $(TESTS_CLEANFILES)
-check: tests dtc convert-dtsv0
+check: tests ${TESTS_BIN}
cd $(TESTS_PREFIX); ./run_tests.sh
-checkm: tests dtc convert-dtsv0
+checkm: tests ${TESTS_BIN}
cd $(TESTS_PREFIX); ./run_tests.sh -m 2>&1 | tee vglog.$$$$
-checkv: tests dtc convert-dtsv0
+checkv: tests ${TESTS_BIN}
cd $(TESTS_PREFIX); ./run_tests.sh -v
ifneq ($(DEPTARGETS),)
diff --git a/tests/dtbs_equal_ordered.c b/tests/dtbs_equal_ordered.c
index ed9278c4f30a..1db25f45265a 100644
--- a/tests/dtbs_equal_ordered.c
+++ b/tests/dtbs_equal_ordered.c
@@ -29,6 +29,31 @@
#include "tests.h"
#include "testdata.h"
+int notequal; /* = 0 */
+
+#define MISMATCH(fmt, ...) \
+ do { \
+ if (notequal) \
+ PASS(); \
+ else \
+ FAIL(fmt, ##__VA_ARGS__); \
+ } while (0)
+
+#define MATCH() \
+ do { \
+ if (!notequal) \
+ PASS(); \
+ else \
+ FAIL("Trees match which shouldn't"); \
+ } while (0)
+
+#define CHECK(code) \
+ { \
+ err = (code); \
+ if (err) \
+ FAIL(#code ": %s", fdt_strerror(err)); \
+ }
+
static void compare_mem_rsv(const void *fdt1, const void *fdt2)
{
int i;
@@ -36,23 +61,18 @@ static void compare_mem_rsv(const void *fdt1, const void *fdt2)
int err;
if (fdt_num_mem_rsv(fdt1) != fdt_num_mem_rsv(fdt2))
- FAIL("Trees have different number of reserve entries");
+ MISMATCH("Trees have different number of reserve entries");
for (i = 0; i < fdt_num_mem_rsv(fdt1); i++) {
- err = fdt_get_mem_rsv(fdt1, i, &addr1, &size1);
- if (err)
- FAIL("fdt_get_mem_rsv(fdt1, %d, ...): %s", i,
- fdt_strerror(err));
- err = fdt_get_mem_rsv(fdt2, i, &addr2, &size2);
- if (err)
- FAIL("fdt_get_mem_rsv(fdt2, %d, ...): %s", i,
- fdt_strerror(err));
+ CHECK(fdt_get_mem_rsv(fdt1, i, &addr1, &size1));
+ CHECK(fdt_get_mem_rsv(fdt2, i, &addr2, &size2));
+
if ((addr1 != addr2) || (size1 != size2))
- FAIL("Mismatch in reserve entry %d: "
- "(0x%llx, 0x%llx) != (0x%llx, 0x%llx)", i,
- (unsigned long long)addr1,
- (unsigned long long)size1,
- (unsigned long long)addr2,
- (unsigned long long)size2);
+ MISMATCH("Mismatch in reserve entry %d: "
+ "(0x%llx, 0x%llx) != (0x%llx, 0x%llx)", i,
+ (unsigned long long)addr1,
+ (unsigned long long)size1,
+ (unsigned long long)addr2,
+ (unsigned long long)size2);
}
}
@@ -77,7 +97,7 @@ static void compare_structure(const void *fdt1, const void *fdt2)
} while (tag2 == FDT_NOP);
if (tag1 != tag2)
- FAIL("Tag mismatch (%d != %d) at (%d, %d)",
+ MISMATCH("Tag mismatch (%d != %d) at (%d, %d)",
tag1, tag2, offset1, offset2);
switch (tag1) {
@@ -90,9 +110,10 @@ static void compare_structure(const void *fdt1, const void *fdt2)
if (!name2)
FAIL("fdt_get_name(fdt2, %d, ..): %s",
offset2, fdt_strerror(err));
+
if (!streq(name1, name2))
- FAIL("Name mismatch (\"%s\" != \"%s\") at (%d, %d)",
- name1, name2, offset1, offset2);
+ MISMATCH("Name mismatch (\"%s\" != \"%s\") at (%d, %d)",
+ name1, name2, offset1, offset2);
break;
case FDT_PROP:
@@ -106,17 +127,17 @@ static void compare_structure(const void *fdt1, const void *fdt2)
name1 = fdt_string(fdt1, fdt32_to_cpu(prop1->nameoff));
name2 = fdt_string(fdt2, fdt32_to_cpu(prop2->nameoff));
if (!streq(name1, name2))
- FAIL("Property name mismatch \"%s\" != \"%s\" "
- "at (%d, %d)", name1, name2, offset1, offset2);
+ MISMATCH("Property name mismatch \"%s\" != \"%s\" "
+ "at (%d, %d)", name1, name2, offset1, offset2);
len1 = fdt32_to_cpu(prop1->len);
len2 = fdt32_to_cpu(prop2->len);
if (len1 != len2)
- FAIL("Property length mismatch %u != %u "
- "at (%d, %d)", len1, len2, offset1, offset2);
+ MISMATCH("Property length mismatch %u != %u "
+ "at (%d, %d)", len1, len2, offset1, offset2);
if (memcmp(prop1->data, prop2->data, len1) != 0)
- FAIL("Property value mismatch at (%d, %d)",
- offset1, offset2);
+ MISMATCH("Property value mismatch at (%d, %d)",
+ offset1, offset2);
break;
case FDT_END:
@@ -131,10 +152,14 @@ int main(int argc, char *argv[])
uint32_t cpuid1, cpuid2;
test_init(argc, argv);
- if (argc != 3)
- CONFIG("Usage: %s <dtb file> <dtb file>", argv[0]);
- fdt1 = load_blob(argv[1]);
- fdt2 = load_blob(argv[2]);
+ if ((argc != 3)
+ && ((argc != 4) || !streq(argv[1], "-n")))
+ CONFIG("Usage: %s [-n] <dtb file> <dtb file>", argv[0]);
+ if (argc == 4)
+ notequal = 1;
+
+ fdt1 = load_blob(argv[argc-2]);
+ fdt2 = load_blob(argv[argc-1]);
compare_mem_rsv(fdt1, fdt2);
compare_structure(fdt1, fdt2);
@@ -142,8 +167,8 @@ int main(int argc, char *argv[])
cpuid1 = fdt_boot_cpuid_phys(fdt1);
cpuid2 = fdt_boot_cpuid_phys(fdt2);
if (cpuid1 != cpuid2)
- FAIL("boot_cpuid_phys mismatch 0x%x != 0x%x",
- cpuid1, cpuid2);
+ MISMATCH("boot_cpuid_phys mismatch 0x%x != 0x%x",
+ cpuid1, cpuid2);
- PASS();
+ MATCH();
}
diff --git a/tests/dtc-checkfails.sh b/tests/dtc-checkfails.sh
index c58694fc7bbb..76ded15c2d58 100755
--- a/tests/dtc-checkfails.sh
+++ b/tests/dtc-checkfails.sh
@@ -4,30 +4,41 @@
for x; do
shift
+ if [ "$x" = "-n" ]; then
+ for x; do
+ shift
+ if [ "$x" = "--" ]; then
+ break;
+ fi
+ NOCHECKS="$NOCHECKS $x"
+ done
+ break;
+ fi
if [ "$x" = "--" ]; then
break;
fi
- CHECKS="$CHECKS $x"
+ YESCHECKS="$YESCHECKS $x"
done
-LOG="tmp.log.$$"
-
-rm -f $TMPFILE $LOG
+LOG=tmp.log.$$
+rm -f $LOG
+trap "rm -f $LOG" 0
verbose_run_log "$LOG" $VALGRIND "$DTC" -o /dev/null "$@"
ret="$?"
-if [ "$ret" -gt 127 ]; then
- signame=$(kill -l $[ret - 128])
- FAIL "Killed by SIG$signame"
-fi
+FAIL_IF_SIGNAL $ret
-for c in $CHECKS; do
+for c in $YESCHECKS; do
if ! grep -E "^(ERROR)|(Warning) \($c\):" $LOG > /dev/null; then
FAIL "Failed to trigger check \"$c\""
fi
done
-rm -f $LOG
+for c in $NOCHECKS; do
+ if grep -E "^(ERROR)|(Warning) \($c\):" $LOG > /dev/null; then
+ FAIL "Incorrectly triggered check \"$c\""
+ fi
+done
PASS
diff --git a/tests/extra-terminating-null.c b/tests/extra-terminating-null.c
index bb71b1ab34c7..8a2043f3dd76 100644
--- a/tests/extra-terminating-null.c
+++ b/tests/extra-terminating-null.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-void check_extranull(void *fdt, const char *prop, const char *str, int numnulls)
+static void check_extranull(void *fdt, const char *prop, const char *str, int numnulls)
{
int len = strlen(str);
char checkbuf[len+numnulls];
diff --git a/tests/get_alias.c b/tests/get_alias.c
index 8eeaee4a9bd2..1e0faf474fe7 100644
--- a/tests/get_alias.c
+++ b/tests/get_alias.c
@@ -29,7 +29,7 @@
#include "tests.h"
#include "testdata.h"
-void check_alias(void *fdt, const char *path, const char *alias)
+static void check_alias(void *fdt, const char *path, const char *alias)
{
const char *aliaspath;
diff --git a/tests/include1.dts b/tests/include1.dts
index 5d59d8337555..893aaffe7496 100644
--- a/tests/include1.dts
+++ b/tests/include1.dts
@@ -6,6 +6,7 @@
/ {
/include/ "include4.dts"
/include/ "include5.dts" = <0xdeadbeef>;
+ prop-int64 /include/ "include5a.dts";
prop-str = /include/ "include6.dts";
/include/ "include7.dts"
diff --git a/tests/mangle-layout.c b/tests/mangle-layout.c
index 5be28b9af999..3b19788bd72a 100644
--- a/tests/mangle-layout.c
+++ b/tests/mangle-layout.c
@@ -65,7 +65,7 @@ static void new_header(struct bufstate *buf, int version, const void *fdt)
static void add_block(struct bufstate *buf, int version, char block, const void *fdt)
{
- int align, size;
+ int align, size, oldsize;
const void *src;
int offset;
@@ -95,9 +95,10 @@ static void add_block(struct bufstate *buf, int version, char block, const void
CONFIG("Bad block '%c'", block);
}
- offset = ALIGN(buf->size, align);
-
+ oldsize = buf->size;
+ offset = ALIGN(oldsize, align);
expand_buf(buf, offset+size);
+ memset(buf->buf + oldsize, 0, offset - oldsize);
memcpy(buf->buf + offset, src, size);
diff --git a/tests/notfound.c b/tests/notfound.c
index 38918ad2d463..4d55b886ba7a 100644
--- a/tests/notfound.c
+++ b/tests/notfound.c
@@ -37,27 +37,25 @@ static void check_error(const char *s, int 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);
+ fdt_get_property(fdt, 0, "nonexistant-property", &lenerr);
check_error("fdt_get_property(\"nonexistant-property\")", lenerr);
- val = fdt_getprop(fdt, 0, "nonexistant-property", &lenerr);
+ fdt_getprop(fdt, 0, "nonexistant-property", &lenerr);
check_error("fdt_getprop(\"nonexistant-property\"", lenerr);
subnode1_offset = fdt_subnode_offset(fdt, 0, "subnode@1");
if (subnode1_offset < 0)
FAIL("Couldn't find subnode1: %s", fdt_strerror(subnode1_offset));
- val = fdt_getprop(fdt, subnode1_offset, "prop-str", &lenerr);
+ fdt_getprop(fdt, subnode1_offset, "prop-str", &lenerr);
check_error("fdt_getprop(\"prop-str\")", lenerr);
offset = fdt_subnode_offset(fdt, 0, "nonexistant-subnode");
diff --git a/tests/open_pack.c b/tests/open_pack.c
index d6140249c054..0a5a3fcc8392 100644
--- a/tests/open_pack.c
+++ b/tests/open_pack.c
@@ -48,6 +48,8 @@ int main(int argc, char *argv[])
bufsize = oldsize * 2;
buf = xmalloc(bufsize);
+ /* don't leak uninitialized memory into our output */
+ memset(buf, 0, bufsize);
fdt1 = buf;
err = fdt_open_into(fdt, fdt1, bufsize);
diff --git a/tests/path_offset.c b/tests/path_offset.c
index bb092f114cab..d3e1f8ebbac0 100644
--- a/tests/path_offset.c
+++ b/tests/path_offset.c
@@ -104,5 +104,9 @@ int main(int argc, char *argv[])
FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)",
subsubnode2_offset, subsubnode2_offset_p);
+ if (subsubnode2_offset2 != subsubnode2_offset2_p)
+ FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)",
+ subsubnode2_offset2, subsubnode2_offset2_p);
+
PASS();
}
diff --git a/tests/path_offset_aliases.c b/tests/path_offset_aliases.c
index 191edd2b8113..3682da489a87 100644
--- a/tests/path_offset_aliases.c
+++ b/tests/path_offset_aliases.c
@@ -29,7 +29,7 @@
#include "tests.h"
#include "testdata.h"
-void check_alias(void *fdt, const char *full_path, const char *alias_path)
+static void check_alias(void *fdt, const char *full_path, const char *alias_path)
{
int offset, offset_a;
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index c532030f109b..f5eebd6ffcfe 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -24,11 +24,11 @@ base_run_test() {
tot_pass=$((tot_pass + 1))
else
ret="$?"
- if [ "$ret" == "1" ]; then
+ if [ "$ret" -eq 1 ]; then
tot_config=$((tot_config + 1))
- elif [ "$ret" == "2" ]; then
+ elif [ "$ret" -eq 2 ]; then
tot_fail=$((tot_fail + 1))
- elif [ "$ret" == "$VGCODE" ]; then
+ elif [ "$ret" -eq $VGCODE ]; then
tot_vg=$((tot_vg + 1))
else
tot_strange=$((tot_strange + 1))
@@ -36,6 +36,20 @@ base_run_test() {
fi
}
+shorten_echo () {
+ limit=32
+ echo -n "$1"
+ shift
+ for x; do
+ if [ ${#x} -le $limit ]; then
+ echo -n " $x"
+ else
+ short=$(echo "$x" | head -c$limit)
+ echo -n " \"$short\"...<${#x} bytes>"
+ fi
+ done
+}
+
run_test () {
echo -n "$@: "
if [ -n "$VALGRIND" -a -f $1.supp ]; then
@@ -70,6 +84,28 @@ run_wrap_test () {
base_run_test wrap_test "$@"
}
+wrap_error () {
+ (
+ if verbose_run "$@"; then
+ FAIL "Expected non-zero return code"
+ else
+ ret="$?"
+ if [ "$ret" -gt 127 ]; then
+ signame=$(kill -l $((ret - 128)))
+ FAIL "Killed by SIG$signame"
+ else
+ PASS
+ fi
+ fi
+ )
+}
+
+run_wrap_error_test () {
+ shorten_echo "$@"
+ echo -n " {!= 0}: "
+ base_run_test wrap_error "$@"
+}
+
run_dtc_test () {
echo -n "dtc $@: "
base_run_test wrap_test $VALGRIND $DTC "$@"
@@ -83,6 +119,21 @@ asm_to_so_test () {
run_wrap_test asm_to_so "$@"
}
+run_fdtget_test () {
+ expect="$1"
+ shift
+ echo -n "fdtget-runtest.sh "$expect" $@: "
+ base_run_test sh fdtget-runtest.sh "$expect" "$@"
+}
+
+run_fdtput_test () {
+ expect="$1"
+ shift
+ shorten_echo fdtput-runtest.sh "$expect" "$@"
+ echo -n ": "
+ base_run_test sh fdtput-runtest.sh "$expect" "$@"
+}
+
tree1_tests () {
TREE=$1
@@ -178,6 +229,10 @@ libfdt_tests () {
run_test rw_tree1
tree1_tests rw_tree1.test.dtb
tree1_tests_rw rw_tree1.test.dtb
+ run_test appendprop1
+ run_test appendprop2 appendprop1.test.dtb
+ run_dtc_test -I dts -O dtb -o appendprop.test.dtb appendprop.dts
+ run_test dtbs_equal_ordered appendprop2.test.dtb appendprop.test.dtb
for basetree in test_tree1.dtb sw_tree1.test.dtb rw_tree1.test.dtb; do
run_test nopulate $basetree
@@ -199,22 +254,21 @@ 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_tree1_dts0.test.dtb test_tree1_dts0.dts
- tree1_tests dtc_tree1_dts0.test.dtb
- tree1_tests_rw dtc_tree1_dts0.test.dtb
-
run_dtc_test -I dts -O dtb -o dtc_escapes.test.dtb escapes.dts
run_test string_escapes dtc_escapes.test.dtb
+ run_dtc_test -I dts -O dtb -o dtc_char_literal.test.dtb char_literal.dts
+ run_test char_literal dtc_char_literal.test.dtb
+
+ run_dtc_test -I dts -O dtb -o dtc_sized_cells.test.dtb sized_cells.dts
+ run_test sized_cells dtc_sized_cells.test.dtb
+
run_dtc_test -I dts -O dtb -o dtc_extra-terminating-null.test.dtb extra-terminating-null.dts
run_test extra-terminating-null dtc_extra-terminating-null.test.dtb
run_dtc_test -I dts -O dtb -o dtc_references.test.dtb references.dts
run_test references dtc_references.test.dtb
- run_dtc_test -I dts -O dtb -o dtc_references_dts0.test.dtb references_dts0.dts
- run_test references dtc_references_dts0.test.dtb
-
run_dtc_test -I dts -O dtb -o dtc_path-references.test.dtb path-references.dts
run_test path-references dtc_path-references.test.dtb
@@ -224,6 +278,11 @@ dtc_tests () {
run_test phandle_format dtc_references.test.$f.dtb $f
done
+ run_dtc_test -I dts -O dtb -o multilabel.test.dtb multilabel.dts
+ run_test references multilabel.test.dtb
+
+ run_dtc_test -I dts -O dtb -o label_repeated.test.dtb label_repeated.dts
+
run_dtc_test -I dts -O dtb -o dtc_comments.test.dtb comments.dts
run_dtc_test -I dts -O dtb -o dtc_comments-cmp.test.dtb comments-cmp.dts
run_test dtbs_equal_ordered dtc_comments.test.dtb dtc_comments-cmp.test.dtb
@@ -242,12 +301,26 @@ dtc_tests () {
run_test incbin incbin.test.dtb
# Check boot_cpuid_phys handling
- run_dtc_test -I dts -O dtb -b 17 -o boot_cpuid.test.dtb empty.dts
- run_test boot-cpuid boot_cpuid.test.dtb 17
- run_dtc_test -I dtb -O dtb -b 17 -o boot_cpuid_test_tree1.test.dtb test_tree1.dtb
- run_test boot-cpuid boot_cpuid_test_tree1.test.dtb 17
- run_dtc_test -I dtb -O dtb -o boot_cpuid_preserved_test_tree1.test.dtb boot_cpuid_test_tree1.test.dtb
- run_test dtbs_equal_ordered boot_cpuid_preserved_test_tree1.test.dtb boot_cpuid_test_tree1.test.dtb
+ run_dtc_test -I dts -O dtb -o boot_cpuid.test.dtb boot-cpuid.dts
+ run_test boot-cpuid boot_cpuid.test.dtb 16
+
+ run_dtc_test -I dts -O dtb -b 17 -o boot_cpuid_17.test.dtb boot-cpuid.dts
+ run_test boot-cpuid boot_cpuid_17.test.dtb 17
+
+ run_dtc_test -I dtb -O dtb -o preserve_boot_cpuid.test.dtb boot_cpuid.test.dtb
+ run_test boot-cpuid preserve_boot_cpuid.test.dtb 16
+ run_test dtbs_equal_ordered preserve_boot_cpuid.test.dtb boot_cpuid.test.dtb
+
+ run_dtc_test -I dtb -O dtb -o preserve_boot_cpuid_17.test.dtb boot_cpuid_17.test.dtb
+ run_test boot-cpuid preserve_boot_cpuid_17.test.dtb 17
+ run_test dtbs_equal_ordered preserve_boot_cpuid_17.test.dtb boot_cpuid_17.test.dtb
+
+ run_dtc_test -I dtb -O dtb -b17 -o override17_boot_cpuid.test.dtb boot_cpuid.test.dtb
+ run_test boot-cpuid override17_boot_cpuid.test.dtb 17
+
+ run_dtc_test -I dtb -O dtb -b0 -o override0_boot_cpuid_17.test.dtb boot_cpuid_17.test.dtb
+ run_test boot-cpuid override0_boot_cpuid_17.test.dtb 0
+
# Check -Oasm mode
for tree in test_tree1.dts escapes.dts references.dts path-references.dts \
@@ -283,6 +356,17 @@ dtc_tests () {
done
done
+ # Check merge/overlay functionality
+ run_dtc_test -I dts -O dtb -o dtc_tree1_merge.test.dtb test_tree1_merge.dts
+ tree1_tests dtc_tree1_merge.test.dtb test_tree1.dtb
+ run_dtc_test -I dts -O dtb -o dtc_tree1_merge_labelled.test.dtb test_tree1_merge_labelled.dts
+ tree1_tests dtc_tree1_merge_labelled.test.dtb test_tree1.dtb
+ run_dtc_test -I dts -O dtb -o multilabel_merge.test.dtb multilabel_merge.dts
+ run_test references multilabel.test.dtb
+ run_test dtbs_equal_ordered multilabel.test.dtb multilabel_merge.test.dtb
+ 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 some checks
check_tests dup-nodename.dts duplicate_node_names
check_tests dup-propname.dts duplicate_property_names
@@ -291,6 +375,7 @@ dtc_tests () {
check_tests minusone-phandle.dts explicit_phandles
run_sh_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-node-ref.dts
run_sh_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-label-ref.dts
+ run_sh_test dtc-fatal.sh -I dts -O dtb nonexist-node-ref2.dts
check_tests bad-name-property.dts name_properties
check_tests bad-ncells.dts address_cells_is_cell size_cells_is_cell interrupt_cells_is_cell
@@ -304,16 +389,184 @@ dtc_tests () {
run_sh_test dtc-checkfails.sh node_name_format -- -I dtb -O dtb bad_node_format.dtb
run_sh_test dtc-checkfails.sh prop_name_chars -- -I dtb -O dtb bad_prop_char.dtb
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label1.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label2.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label3.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label4.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label5.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label6.dts
+
+ # Check warning options
+ run_sh_test dtc-checkfails.sh address_cells_is_cell interrupt_cells_is_cell -n size_cells_is_cell -- -Wno_size_cells_is_cell -I dts -O dtb bad-ncells.dts
+ run_sh_test dtc-fails.sh -n test-warn-output.test.dtb -I dts -O dtb bad-ncells.dts
+ run_sh_test dtc-fails.sh test-error-output.test.dtb -I dts -O dtb bad-ncells.dts -Esize_cells_is_cell
+ run_sh_test dtc-checkfails.sh always_fail -- -Walways_fail -I dts -O dtb test_tree1.dts
+ run_sh_test dtc-checkfails.sh -n always_fail -- -Walways_fail -Wno_always_fail -I dts -O dtb test_tree1.dts
+ run_sh_test dtc-fails.sh test-negation-1.test.dtb -Ealways_fail -I dts -O dtb test_tree1.dts
+ run_sh_test dtc-fails.sh -n test-negation-2.test.dtb -Ealways_fail -Eno_always_fail -I dts -O dtb test_tree1.dts
+ run_sh_test dtc-fails.sh test-negation-3.test.dtb -Ealways_fail -Wno_always_fail -I dts -O dtb test_tree1.dts
+ run_sh_test dtc-fails.sh -n test-negation-4.test.dtb -Esize_cells_is_cell -Eno_size_cells_is_cell -I dts -O dtb bad-ncells.dts
+ run_sh_test dtc-checkfails.sh size_cells_is_cell -- -Esize_cells_is_cell -Eno_size_cells_is_cell -I dts -O dtb bad-ncells.dts
+
# Check for proper behaviour reading from stdin
run_dtc_test -I dts -O dtb -o stdin_dtc_tree1.test.dtb - < test_tree1.dts
run_wrap_test cmp stdin_dtc_tree1.test.dtb dtc_tree1.test.dtb
run_dtc_test -I dtb -O dts -o stdin_odts_test_tree1.dtb.test.dts - < test_tree1.dtb
run_wrap_test cmp stdin_odts_test_tree1.dtb.test.dts odts_test_tree1.dtb.test.dts
+ # Check integer expresisons
+ run_test integer-expressions -g integer-expressions.test.dts
+ run_dtc_test -I dts -O dtb -o integer-expressions.test.dtb integer-expressions.test.dts
+ run_test integer-expressions integer-expressions.test.dtb
+
# Check for graceful failure in some error conditions
run_sh_test dtc-fatal.sh -I dts -O dtb nosuchfile.dts
run_sh_test dtc-fatal.sh -I dtb -O dtb nosuchfile.dtb
run_sh_test dtc-fatal.sh -I fs -O dtb nosuchfile
+
+ # Dependencies
+ run_dtc_test -I dts -O dtb -o dependencies.test.dtb -d dependencies.test.d dependencies.dts
+ run_wrap_test cmp dependencies.test.d dependencies.cmp
+
+ # Search paths
+ run_wrap_error_test $DTC -I dts -O dtb -o search_paths.dtb search_paths.dts
+ run_dtc_test -i search_dir -I dts -O dtb -o search_paths.dtb \
+ search_paths.dts
+ run_wrap_error_test $DTC -i search_dir_b -I dts -O dtb \
+ -o search_paths_b.dtb search_paths_b.dts
+ run_dtc_test -i search_dir_b -i search_dir -I dts -O dtb \
+ -o search_paths_b.dtb search_paths_b.dts
+ run_dtc_test -I dts -O dtb -o search_paths_subdir.dtb \
+ search_dir_b/search_paths_subdir.dts
+}
+
+cmp_tests () {
+ basetree="$1"
+ shift
+ wrongtrees="$@"
+
+ run_test dtb_reverse $basetree
+
+ # First dtbs_equal_ordered
+ run_test dtbs_equal_ordered $basetree $basetree
+ run_test dtbs_equal_ordered -n $basetree $basetree.reversed.test.dtb
+ for tree in $wrongtrees; do
+ run_test dtbs_equal_ordered -n $basetree $tree
+ done
+
+ # now unordered
+ run_test dtbs_equal_unordered $basetree $basetree
+ run_test dtbs_equal_unordered $basetree $basetree.reversed.test.dtb
+ run_test dtbs_equal_unordered $basetree.reversed.test.dtb $basetree
+ for tree in $wrongtrees; do
+ run_test dtbs_equal_unordered -n $basetree $tree
+ done
+
+ # now dtc --sort
+ run_dtc_test -I dtb -O dtb -s -o $basetree.sorted.test.dtb $basetree
+ run_test dtbs_equal_unordered $basetree $basetree.sorted.test.dtb
+ run_dtc_test -I dtb -O dtb -s -o $basetree.reversed.sorted.test.dtb $basetree.reversed.test.dtb
+ run_test dtbs_equal_unordered $basetree.reversed.test.dtb $basetree.reversed.sorted.test.dtb
+ run_test dtbs_equal_ordered $basetree.sorted.test.dtb $basetree.reversed.sorted.test.dtb
+}
+
+dtbs_equal_tests () {
+ WRONG_TREE1=""
+ for x in 1 2 3 4 5 6 7 8 9; do
+ run_dtc_test -I dts -O dtb -o test_tree1_wrong$x.test.dtb test_tree1_wrong$x.dts
+ WRONG_TREE1="$WRONG_TREE1 test_tree1_wrong$x.test.dtb"
+ done
+ cmp_tests test_tree1.dtb $WRONG_TREE1
+}
+
+fdtget_tests () {
+ dts=label01.dts
+ dtb=$dts.fdtget.test.dtb
+ run_dtc_test -O dtb -o $dtb $dts
+
+ # run_fdtget_test <expected-result> [<flags>] <file> <node> <property>
+ run_fdtget_test "MyBoardName" $dtb / model
+ 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
+ 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
+ run_fdtget_test "61 62 63 0" -tbx $dtb /randomnode tricky1
+ run_fdtget_test "a b c d de ea ad be ef" -tbx $dtb /randomnode blob
+
+ # Here the property size is not a multiple of 4 bytes, so it should fail
+ run_wrap_error_test $DTGET -tlx $dtb /randomnode mixed
+ run_fdtget_test "6162 6300 1234 0 a 0 b 0 c" -thx $dtb /randomnode mixed
+ run_fdtget_test "61 62 63 0 12 34 0 0 0 a 0 0 0 b 0 0 0 c" \
+ -thhx $dtb /randomnode mixed
+ run_wrap_error_test $DTGET -ts $dtb /randomnode doctor-who
+
+ # Test multiple arguments
+ run_fdtget_test "MyBoardName\nmemory" -ts $dtb / model /memory device_type
+
+ # Test defaults
+ run_wrap_error_test $DTGET -tx $dtb /randomnode doctor-who
+ run_fdtget_test "<the dead silence>" -tx \
+ -d "<the dead silence>" $dtb /randomnode doctor-who
+ run_fdtget_test "<blink>" -tx -d "<blink>" $dtb /memory doctor-who
+}
+
+fdtput_tests () {
+ dts=label01.dts
+ dtb=$dts.fdtput.test.dtb
+ text=lorem.txt
+
+ # Allow just enough space for $text
+ run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+
+ # run_fdtput_test <expected-result> <file> <node> <property> <flags> <value>
+ run_fdtput_test "a_model" $dtb / model -ts "a_model"
+ run_fdtput_test "board1 board2" $dtb / compatible -ts board1 board2
+ run_fdtput_test "board1 board2" $dtb / compatible -ts "board1 board2"
+ run_fdtput_test "32768" $dtb /cpus/PowerPC,970@1 d-cache-size "" "32768"
+ run_fdtput_test "8001" $dtb /cpus/PowerPC,970@1 d-cache-size -tx 0x8001
+ run_fdtput_test "2 3 12" $dtb /randomnode tricky1 -tbi "02 003 12"
+ run_fdtput_test "a b c ea ad be ef" $dtb /randomnode blob \
+ -tbx "a b c ea ad be ef"
+ run_fdtput_test "a0b0c0d deeaae ef000000" $dtb /randomnode blob \
+ -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)"
+
+ # Start again with a fresh dtb
+ run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+
+ # Node creation
+ run_wrap_error_test $DTPUT $dtb -c /baldrick sod
+ run_wrap_test $DTPUT $dtb -c /chosen/son /chosen/daughter
+ run_fdtput_test "eva" $dtb /chosen/daughter name "" -ts "eva"
+ run_fdtput_test "adam" $dtb /chosen/son name "" -ts "adam"
+
+ # Not allowed to create an existing node
+ run_wrap_error_test $DTPUT $dtb -c /chosen
+ run_wrap_error_test $DTPUT $dtb -c /chosen/son
+
+ # Automatic node creation
+ run_wrap_test $DTPUT $dtb -cp /blackadder/the-second/turnip \
+ /blackadder/the-second/potato
+ run_fdtput_test 1000 $dtb /blackadder/the-second/turnip cost "" 1000
+ 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"
+
+ # Allowed to create an existing node with -p
+ run_wrap_test $DTPUT $dtb -cp /chosen
+ run_wrap_test $DTPUT $dtb -cp /chosen/son
+
+ # TODO: Add tests for verbose mode?
+}
+
+utilfdt_tests () {
+ run_test utilfdt_test
}
while getopts "vt:m" ARG ; do
@@ -331,7 +584,7 @@ while getopts "vt:m" ARG ; do
done
if [ -z "$TESTSETS" ]; then
- TESTSETS="libfdt dtc"
+ TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput"
fi
# Make sure we don't have stale blobs lying around
@@ -342,9 +595,21 @@ for set in $TESTSETS; do
"libfdt")
libfdt_tests
;;
+ "utilfdt")
+ utilfdt_tests
+ ;;
"dtc")
dtc_tests
;;
+ "dtbs_equal")
+ dtbs_equal_tests
+ ;;
+ "fdtget")
+ fdtget_tests
+ ;;
+ "fdtput")
+ fdtput_tests
+ ;;
esac
done
diff --git a/tests/rw_tree1.c b/tests/rw_tree1.c
index f0bce88bda0b..103a24d7769f 100644
--- a/tests/rw_tree1.c
+++ b/tests/rw_tree1.c
@@ -57,23 +57,14 @@ int main(int argc, char *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_create_empty_tree(fdt, SPACE));
CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_1, TEST_SIZE_1));
CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_2, TEST_SIZE_2));
CHECK(fdt_setprop_string(fdt, 0, "compatible", "test_tree1"));
- CHECK(fdt_setprop_cell(fdt, 0, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_setprop_u32(fdt, 0, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_setprop_u64(fdt, 0, "prop-int64", TEST_VALUE64_1));
CHECK(fdt_setprop_string(fdt, 0, "prop-str", TEST_STRING_1));
OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@1"));
diff --git a/tests/setprop.c b/tests/setprop.c
index 386b87b408b6..9f2bc883b25e 100644
--- a/tests/setprop.c
+++ b/tests/setprop.c
@@ -74,5 +74,23 @@ int main(int argc, char *argv[])
check_getprop(fdt, 0, "prop-str", 0, NULL);
+ err = fdt_setprop_u32(fdt, 0, "prop-u32", TEST_VALUE_2);
+ if (err)
+ FAIL("Failed to set \"prop-u32\" to 0x%08x: %s",
+ TEST_VALUE_2, fdt_strerror(err));
+ check_getprop_cell(fdt, 0, "prop-u32", TEST_VALUE_2);
+
+ err = fdt_setprop_cell(fdt, 0, "prop-cell", TEST_VALUE_2);
+ if (err)
+ FAIL("Failed to set \"prop-cell\" to 0x%08x: %s",
+ TEST_VALUE_2, fdt_strerror(err));
+ check_getprop_cell(fdt, 0, "prop-cell", TEST_VALUE_2);
+
+ err = fdt_setprop_u64(fdt, 0, "prop-u64", TEST_VALUE64_1);
+ if (err)
+ FAIL("Failed to set \"prop-u64\" to 0x%016llx: %s",
+ TEST_VALUE64_1, fdt_strerror(err));
+ check_getprop_64(fdt, 0, "prop-u64", TEST_VALUE64_1);
+
PASS();
}
diff --git a/tests/setprop_inplace.c b/tests/setprop_inplace.c
index aa0cd9694df2..82d895138d5d 100644
--- a/tests/setprop_inplace.c
+++ b/tests/setprop_inplace.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -34,6 +35,7 @@ int main(int argc, char *argv[])
{
void *fdt;
const uint32_t *intp;
+ const uint64_t *int64p;
const char *strp;
char *xstr;
int xlen, i;
@@ -47,7 +49,7 @@ int main(int argc, char *argv[])
verbose_printf("Old int value was 0x%08x\n", *intp);
err = fdt_setprop_inplace_cell(fdt, 0, "prop-int", ~TEST_VALUE_1);
if (err)
- FAIL("Failed to set \"prop-int\" to 0x08%x: %s",
+ FAIL("Failed to set \"prop-int\" to 0x%08x: %s",
~TEST_VALUE_1, fdt_strerror(err));
intp = check_getprop_cell(fdt, 0, "prop-int", ~TEST_VALUE_1);
verbose_printf("New int value is 0x%08x\n", *intp);
@@ -55,6 +57,20 @@ int main(int argc, char *argv[])
strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1,
TEST_STRING_1);
+
+ int64p = check_getprop_64(fdt, 0, "prop-int64", TEST_VALUE64_1);
+
+ verbose_printf("Old int64 value was 0x%016" PRIx64 "\n", *int64p);
+ err = fdt_setprop_inplace_u64(fdt, 0, "prop-int64", ~TEST_VALUE64_1);
+ if (err)
+ FAIL("Failed to set \"prop-int64\" to 0x%016llx: %s",
+ ~TEST_VALUE64_1, fdt_strerror(err));
+ int64p = check_getprop_64(fdt, 0, "prop-int64", ~TEST_VALUE64_1);
+ verbose_printf("New int64 value is 0x%016" PRIx64 "\n", *int64p);
+
+ 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);
diff --git a/tests/subnode_offset.c b/tests/subnode_offset.c
index b961070905d6..e58c192f7ab1 100644
--- a/tests/subnode_offset.c
+++ b/tests/subnode_offset.c
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
void *fdt;
int subnode1_offset, subnode2_offset;
int subsubnode1_offset, subsubnode2_offset, subsubnode2_offset2;
- int ss11_off, ss12_off, ss21_off, ss22_off;
+ int ss12_off, ss21_off;
test_init(argc, argv);
fdt = load_blob_arg(argc, argv);
@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
if (subsubnode2_offset != subsubnode2_offset2)
FAIL("Different offsets with and without unit address");
- ss11_off = check_subnode(fdt, subnode1_offset, "ss1");
+ check_subnode(fdt, subnode1_offset, "ss1");
ss21_off = fdt_subnode_offset(fdt, subnode2_offset, "ss1");
if (ss21_off != -FDT_ERR_NOTFOUND)
FAIL("Incorrectly found ss1 in subnode2");
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
ss12_off = fdt_subnode_offset(fdt, subnode1_offset, "ss2");
if (ss12_off != -FDT_ERR_NOTFOUND)
FAIL("Incorrectly found ss2 in subnode1");
- ss22_off = check_subnode(fdt, subnode2_offset, "ss2");
+ check_subnode(fdt, subnode2_offset, "ss2");
PASS();
}
diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c
index f2c430ab38ca..5c71414692a5 100644
--- a/tests/sw_tree1.c
+++ b/tests/sw_tree1.c
@@ -55,7 +55,8 @@ int main(int argc, char *argv[])
CHECK(fdt_begin_node(fdt, ""));
CHECK(fdt_property_string(fdt, "compatible", "test_tree1"));
- CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
+ 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_begin_node(fdt, "subnode@1"));
diff --git a/tests/test_tree1.dts b/tests/test_tree1.dts
index 218c38206314..cf530ce4ba01 100644
--- a/tests/test_tree1.dts
+++ b/tests/test_tree1.dts
@@ -6,6 +6,7 @@
/ {
compatible = "test_tree1";
prop-int = <0xdeadbeef>;
+ prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>;
prop-str = "hello world";
subnode@1 {
@@ -25,7 +26,7 @@
linux,phandle = <0x2000>;
prop-int = <123456789>;
- subsubnode@0 {
+ ssn0: subsubnode@0 {
phandle = <0x2001>;
compatible = "subsubnode2", "subsubnode";
prop-int = <0726746425>;
diff --git a/tests/testdata.h b/tests/testdata.h
index 5b5a9a3b37ea..ce715e4c679e 100644
--- a/tests/testdata.h
+++ b/tests/testdata.h
@@ -12,6 +12,8 @@
#define TEST_VALUE_1 0xdeadbeef
#define TEST_VALUE_2 123456789
+#define TEST_VALUE64_1 ASM_CONST_LL(0xdeadbeef01abcdef)
+
#define PHANDLE_1 0x2000
#define PHANDLE_2 0x2001
@@ -19,6 +21,12 @@
#define TEST_STRING_2 "nastystring: \a\b\t\n\v\f\r\\\""
#define TEST_STRING_3 "\xde\xad\xbe\xef"
+#define TEST_CHAR1 '\r'
+#define TEST_CHAR2 'b'
+#define TEST_CHAR3 '\0'
+#define TEST_CHAR4 '\''
+#define TEST_CHAR5 '\xff'
+
#ifndef __ASSEMBLY__
extern struct fdt_header _test_tree1;
extern struct fdt_header _truncated_property;
diff --git a/tests/tests.h b/tests/tests.h
index fcb2b2af6763..56a843cd25d8 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -93,22 +93,6 @@ void cleanup(void);
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_mem_rsv(void *fdt, int n, uint64_t addr, uint64_t size);
void check_property(void *fdt, int nodeoffset, const char *name,
@@ -127,6 +111,11 @@ const void *check_getprop(void *fdt, int nodeoffset, const char *name,
uint32_t x = cpu_to_fdt32(val); \
check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
})
+#define check_getprop_64(fdt, nodeoffset, name, val) \
+ ({ \
+ uint64_t x = cpu_to_fdt64(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))
int nodename_eq(const char *s1, const char *s2);
@@ -135,4 +124,6 @@ void *load_blob_arg(int argc, char *argv[]);
void save_blob(const char *filename, void *blob);
void *open_blob_rw(void *blob);
+#include "util.h"
+
#endif /* _TESTS_H */
diff --git a/tests/tests.sh b/tests/tests.sh
index 30ffead41eab..31530d5e228f 100755
--- a/tests/tests.sh
+++ b/tests/tests.sh
@@ -10,7 +10,17 @@ FAIL () {
exit 2
}
+FAIL_IF_SIGNAL () {
+ ret="$1"
+ if [ "$ret" -gt 127 ]; then
+ signame=$(kill -l $((ret - 128)))
+ FAIL "Killed by SIG$signame"
+ fi
+}
+
DTC=../dtc
+DTGET=../fdtget
+DTPUT=../fdtput
verbose_run () {
if [ -z "$QUIET_TEST" ]; then
@@ -20,6 +30,15 @@ verbose_run () {
fi
}
+verbose_run_check () {
+ verbose_run "$@"
+ ret="$?"
+ FAIL_IF_SIGNAL $ret
+ if [ $ret != 0 ]; then
+ FAIL "Returned error code $ret"
+ fi
+}
+
verbose_run_log () {
LOG="$1"
shift
@@ -30,3 +49,13 @@ verbose_run_log () {
fi
return $ret
}
+
+verbose_run_log_check () {
+ verbose_run_log "$@"
+ ret="$?"
+ FAIL_IF_SIGNAL $ret
+ if [ $ret != 0 ]; then
+ FAIL "Returned error code $ret"
+ fi
+}
+
diff --git a/tests/testutils.c b/tests/testutils.c
index b0a22304cf2d..f185133a82b5 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -159,33 +159,13 @@ int nodename_eq(const char *s1, const char *s2)
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);
+ char *blob;
+ int ret = utilfdt_read_err(filename, &blob);
- return p;
+ if (ret)
+ CONFIG("Couldn't open blob from \"%s\": %s", filename,
+ strerror(ret));
+ return blob;
}
void *load_blob_arg(int argc, char *argv[])
@@ -197,28 +177,11 @@ void *load_blob_arg(int argc, char *argv[])
void save_blob(const char *filename, void *fdt)
{
- int fd;
- int totalsize;
- int offset;
- char *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;
- }
+ int ret = utilfdt_write_err(filename, fdt);
+
+ if (ret)
+ CONFIG("Couldn't write blob to \"%s\": %s", filename,
+ strerror(ret));
}
void *open_blob_rw(void *blob)
diff --git a/tests/trees.S b/tests/trees.S
index 66adf3f7464d..cae018760e58 100644
--- a/tests/trees.S
+++ b/tests/trees.S
@@ -52,6 +52,10 @@ tree##_rsvmap_end: ;
PROPHDR(tree, name, 4) \
FDTLONG(val) ;
+#define PROP_INT64(tree, name, val) \
+ PROPHDR(tree, name, 8) \
+ FDTQUAD(val) ;
+
#define PROP_STR(tree, name, str) \
PROPHDR(tree, name, 55f - 54f) \
54: \
@@ -86,6 +90,7 @@ test_tree1_struct:
BEGIN_NODE("")
PROP_STR(test_tree1, compatible, "test_tree1")
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)
BEGIN_NODE("subnode@1")
@@ -124,6 +129,7 @@ test_tree1_struct_end:
test_tree1_strings:
STRING(test_tree1, compatible, "compatible")
STRING(test_tree1, prop_int, "prop-int")
+ STRING(test_tree1, prop_int64, "prop-int64")
STRING(test_tree1, prop_str, "prop-str")
STRING(test_tree1, linux_phandle, "linux,phandle")
STRING(test_tree1, phandle, "phandle")
diff --git a/tests/value-labels.c b/tests/value-labels.c
index c5aea8f7833d..abe272164927 100644
--- a/tests/value-labels.c
+++ b/tests/value-labels.c
@@ -59,8 +59,8 @@ struct val_label labels3[] = {
{ "end3", -1 },
};
-void check_prop_labels(void *sohandle, void *fdt, const char *name,
- const struct val_label* labels, int n)
+static void check_prop_labels(void *sohandle, void *fdt, const char *name,
+ const struct val_label* labels, int n)
{
const struct fdt_property *prop;
const char *p;