[Crosstoolchain-logs] [device-tree-compiler] 141/357: dtc: Add basic testcases for dtc

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:06:07 UTC 2016


This is an automated email from the git hooks/post-receive script.

zumbi pushed a commit to branch upstream/1.3.x
in repository device-tree-compiler.

commit 8d59bd3b17ba04dc9bc906742ebe74e69fb0d1ad
Author: David Gibson <david at gibson.dropbear.id.au>
Date:   Tue Sep 18 10:33:40 2007 +1000

    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 at gibson.dropbear.id.au>
---
 tests/Makefile.tests |  4 ++--
 tests/dtc.sh         | 28 ++++++++++++++++++++++++++++
 tests/run_tests.sh   | 13 ++++++++++++-
 tests/test_tree1.dts | 20 ++++++++++++++++++++
 4 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.tests b/tests/Makefile.tests
index cc034bb..e97e903 100644
--- a/tests/Makefile.tests
+++ b/tests/Makefile.tests
@@ -43,10 +43,10 @@ tests_clean:
 	rm -f $(STD_CLEANFILES:%=$(TESTS_PREFIX)%)
 	rm -f $(TESTS_CLEANFILES)
 
-check:	tests
+check:	tests dtc
 	cd $(TESTS_PREFIX); ./run_tests.sh
 
-checkv:	tests
+checkv:	tests dtc
 	cd $(TESTS_PREFIX); ./run_tests.sh -v
 
 ifneq ($(DEPTARGETS),)
diff --git a/tests/dtc.sh b/tests/dtc.sh
new file mode 100755
index 0000000..f704f55
--- /dev/null
+++ b/tests/dtc.sh
@@ -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
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 3973730..3c64e9d 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -86,6 +86,14 @@ libfdt_tests () {
     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
     case $ARG in
 	"v")
@@ -98,7 +106,7 @@ while getopts "vdt:" ARG ; do
 done
 
 if [ -z "$TESTSETS" ]; then
-    TESTSETS="libfdt"
+    TESTSETS="libfdt dtc"
 fi
 
 for set in $TESTSETS; do
@@ -106,6 +114,9 @@ for set in $TESTSETS; do
 	"libfdt")
 	    libfdt_tests
 	    ;;
+	"dtc")
+	    dtc_tests
+	    ;;
     esac
 done
 
diff --git a/tests/test_tree1.dts b/tests/test_tree1.dts
new file mode 100644
index 0000000..5ddc208
--- /dev/null
+++ b/tests/test_tree1.dts
@@ -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>;
+		};
+	};
+};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list