aboutsummaryrefslogtreecommitdiff
path: root/src/tests/utests/run_qemu_test.sh
blob: eb535acb197a62c8e37218925a1c9c7f09e73d02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

BINFILE=$1
LOGFILE=$2
MAPFILE=$3

RESULTFILE=`mktemp`
PIDFILE=`mktemp`

(timeout 10s qemu-system-i386 -kernel build/kernel.bin -append "init=io:/mod/`basename $BINFILE`" \
							  -initrd "$BINFILE,$MAPFILE" -serial stdio -m 16 -display none 2>/dev/null \
	& echo $! >$PIDFILE) \
	| tee >(grep -m 1 "TEST-" >$RESULTFILE; kill -INT `cat $PIDFILE`) >$LOGFILE

RESULT=`cat $RESULTFILE`

rm $RESULTFILE
rm $PIDFILE

if [ "$RESULT" != '[1] (TEST-OK)' ]; then
	echo -e "\033[0;31m$BINFILE $RESULT\033[0m"
	cp $LOGFILE $LOGFILE.err
	exit 1;
else
	echo -e "\033[0;32m$BINFILE $RESULT\033[0m"
fi