Optimize vehicle impact code by only calling vlen() if damage would be taken
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server-testcase / run.sh
1 #!/bin/sh
2
3 if [ "$#" -lt 3 ]; then
4         echo "Usage: $0 'float test() { if(fail) return 0; else if(good) return 1; else return -1; }' ./darkplaces-dedicated basement +sv_cheats 1"
5         exit 125
6 fi
7
8 case "$0" in
9         */*)
10                 dir=${0%/*}
11                 ;;
12         *)
13                 dir=`pwd`
14                 ;;
15 esac
16 testcase=$1; shift
17 engine=$1; shift
18 map=$1; shift
19 echo "$testcase" > "$dir/testcase.qc"
20 if ( cd $dir && fteqcc ); then
21         set -- "$engine" -xonotic -basedir "$dir/../../.." +sv_progs progs-testcase.dat "$@" +map "$map"
22         if [ -n "$GDB_ME" ]; then
23                 cmdfile=`mktemp`
24                 {
25                         echo "break VM_dprint"
26                         echo "run"
27                         echo "delete 1"
28                         echo "finish"
29                 } > "$cmdfile"
30                 gdb -x "$cmdfile" --args "$@"
31                 rm -f "$cmdfile"
32                 exit 0
33         else
34                 r=`"$@" | tee /dev/stderr`
35         fi
36         case "$r" in
37                 *"TESTCASE: PASS"*)
38                         echo "PASS detected"
39                         exit 0
40                         ;;
41                 *"TESTCASE: FAIL"*)
42                         echo "FAIL detected"
43                         exit 1
44                         ;;
45                 *"TESTCASE: INVALID"*)
46                         echo "INVALID detected"
47                         exit 125
48                         ;;
49                 *)
50                         echo "Running failed"
51                         exit 125
52                         ;;
53         esac
54 else
55         echo "Compilation failed"
56         exit 125
57 fi