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"
|
#include "test.h"
|
||||||
|
|
||||||
|
/* No CRT in this file (this includes stdio and stdlib!). */
|
||||||
|
|
||||||
void finished(void)
|
void finished(void)
|
||||||
{
|
{
|
||||||
static const char s[] = "@@FINISHED\n";
|
static const char s[] = "@@FINISHED\n";
|
||||||
|
@ -9,7 +11,7 @@ void finished(void)
|
||||||
void writehex(uint32_t code)
|
void writehex(uint32_t code)
|
||||||
{
|
{
|
||||||
char buf[8];
|
char buf[8];
|
||||||
char* p = &buf[8];
|
char* p = &buf[sizeof(buf)];
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -18,7 +20,7 @@ void writehex(uint32_t code)
|
||||||
}
|
}
|
||||||
while (code > 0);
|
while (code > 0);
|
||||||
|
|
||||||
write(1, p, buf+8-p);
|
write(1, p, buf + sizeof(buf) - p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fail(uint32_t code)
|
void fail(uint32_t code)
|
||||||
|
|
|
@ -3,25 +3,18 @@ qemu=$1
|
||||||
img=$2
|
img=$2
|
||||||
timeout=$3
|
timeout=$3
|
||||||
|
|
||||||
pipe=/tmp/testdriver.$$.pipe
|
pipe=/tmp/$$.testdriver.pipe
|
||||||
mknod $pipe p
|
mknod $pipe p
|
||||||
trap "rm $pipe" EXIT
|
trap "rm -f $pipe" EXIT
|
||||||
|
|
||||||
timeout $timeout $qemu -nographic -kernel $img >$pipe 2>&1 &
|
result=/tmp/$$.testdriver.result
|
||||||
pid=$!
|
trap "rm -f $result" EXIT
|
||||||
|
|
||||||
status=0
|
pidfile=/tmp/$$.testdriver.pid
|
||||||
while read line < $pipe; do
|
trap "rm -f $pidfile" EXIT
|
||||||
case "$line" in
|
|
||||||
*@@FAIL*)
|
|
||||||
echo $line
|
|
||||||
status=1
|
|
||||||
;;
|
|
||||||
|
|
||||||
*@@FINISHED*)
|
($qemu -nographic -kernel $img 2>&1 & echo $! > $pidfile ) | tee $result | \
|
||||||
kill $pid
|
grep -l @@FINISHED | (read dummy && kill $(cat $pidfile))
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
exit $status
|
grep @@FAIL $result && cat $result && exit 1
|
||||||
|
exit 0
|
Loading…
Reference in a new issue