From edfee3357648278f5b476b2fc1d29a2571608940 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 16 Nov 2016 20:50:14 +0100 Subject: [PATCH] Cleanup; the test driver is now way more robust. --- plat/qemuppc/tests/lib/test.c | 6 ++++-- plat/qemuppc/tests/testdriver.sh | 27 ++++++++++----------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/plat/qemuppc/tests/lib/test.c b/plat/qemuppc/tests/lib/test.c index 9da7e8101..02d98773b 100644 --- a/plat/qemuppc/tests/lib/test.c +++ b/plat/qemuppc/tests/lib/test.c @@ -1,5 +1,7 @@ #include "test.h" +/* No CRT in this file (this includes stdio and stdlib!). */ + void finished(void) { static const char s[] = "@@FINISHED\n"; @@ -9,7 +11,7 @@ void finished(void) void writehex(uint32_t code) { char buf[8]; - char* p = &buf[8]; + char* p = &buf[sizeof(buf)]; do { @@ -18,7 +20,7 @@ void writehex(uint32_t code) } while (code > 0); - write(1, p, buf+8-p); + write(1, p, buf + sizeof(buf) - p); } void fail(uint32_t code) diff --git a/plat/qemuppc/tests/testdriver.sh b/plat/qemuppc/tests/testdriver.sh index 84abdab1a..8cce48d1c 100755 --- a/plat/qemuppc/tests/testdriver.sh +++ b/plat/qemuppc/tests/testdriver.sh @@ -3,25 +3,18 @@ qemu=$1 img=$2 timeout=$3 -pipe=/tmp/testdriver.$$.pipe +pipe=/tmp/$$.testdriver.pipe mknod $pipe p -trap "rm $pipe" EXIT +trap "rm -f $pipe" EXIT -timeout $timeout $qemu -nographic -kernel $img >$pipe 2>&1 & -pid=$! +result=/tmp/$$.testdriver.result +trap "rm -f $result" EXIT -status=0 -while read line < $pipe; do - case "$line" in - *@@FAIL*) - echo $line - status=1 - ;; +pidfile=/tmp/$$.testdriver.pid +trap "rm -f $pidfile" EXIT - *@@FINISHED*) - kill $pid - ;; - esac -done +($qemu -nographic -kernel $img 2>&1 & echo $! > $pidfile ) | tee $result | \ + grep -l @@FINISHED | (read dummy && kill $(cat $pidfile)) -exit $status +grep @@FAIL $result && cat $result && exit 1 +exit 0 \ No newline at end of file -- 2.34.1