tools/ctdb: Pass memory context for returning nodes in parse_nodestring
[Samba/wip.git] / ctdb / libctdb / test / run.sh
blobad4a28a51f8de719dfa8df293180755725bc59fe
1 #! /bin/sh
3 set -e
5 CTDBD_DIR=/tmp/ctdbd-test
6 VALGRIND="valgrind -q --error-exitcode=111"
8 if [ x"$1" = x--no-valgrind ]; then
9 VALGRIND=""
10 shift
13 if pidof ctdbd > /dev/null; then
14 echo ctdbd already running. Please kill it. >&2
15 exit 1
18 cleanup()
20 killall ctdbd
23 # Default is to run all tests.
24 if [ $# = 0 ]; then
25 set tests/*
28 # Build ctdb, and build ctdb-test
29 make --quiet -C ../..
30 echo Building ctdb-test...
31 make --quiet
33 rm -rf $CTDBD_DIR
34 mkdir -p $CTDBD_DIR $CTDBD_DIR/dbs $CTDBD_DIR/dbs/persistent $CTDBD_DIR/dbs/state $CTDBD_DIR/event.d
36 if lsmod | grep -q dummy; then
38 else
39 echo Installing dummy0 network module...
40 sudo modprobe dummy
43 echo 10.199.199.1/24 dummy0 > $CTDBD_DIR/addresses
44 cat > $CTDBD_DIR/event.d/01.print <<EOF
45 #! /bin/sh
47 echo "Script invoked with args \$@" >> $CTDBD_DIR/eventscripts.log
48 EOF
49 chmod a+x $CTDBD_DIR/event.d/01.print
51 echo Running ctdbd with logging to $CTDBD_DIR/log...
52 ../../bin/ctdbd --logfile=$CTDBD_DIR/log --public-addresses=$CTDBD_DIR/addresses --dbdir=$CTDBD_DIR/dbs --reclock=$CTDBD_DIR/reclock --dbdir-persistent=$CTDBD_DIR/dbs/persistent --dbdir-state=$CTDBD_DIR/dbs/state --event-script-dir=$CTDBD_DIR/event.d
54 trap cleanup EXIT
56 echo Waiting for ctdbd to be happy...
57 i=0
58 while true; do
59 ../../bin/ctdb status > $CTDBD_DIR/status
60 if ! grep -q UNHEALTHY $CTDBD_DIR/status; then
61 break
63 sleep 1
64 i=`expr $i + 1`
65 if [ $i = 40 ]; then
66 echo ctdbd failed to start: >&2
67 tail -n 20 $CTDBD_DIR/log >&2
68 exit 1
70 done
72 for test; do
73 echo -n Running $test...
74 if $VALGRIND ./ctdb-test --quiet $test > $CTDBD_DIR/test-out 2>&1; then
75 echo success.
76 else
77 echo failure:
78 cat $CTDBD_DIR/test-out
79 exit 1
81 done
83 echo Success!