Skip to content

Commit

Permalink
hdata/test: workaround dtc bugs
Browse files Browse the repository at this point in the history
[ Upstream commit b547df6 ]

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@linux.ibm.com>
  • Loading branch information
stewartsmith committed Feb 13, 2019
1 parent 1a90d59 commit cc7945c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hdata/test/Makefile.check
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@ $<, $<)
Expand Down
13 changes: 13 additions & 0 deletions hdata/test/dtdiff_wrap.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cc7945c

Please sign in to comment.