ack/tests/plat/testdriver.sh
George Koehler 96e23b3a0f Show tests that @@TIMEDOUT.
A `set -e` in testdriver.sh caused it to exit early and hide the
output of a @@TIMEDOUT test, so I never saw the @@TIMEDOUT marker.
Then build.lua added a @@FAIL marker.
2017-11-08 14:08:43 -05:00

58 lines
1.4 KiB
Bash
Executable file

#!/bin/sh
method=$1
img=$2
timeout=$3
timeoutprog=$4
errcho() {
>&2 echo "$*"
}
get_test_output() {
case $method in
qemu-system-*)
if ! command -v $method >/dev/null 2>&1 ; then
errcho "Warning: $method not installed, skipping test"
echo "@@SKIPPED"
exit 0
fi
case $method in
qemu-system-i386) img="-drive file=$img,if=floppy,format=raw" ;;
qemu-system-ppc) img="-kernel $img" ;;
esac
$timeoutprog -t $timeout -- $method -nographic $img 2>&1
;;
qemu-*)
if ! command -v $method >/dev/null 2>&1 ; then
errcho "Warning: $method not installed, skipping test"
echo "@@SKIPPED"
exit 0
fi
$method $img 2>&1
;;
*)
errcho "Error: $method not known by testdriver"
exit 1
;;
esac
}
# Hide output if the test passed.
# Show output if it failed, skipped, or timed out.
get_test_output | awk '
{ lines[count++] = $0 }
/@@FAIL|@@SKIPPED|@@TIMEDOUT/ { bad = 1 }
/@@FINISHED/ { finished = 1 }
END {
if (finished && !bad) exit 0
for (i = 0; i < count; i++) print lines[i]
if (!bad) print "@@FAIL by testdriver.sh"
exit 1
}
'