Betterer timeout handling.
authorDavid Given <dg@cowlark.com>
Thu, 17 Nov 2016 21:04:50 +0000 (22:04 +0100)
committerDavid Given <dg@cowlark.com>
Thu, 17 Nov 2016 21:04:50 +0000 (22:04 +0100)
plat/qemuppc/tests/testdriver.sh

index 8cce48d..3424e96 100755 (executable)
@@ -13,8 +13,10 @@ trap "rm -f $result" EXIT
 pidfile=/tmp/$$.testdriver.pid
 trap "rm -f $pidfile" EXIT
 
-($qemu -nographic -kernel $img 2>&1 & echo $! > $pidfile ) | tee $result | \
-    grep -l @@FINISHED | (read dummy && kill $(cat $pidfile))
+( $qemu -nographic -kernel $img 2>&1 & echo $! > $pidfile ) \
+    | tee $result \
+    | ( timeout $timeout grep -l -q @@FINISHED ; echo ) \
+    | ( read dummy && kill $(cat $pidfile) )
 
-grep @@FAIL $result && cat $result && exit 1
+( grep -q @@FAIL $result || ! grep -q @@FINISHED $result ) && cat $result && exit 1
 exit 0
\ No newline at end of file