platform_external_dtc/tests/tests.sh
David Gibson 15b23d21a6 Clean up invocation of fdt{get,put} tests
This patch cleans up how the fdtget and fdtput tests are invoked.
Specifically we no longer hide the full command lines with a wrapper
function - this makes it possible to distinguish fdtget from similar
fdtput tests and makes it easier to work out how to manually invoke an
individual failing test.

In addition, we remove the testing for errors from the
fdt{get,put}-runtest.sh script, instead using an internal wrapper
analagous to run_wrap_test which can test for any program invocation
that's expected to return an error.

For a couple of the fdtput tests this would result in printing out
ludicrously large command lines.  Therefore we introduce a new
mechanism to cut those down to something reasonable.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03 08:39:50 -06:00

61 lines
880 B
Bash

# Common functions for shell testcases
PASS () {
echo "PASS"
exit 0
}
FAIL () {
echo "FAIL" "$@"
exit 2
}
FAIL_IF_SIGNAL () {
ret="$1"
if [ "$ret" -gt 127 ]; then
signame=$(kill -l $((ret - 128)))
FAIL "Killed by SIG$signame"
fi
}
DTC=../dtc
DTGET=../fdtget
DTPUT=../fdtput
verbose_run () {
if [ -z "$QUIET_TEST" ]; then
"$@"
else
"$@" > /dev/null 2> /dev/null
fi
}
verbose_run_check () {
verbose_run "$@"
ret="$?"
FAIL_IF_SIGNAL $ret
if [ $ret != 0 ]; then
FAIL "Returned error code $ret"
fi
}
verbose_run_log () {
LOG="$1"
shift
"$@" > "$LOG" 2>&1
ret=$?
if [ -z "$QUIET_TEST" ]; then
cat "$LOG" >&2
fi
return $ret
}
verbose_run_log_check () {
verbose_run_log "$@"
ret="$?"
FAIL_IF_SIGNAL $ret
if [ $ret != 0 ]; then
FAIL "Returned error code $ret"
fi
}