1#! /bin/sh
2
3# Run script for fdtoverlay tests
4# We run fdtoverlay to generate a target device tree, then fdtget to check it
5
6# Usage
7#    fdtoverlay-runtest.sh name expected_output dtb_file node property flags value
8
9SRCDIR=`dirname "$0"`
10. "$SRCDIR/testutils.sh"
11
12LOG=tmp.log.$$
13EXPECT=tmp.expect.$$
14rm -f $LOG $EXPECT
15trap "rm -f $LOG $EXPECT" 0
16
17expect="$1"
18echo $expect >$EXPECT
19node="$2"
20property="$3"
21flags="$4"
22basedtb="$5"
23targetdtb="$6"
24shift 6
25overlays="$@"
26
27# First run fdtoverlay
28verbose_run_check $VALGRIND "$FDTOVERLAY" -i "$basedtb" -o "$targetdtb" $overlays
29
30# Now fdtget to read the value
31verbose_run_log_check "$LOG" $VALGRIND "$DTGET" "$targetdtb" "$node" "$property" $flags
32
33if cmp $EXPECT $LOG >/dev/null; then
34    PASS
35else
36    if [ -z "$QUIET_TEST" ]; then
37	echo "EXPECTED :-:"
38	cat $EXPECT
39    fi
40    FAIL "Results differ from expected"
41fi
42