Cleanup; the test driver is now way more robust.
This commit is contained in:
parent
581fa4a457
commit
edfee33576
2 changed files with 14 additions and 19 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue