2009-01-12 17:11:45 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2009-01-13 16:30:24 +00:00
|
|
|
# $Id$
|
|
|
|
|
2014-09-21 16:41:03 +00:00
|
|
|
if ! [ -f ai/regression/run.sh ]; then
|
2009-01-12 17:11:45 +00:00
|
|
|
echo "Make sure you are in the root of OpenTTD before starting this script."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f scripts/game_start.scr ]; then
|
2009-02-03 17:33:43 +00:00
|
|
|
mv scripts/game_start.scr scripts/game_start.scr.regression
|
2009-01-12 17:11:45 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
params=""
|
|
|
|
gdb=""
|
|
|
|
if [ "$1" != "-r" ]; then
|
|
|
|
params="-snull -mnull -vnull:ticks=30000"
|
|
|
|
fi
|
|
|
|
if [ "$1" = "-g" ]; then
|
|
|
|
gdb="gdb --ex run --args "
|
|
|
|
fi
|
2014-09-21 16:41:03 +00:00
|
|
|
|
|
|
|
if [ -d "ai/regression/tst_$1" ]; then
|
|
|
|
tests="ai/regression/tst_$1"
|
|
|
|
elif [ -d "ai/regression/tst_$2" ]; then
|
|
|
|
tests="ai/regression/tst_$2"
|
2009-01-12 17:11:45 +00:00
|
|
|
else
|
2014-09-21 16:41:03 +00:00
|
|
|
tests=ai/regression/tst_*
|
2009-01-12 17:11:45 +00:00
|
|
|
fi
|
|
|
|
|
2011-06-13 10:09:59 +00:00
|
|
|
ret=0
|
2014-09-21 16:41:03 +00:00
|
|
|
for tst in $tests; do
|
2014-09-21 17:22:50 +00:00
|
|
|
echo -n "Running $tst... "
|
2014-09-21 16:41:03 +00:00
|
|
|
|
|
|
|
# Make sure that only one info.nut is present for each test run. Otherwise openttd gets confused.
|
|
|
|
cp ai/regression/regression_info.nut $tst/info.nut
|
|
|
|
|
|
|
|
sav=$tst/test.sav
|
|
|
|
if ! [ -f $sav ]; then
|
|
|
|
sav=ai/regression/empty.sav
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$gdb" ]; then
|
|
|
|
$gdb ./openttd -x -c ai/regression/regression.cfg $params -g $sav
|
|
|
|
else
|
2019-01-13 07:40:54 +00:00
|
|
|
./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: \[.*\]' > $tst/tmp.regression
|
2014-09-21 16:41:03 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$gdb" ]; then
|
2019-01-13 07:40:54 +00:00
|
|
|
res="`diff -ub $tst/result.txt $tst/tmp.regression`"
|
2014-09-21 17:22:50 +00:00
|
|
|
if [ -z "$res" ]; then
|
|
|
|
echo "passed!"
|
|
|
|
else
|
|
|
|
echo "failed! Difference:"
|
|
|
|
echo "$res"
|
|
|
|
ret=1
|
|
|
|
fi
|
2014-09-21 16:41:03 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm $tst/info.nut
|
2019-01-13 07:40:54 +00:00
|
|
|
|
|
|
|
if [ "$1" != "-k" ]; then
|
|
|
|
rm -f $tst/tmp.regression
|
|
|
|
fi
|
2014-09-21 16:41:03 +00:00
|
|
|
done
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
if [ -f scripts/game_start.scr.regression ]; then
|
2009-02-03 17:33:43 +00:00
|
|
|
mv scripts/game_start.scr.regression scripts/game_start.scr
|
2009-01-12 17:11:45 +00:00
|
|
|
fi
|
|
|
|
|
2011-06-13 10:09:59 +00:00
|
|
|
exit $ret
|