1 export EMPIREHOST=127.0.0.1 LOGNAME=tester
3 if [ -x ./config.status ] && ./config.status --version | grep -q '^Wolfpack Empire'
5 else echo "$0: Must be run in root of build tree" >&2; exit 1
12 trap 'if [ "$pid" ]; then kill -9 "$pid" 2>/dev/null || true; fi; [ "$failed" ] && exit 1' EXIT
15 testdir="$srcdir/tests/$test"
16 econfig=sandbox/etc/empire/econfig
17 schedule=sandbox/etc/empire/schedule
18 data=sandbox/var/empire
19 empdump="src/util/empdump -e $econfig"
20 files="src/util/files -e $econfig"
21 fairland="src/util/fairland -e $econfig"
23 empthread=`sed -n 's/empthread *:= *\(.*\)/\1/p' <GNUmakefile`
28 if [ "$warn_empthread" ] && [ "$empthread" != "LWP" ]
30 echo "Warning: test not expected to work with thread package $empthread!" >&2
38 mkdir -p sandbox/etc/empire sandbox/share/empire/builtin $data
41 data "../../var/empire"
42 info "../../../../info.nr"
43 builtin "../../share/empire/builtin"
44 listen_addr "$EMPIREHOST"
49 cp `git ls-files "$srcdir"/src/lib/global | uniq | grep '\.config$'` sandbox/share/empire/builtin
63 "$@" >>sandbox/$name.out 2>>sandbox/$name.err
66 echo $ret >>sandbox/$name.status
71 # date +%s isn't portable...
72 perl -e 'printf "%s\n", time'
77 local pidfile=$data/server.pid
81 # Currently expected to work only with thread package LWP,
84 # - Thread scheduling is reliably deterministic only with LWP
85 # - Shell builtin kill appears not to do the job in MinGW
86 # - The Windows server tries to run as service when -d isn't
88 # - The Windows server does not implement -E crash-dump
90 # TODO address these shortcomings.
95 src/server/emp_server -e $econfig -R 1 -s -E crash-dump
97 until pid=`cat $pidfile 2>/dev/null` && [ -n "$pid" ]
99 if [ `now` -gt $timeout ]
101 echo "Timed out waiting for server to create $pidfile" >&2
105 while src/client/empire red herring 2>&1 | grep -q "Connection refused"
107 if [ `now` -gt $timeout ]
109 echo "Timed out waiting for server to accept connections" >&2
120 while kill -0 "$pid" 2>/dev/null
122 if [ `now` -gt $timeout ]
124 echo "Timed out waiting for server to terminate" >&2
135 sed '/^|/d' "$@" | src/client/empire "$c" "$r" >/dev/null
145 r=`echo $c | sed 's/^POGO$/peter/'`
146 feed_input "$c" "$r" "$i"
152 feed_files `git ls-files "$@" | uniq | grep '/[0-9][0-9]-[^/]*$'`
166 if [ -z "$xd" ] || [ "$#" -ne 0 ]
168 cp -r $data/tel $data/empty.tel
171 then feed_input POGO peter
174 echo 'edit c * ?tgms>0 t 0' | feed_input POGO peter
176 mv $data/tel $data/setup.tel
177 mv $data/empty.tel $data/tel
178 mv $data/news $data/setup.news
180 mv $data/lostitems $data/setup.lostitems
182 mv $data/journal.log $data/setup.journal.log
183 mv $data/server.log $data/setup.server.log
191 $empdump -x >sandbox/final.xdump
200 for j in status out err
208 cmp_out var/empire/server.log var/empire/journal.log final.xdump
222 local i=$1 exp="${2-$testdir/${1##*/}}"
223 local act="sandbox/$i"
224 local nrm="sandbox/normalized-${i##*/}"
230 exp=sandbox/ok.status
231 echo 0 >sandbox/ok.status
234 [ ! -e "$act" ] && return
237 *.status) exp=sandbox/ok.status; echo 0 >sandbox/ok.status ;;
244 perl "$srcdir"/tests/normalize.pl -j "$act" ;;
246 perl "$srcdir"/tests/normalize.pl -s "$act" ;;
248 perl "$srcdir"/tests/normalize.pl "$act" ;;
250 perl -pe 's/\s+$/\n/;' -e "s,\Q$srcdir/tests\E,tests," "$act" ;;
252 perl -pe 's/\s+$/\n/;' "$act" ;;
254 if diff -u "$exp" "$nrm" >"$nrm.diff"
257 elif [ "$EMPIRE_CHECK_ACCEPT" ]