(svn r27763) -Update from Eints:
[openttd.git] / bin / ai / regression / run.sh
blobd47a664ea3ba6965d8366c48174e28b7700c99a6
1 #!/bin/sh
3 # $Id$
5 if ! [ -f ai/regression/run.sh ]; then
6 echo "Make sure you are in the root of OpenTTD before starting this script."
7 exit 1
8 fi
10 if [ -f scripts/game_start.scr ]; then
11 mv scripts/game_start.scr scripts/game_start.scr.regression
14 params=""
15 gdb=""
16 if [ "$1" != "-r" ]; then
17 params="-snull -mnull -vnull:ticks=30000"
19 if [ "$1" = "-g" ]; then
20 gdb="gdb --ex run --args "
23 if [ -d "ai/regression/tst_$1" ]; then
24 tests="ai/regression/tst_$1"
25 elif [ -d "ai/regression/tst_$2" ]; then
26 tests="ai/regression/tst_$2"
27 else
28 tests=ai/regression/tst_*
31 ret=0
32 for tst in $tests; do
33 echo -n "Running $tst... "
35 # Make sure that only one info.nut is present for each test run. Otherwise openttd gets confused.
36 cp ai/regression/regression_info.nut $tst/info.nut
38 sav=$tst/test.sav
39 if ! [ -f $sav ]; then
40 sav=ai/regression/empty.sav
43 if [ -n "$gdb" ]; then
44 $gdb ./openttd -x -c ai/regression/regression.cfg $params -g $sav
45 else
46 ./openttd -x -c ai/regression/regression.cfg $params -g $sav -d script=2 -d misc=9 2>&1 | awk '{ gsub("0x(\\(nil\\)|0+)(x0)?", "0x00000000", $0); gsub("^dbg: \\[script\\]", "", $0); gsub("^ ", "ERROR: ", $0); gsub("ERROR: \\[1\\] ", "", $0); gsub("\\[P\\] ", "", $0); print $0; }' | grep -v '^dbg: \[.*\]' > tmp.regression
49 if [ -z "$gdb" ]; then
50 res="`diff -ub $tst/result.txt tmp.regression`"
51 if [ -z "$res" ]; then
52 echo "passed!"
53 else
54 echo "failed! Difference:"
55 echo "$res"
56 ret=1
60 rm $tst/info.nut
61 done
63 if [ -f scripts/game_start.scr.regression ]; then
64 mv scripts/game_start.scr.regression scripts/game_start.scr
67 if [ "$1" != "-k" ]; then
68 rm -f tmp.regression
71 exit $ret