File: run.sh

package info (click to toggle)
spring 106.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,316 kB
  • sloc: cpp: 543,954; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (89 lines) | stat: -rwxr-xr-x 1,627 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh

set -e # abort on error

if [ $# -le 0 ]; then
	echo "Usage: $0 /path/to/spring testScript [parameters]"
	exit 1
fi


if [ ! -x "$1" ]; then
	echo "Parameter 1 $1 isn't executable!"
	exit 1
fi

if [ "$(cat /proc/sys/kernel/core_pattern)" != "core" ]; then
	echo "Please set /proc/sys/kernel/core_pattern to core"
fi

#if [ "$(cat /proc/sys/kernel/core_uses_pid)" != "1" ]; then
#	echo "Please run sudo echo 1 >/proc/sys/kernel/core_uses_pid"
#	exit 1
#fi

echo "Env: GAME=$GAME MAP=$MAP AI=$AI AIVER=$AIVER"

# enable core dumps
ulimit -c unlimited

RUNCLIENT=test/validation/run-client.sh

if [ ! -x $RUNCLIENT ]; then
	echo "$RUNCLIENT doesn't exist, please run from the source-root directory"
	exit 1
fi


# limit to 1.5GB RAM
#ulimit -v 1500000
# max 10 min cpu time
ulimit -t 600

# delete path cache
rm -rf ~/.config/spring/cache/

if [ "$GAME" != "devgame:test" ];
then
	# start up the client in background
	$RUNCLIENT "$1 --nocolor" &
	PID_CLIENT=$!
fi

# start host
echo "Starting Host"
set +e #temp disable abort on error
$@ --nocolor &
PID_HOST=$!

# auto kill host after 15mins
#sleep 900 && kill -9 $PID_HOST &

echo waiting for host to exit, pid: $PID_HOST
# store exit code
wait $PID_HOST
EXIT=$?


if [ "$GAME" != "devgame:test" ];
then
	echo waiting for client to exit, pid: $PID_CLIENT
	# get spring client process exit code / wait for exit
	wait $PID_CLIENT
	EXITCHILD=$?

	#reenable abbort on error
	set -e

	# exit with exit code of server/client if failed
	if [ $EXITCHILD -ne 0 ];
	then
		echo Client exited with $EXITCHILD
		exit $EXITCHILD
	fi

fi

echo Server exited with $EXIT
exit $EXIT