2016-11-13 12:37:22 +00:00
|
|
|
#!/bin/sh
|
2016-11-26 10:23:25 +00:00
|
|
|
method=$1
|
2016-11-13 12:37:22 +00:00
|
|
|
img=$2
|
|
|
|
timeout=$3
|
|
|
|
|
2016-11-16 19:50:14 +00:00
|
|
|
pipe=/tmp/$$.testdriver.pipe
|
2016-11-13 12:37:22 +00:00
|
|
|
mknod $pipe p
|
2016-11-16 19:50:14 +00:00
|
|
|
trap "rm -f $pipe" EXIT
|
2016-11-13 12:37:22 +00:00
|
|
|
|
2016-11-16 19:50:14 +00:00
|
|
|
result=/tmp/$$.testdriver.result
|
|
|
|
trap "rm -f $result" EXIT
|
2016-11-13 12:37:22 +00:00
|
|
|
|
2016-11-16 19:50:14 +00:00
|
|
|
pidfile=/tmp/$$.testdriver.pid
|
|
|
|
trap "rm -f $pidfile" EXIT
|
2016-11-13 12:37:22 +00:00
|
|
|
|
2016-11-26 10:23:25 +00:00
|
|
|
case $method in
|
|
|
|
qemu-system-*)
|
2016-11-26 11:53:36 +00:00
|
|
|
if ! command -v $method 2>/dev/null; then
|
2016-11-26 10:23:25 +00:00
|
|
|
echo "Warning: $method not installed, skipping test"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $method in
|
|
|
|
qemu-system-i386) img="-drive file=$img,if=floppy,format=raw" ;;
|
|
|
|
qemu-system-ppc) img="-kernel $img" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
( $method -nographic $img 2>&1 & echo $! > $pidfile ) \
|
|
|
|
| tee $result \
|
|
|
|
| ( timeout $timeout grep -l -q @@FINISHED ; echo ) \
|
|
|
|
| ( read dummy && kill $(cat $pidfile) )
|
|
|
|
|
|
|
|
;;
|
2016-11-26 10:56:17 +00:00
|
|
|
|
|
|
|
qemu-*)
|
2016-11-26 11:53:36 +00:00
|
|
|
if ! command -v $method 2>/dev/null; then
|
2016-11-26 10:56:17 +00:00
|
|
|
echo "Warning: $method not installed, skipping test"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
$method $img > $result
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Error: $method not known by testdriver"
|
|
|
|
exit 1
|
|
|
|
;;
|
2016-11-26 10:23:25 +00:00
|
|
|
esac
|
2016-11-13 12:37:22 +00:00
|
|
|
|
2016-11-17 21:04:50 +00:00
|
|
|
( grep -q @@FAIL $result || ! grep -q @@FINISHED $result ) && cat $result && exit 1
|
2016-11-26 11:53:36 +00:00
|
|
|
exit 0
|