2 # Smoke test for Empire
5 then echo "Usage: $0 SRCDIR" >&2; exit 1
10 export EMPIREHOST=127.0.0.1 LOGNAME=tester
12 if [ -x ./config.status ] && ./config.status --version | grep -q '^Wolfpack Empire'
14 else echo "$0: Must be run in root of build tree" >&2; exit 1
18 # Currently expected to work only with thread package LWP and a
19 # random() that behaves exactly like the one on my development system,
22 # - Thread scheduling is reliably deterministic only with LWP
23 # - The PRN sequence produced by random() isn't portable
24 # - Shell builtin kill appears not to do the job in MinGW
25 # - The Windows server tries to run as service when -d isn't
28 # TODO address these shortcomings.
30 if [ "`uname -s`" != "Linux" ] # lame approx. of "random() behaves like mine"
31 then echo "Warning: smoke test not expected to work on this system!" >&2
32 elif [ `sed -n 's/empthread *:= *\(.*\)/\1/p' <GNUmakefile` != LWP ]
33 then echo "Warning: smoke test not expected to work with this thread package!" >&2
38 mkdir -p sandbox/etc/empire sandbox/share/empire/builtin sandbox/var/empire
39 touch sandbox/etc/empire/schedule
40 cat >sandbox/etc/empire/econfig <<EOF
41 data "../../var/empire"
42 info "../../../../info.nr"
43 builtin "../../share/empire/builtin"
44 listen_addr "$EMPIREHOST"
47 cp "$srcdir"/src/lib/global/*.config sandbox/share/empire/builtin
49 exec 3>sandbox/smoke.out
52 trap 'if [ "$pid" ]; then kill "$pid" 2>/dev/null || true; fi' EXIT
54 # Create world and start server
55 src/util/files -e sandbox/etc/empire/econfig -f >&3
56 src/util/fairland -e sandbox/etc/empire/econfig -q -s sandbox/newcap_script -R 1 10 30
57 src/server/emp_server -e sandbox/etc/empire/econfig -R 1
58 while src/client/empire red herring 2>&1 | grep -q "Connection refused"
59 do : # FIXME hangs here if server crashes on startup
61 pid=`cat sandbox/var/empire/server.pid`
62 src/client/empire POGO peter <sandbox/newcap_script >/dev/null
66 for i in "$srcdir"/tests/smoke/[0-9]*
71 echo "Update Turn $t starting" >&3
72 src/client/empire POGO peter <<EOF >&3
80 echo "Update Turn $t completed successfully" >&3
85 echo "Player $p Turn $t starting" >&3
88 else c="${p#0}"; r="$c"
90 src/client/empire "$c" "$r" <$j >&3
91 echo "Player $p Turn $t completed successfully" >&3
98 while kill -0 "$pid" 2>/dev/null
99 do : # FIXME hangs here if server fails to exit
104 src/util/empdump -e sandbox/etc/empire/econfig -x >sandbox/smoke.xdump
106 # Smoke test completed; compare results
110 local opt exp act nrm msg ret=0
114 */journal.log) opt=-j ;;
115 */server.log) opt=-s ;;
118 exp="$srcdir/tests/smoke/${i##*/}"
120 nrm="sandbox/normalized-${i##*/}"
121 perl "$srcdir"/tests/normalize.pl $opt "$act" >"$nrm"
122 if msg=`diff -q "$exp" "$nrm"`
134 cmp_out smoke.out var/empire/server.log var/empire/journal.log smoke.xdump