Browse Source

tests: fdtoverlay unit test

Add an fdtoverlay unit test. Applies applies overlay(s) and then
retrieves an inserted property to verify.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
Pantelis Antoniou 8 years ago committed by David Gibson
parent
commit
e3b9a9588a
  1. 40
      tests/fdtoverlay-runtest.sh
  2. 27
      tests/run_tests.sh
  3. 1
      tests/tests.sh

40
tests/fdtoverlay-runtest.sh

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
#! /bin/sh

# Run script for fdtoverlay tests
# We run fdtoverlay to generate a target device tree, thn fdtget to check it

# Usage
# fdtoverlay-runtest.sh name expected_output dtb_file node property flags value

. ./tests.sh

LOG=tmp.log.$$
EXPECT=tmp.expect.$$
rm -f $LOG $EXPECT
trap "rm -f $LOG $EXPECT" 0

expect="$1"
echo $expect >$EXPECT
node="$2"
property="$3"
flags="$4"
basedtb="$5"
targetdtb="$6"
shift 6
overlays="$@"

# First run fdtoverlay
verbose_run_check $VALGRIND "$FDTOVERLAY" -i "$basedtb" -o "$targetdtb" $overlays

# Now fdtget to read the value
verbose_run_log_check "$LOG" $VALGRIND "$DTGET" "$targetdtb" "$node" "$property" $flags

if cmp $EXPECT $LOG >/dev/null; then
PASS
else
if [ -z "$QUIET_TEST" ]; then
echo "EXPECTED :-:"
cat $EXPECT
fi
FAIL "Results differ from expected"
fi

27
tests/run_tests.sh

@ -160,6 +160,14 @@ run_fdtdump_test() { @@ -160,6 +160,14 @@ run_fdtdump_test() {
base_run_test sh fdtdump-runtest.sh "$file" 2>/dev/null
}

run_fdtoverlay_test() {
expect="$1"
shift
shorten_echo fdtoverlay-runtest.sh "$expect" "$@"
printf ": "
base_run_test sh fdtoverlay-runtest.sh "$expect" "$@"
}

BAD_FIXUP_TREES="bad_index \
empty \
empty_index \
@ -771,6 +779,20 @@ fdtdump_tests () { @@ -771,6 +779,20 @@ fdtdump_tests () {
run_fdtdump_test fdtdump.dts
}

fdtoverlay_tests() {
base=overlay_base.dts
basedtb=overlay_base.fdoverlay.test.dtb
overlay=overlay_overlay_manual_fixups.dts
overlaydtb=overlay_overlay_manual_fixups.fdoverlay.test.dtb
targetdtb=target.fdoverlay.test.dtb

run_dtc_test -@ -I dts -O dtb -o $basedtb $base
run_dtc_test -@ -I dts -O dtb -o $overlaydtb $overlay

# test that the new property is installed
run_fdtoverlay_test foobar "/test-node" "test-str-property" "-ts" ${basedtb} ${targetdtb} ${overlaydtb}
}

pylibfdt_tests () {
TMP=/tmp/tests.stderr.$$
python pylibfdt_tests.py -v 2> $TMP
@ -809,7 +831,7 @@ while getopts "vt:me" ARG ; do @@ -809,7 +831,7 @@ while getopts "vt:me" ARG ; do
done

if [ -z "$TESTSETS" ]; then
TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump"
TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump fdtoverlay"

# Test pylibfdt if the libfdt Python module is available.
if [ -f ../pylibfdt/_libfdt.so ]; then
@ -846,6 +868,9 @@ for set in $TESTSETS; do @@ -846,6 +868,9 @@ for set in $TESTSETS; do
"pylibfdt")
pylibfdt_tests
;;
"fdtoverlay")
fdtoverlay_tests
;;
esac
done


1
tests/tests.sh

@ -22,6 +22,7 @@ DTC=../dtc @@ -22,6 +22,7 @@ DTC=../dtc
DTGET=../fdtget
DTPUT=../fdtput
FDTDUMP=../fdtdump
FDTOVERLAY=../fdtoverlay

verbose_run () {
if [ -z "$QUIET_TEST" ]; then

Loading…
Cancel
Save