aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore/testsuite/test.sh
blob: 5718e84a15f295ebaf6b301b8139046d1c3e527d (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/sh

set -e
set -m

run_test()
{
    rm -rf $XENSTORED_ROOTDIR
    mkdir $XENSTORED_ROOTDIR
# Weird failures with this.
    if type valgrind >/dev/null 2>&1; then
	valgrind -q --logfile-fd=3 ./xenstored_test --output-pid --no-fork 3>testsuite/tmp/vgout > /tmp/pid &
	while [ ! -s /tmp/pid ]; do sleep 0; done
	PID=`cat /tmp/pid`
	rm /tmp/pid
    else
	PID=`./xenstored_test --output-pid`
    fi
    if sh -e $2 $1; then
	if [ -s testsuite/tmp/vgout ]; then
	    kill $PID
	    echo VALGRIND errors:
	    cat testsuite/tmp/vgout
	    return 1
	fi
	echo shutdown | ./xs_test
	return 0
    else
	# In case daemon is wedged.
	kill $PID
	sleep 1
	return 1
    fi
}

for f in testsuite/[0-9]*.sh; do
    if run_test $f; then
	echo Test $f passed...
    else
	echo Test $f failed, running verbosely...
	run_test $f -x
	exit 1
    fi
done