[Skiboot] [PATCH] hdata/test: workaround dtc bugs

Stewart Smith stewart at linux.ibm.com
Mon Nov 26 19:10:40 AEDT 2018


In dtc v1.4.5 to at least v1.4.7 there have been a few bugs introduced
that change the layout of what's produced in the dts. In order to be
immune from them, we should use the (provided) dtdiff utility, but we
also need to run the dts we're diffing against through a dtb cycle in
order to ensure we get the same format as what the hdat_to_dt to dts
conversion will.

This fixes a bunch of unit test failures on the version of dtc shipped
with recent Linux distros such as Fedora 29.

Signed-off-by: Stewart Smith <stewart at linux.ibm.com>
---
 hdata/test/Makefile.check |  8 ++++----
 hdata/test/dtdiff_wrap.sh | 13 +++++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)
 create mode 100755 hdata/test/dtdiff_wrap.sh

diff --git a/hdata/test/Makefile.check b/hdata/test/Makefile.check
index 465d110b9ab2..35524cc33098 100644
--- a/hdata/test/Makefile.check
+++ b/hdata/test/Makefile.check
@@ -21,14 +21,14 @@ hdata/test/hdata_to_dt-check-q: hdata/test/hdata_to_dt
 	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E -s -q hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras, $<)
 
 hdata/test/hdata_to_dt-check-dt: hdata/test/hdata_to_dt
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E hdata/test/p81-811.spira hdata/test/p81-811.spira.heap 2>/dev/null |dtc -I dtb -O dts |diff -u hdata/test/p81-811.spira.dts -, $< device-tree)
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null |dtc -I dtb -O dts |diff -u hdata/test/p8-840-spira.dts -, $< device-tree)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E hdata/test/p81-811.spira hdata/test/p81-811.spira.heap 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p81-811.spira.dts, $< device-tree)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p8-840-spira.dts, $< device-tree)
 
 hdata/test/hdata_to_dt-gcov-run: hdata/test/hdata_to_dt-check-dt-gcov-run
 
 hdata/test/hdata_to_dt-check-dt-gcov-run: hdata/test/hdata_to_dt-gcov
-	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov -8E hdata/test/p81-811.spira hdata/test/p81-811.spira.heap 2>/dev/null |dtc -I dtb -O dts|diff -u hdata/test/p81-811.spira.dts -, $< device-tree)
-	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov -8E -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null |dtc -I dtb -O dts|diff -u hdata/test/p8-840-spira.dts -, $< device-tree)
+	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov -8E hdata/test/p81-811.spira hdata/test/p81-811.spira.heap 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p81-811.spira.dts, $< device-tree)
+	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov -8E -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p8-840-spira.dts, $< device-tree)
 
 hdata/test/stubs.o: hdata/test/stubs.c
 	$(call Q, HOSTCC , $(HOSTCC) $(HOSTCFLAGS) -g -c -o $@ $<, $<)
diff --git a/hdata/test/dtdiff_wrap.sh b/hdata/test/dtdiff_wrap.sh
new file mode 100755
index 000000000000..75c18bafc807
--- /dev/null
+++ b/hdata/test/dtdiff_wrap.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Takes /dev/stdin as dtb, saves to file, does dtdiff
+# Also runs parameter through a dts->dtb->dts conversion
+# in order to work around dtc bugs.
+
+T=$(mktemp)
+cp /dev/stdin $T.dtb
+dtc -I dts -O dtb $1 > $T.orig.dtb
+dtdiff $T.orig.dtb $T.dtb
+R=$?
+if [ $R == 0 ]; then rm -f $T.dtb; fi
+exit $R
-- 
2.19.1



More information about the Skiboot mailing list