dtc: Add basic testcases for dtc
This patch adds a handful of simple testcases for dtc. It adds a dts file which should generate the same sample tree as is used for the libfdt testcases, and tests invoking dtc on this dts, plus the standard batch of libfdt cases on the resulting dtb, which effectively checks that the dtb is correct. Because the test framework assumes each testcase is an executable with the right output conventions, we use a little shell script, dtc.sh, as a wrapper around dtc itself. It simply invokes dtc and returns a PASS or FAIL depending on whether dtc returned an error. It's not much, but it's a start. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
committed by
Jon Loeliger
parent
ef90baa0c6
commit
8d59bd3b17
@@ -43,10 +43,10 @@ tests_clean:
|
|||||||
rm -f $(STD_CLEANFILES:%=$(TESTS_PREFIX)%)
|
rm -f $(STD_CLEANFILES:%=$(TESTS_PREFIX)%)
|
||||||
rm -f $(TESTS_CLEANFILES)
|
rm -f $(TESTS_CLEANFILES)
|
||||||
|
|
||||||
check: tests
|
check: tests dtc
|
||||||
cd $(TESTS_PREFIX); ./run_tests.sh
|
cd $(TESTS_PREFIX); ./run_tests.sh
|
||||||
|
|
||||||
checkv: tests
|
checkv: tests dtc
|
||||||
cd $(TESTS_PREFIX); ./run_tests.sh -v
|
cd $(TESTS_PREFIX); ./run_tests.sh -v
|
||||||
|
|
||||||
ifneq ($(DEPTARGETS),)
|
ifneq ($(DEPTARGETS),)
|
||||||
|
|||||||
28
tests/dtc.sh
Executable file
28
tests/dtc.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
PASS () {
|
||||||
|
echo "PASS"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
FAIL () {
|
||||||
|
echo "FAIL" "$@"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
DTC=../dtc
|
||||||
|
|
||||||
|
verbose_run () {
|
||||||
|
if [ -z "$QUIET_TEST" ]; then
|
||||||
|
"$@"
|
||||||
|
else
|
||||||
|
"$@" > /dev/null 2> /dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if verbose_run "$DTC" "$@"; then
|
||||||
|
PASS
|
||||||
|
else
|
||||||
|
ret="$?"
|
||||||
|
FAIL "dtc returned error code $ret"
|
||||||
|
fi
|
||||||
@@ -86,6 +86,14 @@ libfdt_tests () {
|
|||||||
run_test truncated_property
|
run_test truncated_property
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dtc_tests () {
|
||||||
|
# Make sure we don't have stale blobs lying around
|
||||||
|
rm -f *.test.dtb
|
||||||
|
|
||||||
|
run_test dtc.sh -f -I dts -O dtb -o dtc_tree1.test.dtb test_tree1.dts
|
||||||
|
tree1_tests dtc_tree1.test.dtb
|
||||||
|
}
|
||||||
|
|
||||||
while getopts "vdt:" ARG ; do
|
while getopts "vdt:" ARG ; do
|
||||||
case $ARG in
|
case $ARG in
|
||||||
"v")
|
"v")
|
||||||
@@ -98,7 +106,7 @@ while getopts "vdt:" ARG ; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$TESTSETS" ]; then
|
if [ -z "$TESTSETS" ]; then
|
||||||
TESTSETS="libfdt"
|
TESTSETS="libfdt dtc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for set in $TESTSETS; do
|
for set in $TESTSETS; do
|
||||||
@@ -106,6 +114,9 @@ for set in $TESTSETS; do
|
|||||||
"libfdt")
|
"libfdt")
|
||||||
libfdt_tests
|
libfdt_tests
|
||||||
;;
|
;;
|
||||||
|
"dtc")
|
||||||
|
dtc_tests
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
20
tests/test_tree1.dts
Normal file
20
tests/test_tree1.dts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/ {
|
||||||
|
prop-int = <deadbeef>;
|
||||||
|
prop-str = "hello world";
|
||||||
|
|
||||||
|
subnode1 {
|
||||||
|
prop-int = <deadbeef>;
|
||||||
|
|
||||||
|
subsubnode {
|
||||||
|
prop-int = <deadbeef>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
subnode2 {
|
||||||
|
prop-int = <abcd1234>;
|
||||||
|
|
||||||
|
subsubnode {
|
||||||
|
prop-int = <abcd1234>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user