[Crosstoolchain-logs] [device-tree-compiler] 133/198: Add a basic test for fdtdump
Hector Oron
zumbi at moszumanska.debian.org
Thu Dec 8 17:07:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
zumbi pushed a commit to branch upstream/1.4.x
in repository device-tree-compiler.
commit 76a65b14d1bb10f300f518c11aed231575521c2e
Author: Simon Glass <sjg at chromium.org>
Date: Wed Jun 18 21:24:32 2014 +1000
Add a basic test for fdtdump
We can test fdtdump by comparing its output with the source file that was
compiled by dtc. Add a simple test that should at least catch regressions
in basic functionality.
Signed-off-by: Simon Glass <sjg at chromium.org>
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
Makefile | 1 +
tests/fdtdump-runtest.sh | 30 ++++++++++++++++++++++++++++++
tests/fdtdump.dts | 37 +++++++++++++++++++++++++++++++++++++
tests/run_tests.sh | 31 ++++++++++++++++++++++++++++++-
tests/tests.sh | 1 +
5 files changed, 99 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 86f5ab3..03644dd 100644
--- a/Makefile
+++ b/Makefile
@@ -211,6 +211,7 @@ TESTS_BIN += dtc
TESTS_BIN += convert-dtsv0
TESTS_BIN += fdtput
TESTS_BIN += fdtget
+TESTS_BIN += fdtdump
include tests/Makefile.tests
diff --git a/tests/fdtdump-runtest.sh b/tests/fdtdump-runtest.sh
new file mode 100644
index 0000000..77593cf
--- /dev/null
+++ b/tests/fdtdump-runtest.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+# Arguments:
+# $1 - source file to compile and compare with fdtdump output of the
+# compiled file.
+
+. ./tests.sh
+
+dts="$1"
+dtb="${dts}.dtb"
+out="${dts}.out"
+LOG=tmp.log.$$
+
+files="$dtb $out $LOG"
+
+rm -f $files
+trap "rm -f $files" 0
+
+verbose_run_log_check "$LOG" $VALGRIND $DTC -O dtb $dts -o $dtb
+$FDTDUMP ${dtb} | grep -v "//" >${out}
+
+if diff -w $dts $out >/dev/null; then
+ PASS
+else
+ if [ -z "$QUIET_TEST" ]; then
+ echo "DIFF :-:"
+ diff -u -w $dts $out
+ fi
+ FAIL "Results differ from expected"
+fi
diff --git a/tests/fdtdump.dts b/tests/fdtdump.dts
new file mode 100644
index 0000000..b9d917b
--- /dev/null
+++ b/tests/fdtdump.dts
@@ -0,0 +1,37 @@
+/dts-v1/;
+
+/memreserve/ 0 0xe;
+/ {
+ model = "MyBoardName";
+ compatible = "MyBoardName", "MyBoardFamilyName";
+ #address-cells = <0x00000002>;
+ #size-cells = <0x00000002>;
+ cpus {
+ linux,phandle = <0x00000001>;
+ #address-cells = <0x00000001>;
+ #size-cells = <0x00000000>;
+ PowerPC,970 at 0 {
+ device_type = "cpu";
+ reg = <0x00000000>;
+ linux,boot-cpu;
+ };
+ PowerPC,970 at 1 {
+ device_type = "cpu";
+ reg = <0x00000001>;
+ };
+ };
+ randomnode {
+ string = "foo", "stuff";
+ bytes = [61 62 63 64 65];
+ child {
+ };
+ };
+ memory at 0 {
+ device_type = "memory";
+ reg = <0x00000000 0x00000123 0x00000456 0x87654321>;
+ };
+ chosen {
+ bootargs = "root=/dev/sda2";
+ linux,platform = <0x00000600>;
+ };
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index f205ce6..c6adf21 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -138,6 +138,13 @@ run_fdtput_test () {
base_run_test sh fdtput-runtest.sh "$expect" "$@"
}
+run_fdtdump_test() {
+ file="$1"
+ shorten_echo fdtdump-runtest.sh "$file"
+ echo -n ": "
+ base_run_test sh fdtdump-runtest.sh "$file"
+}
+
tree1_tests () {
TREE=$1
@@ -602,6 +609,25 @@ utilfdt_tests () {
run_test utilfdt_test
}
+fdtdump_tests () {
+ run_fdtdump_test fdtdump.dts
+ return
+
+ local dts=fdtdump.dts
+ local dtb=fdtdump.dts.dtb
+ local out=fdtdump.dts.out
+ run_dtc_test -O dtb $dts -o ${dtb}
+ $FDTDUMP ${dtb} | grep -v "//" >${out}
+ if cmp $dts $out >/dev/null; then
+ PASS
+ else
+ if [ -z "$QUIET_TEST" ]; then
+ diff -w fdtdump.dts $out
+ fi
+ FAIL "Results differ from expected"
+ fi
+}
+
while getopts "vt:me" ARG ; do
case $ARG in
"v")
@@ -620,7 +646,7 @@ while getopts "vt:me" ARG ; do
done
if [ -z "$TESTSETS" ]; then
- TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput"
+ TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump"
fi
# Make sure we don't have stale blobs lying around
@@ -646,6 +672,9 @@ for set in $TESTSETS; do
"fdtput")
fdtput_tests
;;
+ "fdtdump")
+ fdtdump_tests
+ ;;
esac
done
diff --git a/tests/tests.sh b/tests/tests.sh
index 31530d5..818fd09 100644
--- a/tests/tests.sh
+++ b/tests/tests.sh
@@ -21,6 +21,7 @@ FAIL_IF_SIGNAL () {
DTC=../dtc
DTGET=../fdtget
DTPUT=../fdtput
+FDTDUMP=../fdtdump
verbose_run () {
if [ -z "$QUIET_TEST" ]; then
--
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