@@ -4,14 +4,17 @@ cd "$(dirname "$0")" || exit 1
4
4
5
5
tw_srv_bin=teeworlds_srv
6
6
tw_cl_bin=teeworlds
7
+ logdir=logs
8
+ tmpdir=tmp
7
9
srvcfg=' sv_rcon_password rcon;sv_port 8377;killme'
8
- clcfg=' connect 127.0.0.1:8377;killme'
10
+ cl_fifo=" $tmpdir /client.fifo"
11
+ clcfg=" cl_input_fifo $cl_fifo ;connect 127.0.0.1:8377;killme"
9
12
tw_srv_running=0
10
13
tw_client_running=0
11
- logdir=logs
12
14
ruby_logfile=ruby_client.txt
13
15
14
16
mkdir -p logs
17
+ mkdir -p tmp
15
18
16
19
function start_tw_server() {
17
20
if [[ -x " $( command -v teeworlds_srv) " ]]
@@ -35,11 +38,11 @@ function start_tw_server() {
35
38
function connect_tw_client() {
36
39
if [[ -x " $( command -v teeworlds-headless) " ]]
37
40
then
38
- teeworlds-headless " $clcfg " " $logdir /client.txt "
41
+ teeworlds-headless " $clcfg "
39
42
tw_cl_bin=teeworlds-headless
40
43
elif [[ -x " $( command -v /usr/local/bin/teeworlds-headless) " ]]
41
44
then
42
- /usr/local/bin/teeworlds-headless " $clcfg " " $logdir /client.txt "
45
+ /usr/local/bin/teeworlds-headless " $clcfg "
43
46
tw_cl_bin=/usr/local/bin/teeworlds-headless
44
47
elif [[ -x " $( command -v teeworlds) " ]]
45
48
then
@@ -52,6 +55,22 @@ function connect_tw_client() {
52
55
tw_client_running=1
53
56
}
54
57
58
+ function connect_ddnet7_client() {
59
+ if [[ -x " $( command -v DDNet7-headless) " ]]
60
+ then
61
+ DDNet7-headless " $clcfg "
62
+ tw_cl_bin=DDNet7-headless
63
+ elif [[ -x " $( command -v /usr/local/bin/DDNet7-headless) " ]]
64
+ then
65
+ /usr/local/bin/DDNet7-headless " $clcfg "
66
+ tw_cl_bin=/usr/local/bin/DDNet7-headless
67
+ else
68
+ echo " Error: please install a DDNet7-headless"
69
+ exit 1
70
+ fi
71
+ tw_client_running=1
72
+ }
73
+
55
74
function get_test_names() {
56
75
(find client -name " *.rb" ; find server -name " *.rb" ) | tr ' \n' ' '
57
76
}
@@ -94,7 +113,7 @@ function cleanup() {
94
113
echo " [*] shutting down client ..."
95
114
pkill -f " $tw_cl_bin $clcfg "
96
115
fi
97
- [[ " $_timout_pid " != " " ]] && kill " $_timout_pid " & > /dev/null
116
+ [[ " $_timeout_pid " != " " ]] && kill " $_timeout_pid " & > /dev/null
98
117
}
99
118
100
119
trap cleanup EXIT
@@ -108,10 +127,18 @@ function fail() {
108
127
# maybe a sleep does as well
109
128
# or I still did not get flushing
110
129
tail " $ruby_logfile " & > /dev/null
111
- echo " [-] end of ruby client log:"
112
- tail " $ruby_logfile "
113
- echo " [-] end of server log:"
114
- tail " $logdir /server.txt"
130
+ if [[ " $testname " =~ ^client/ ]]
131
+ then
132
+ echo " [-] end of ruby client log:"
133
+ tail " $ruby_logfile "
134
+ echo " [-] end of server log:"
135
+ tail " $logdir /server.txt"
136
+ else
137
+ echo " [-] end of ruby server log:"
138
+ tail " $ruby_logfile "
139
+ echo " [-] end of client log:"
140
+ tail " $logdir /client.txt"
141
+ fi
115
142
echo " $msg "
116
143
exit 1
117
144
}
@@ -133,13 +160,21 @@ then
133
160
echo " server log $( date) " > " $logdir /server.txt"
134
161
start_tw_server
135
162
else
136
- echo " client log $( date) " > " $logdir /client.txt"
137
- echo " server log $( date) " > " $ruby_logfile "
138
- connect_tw_client
163
+ echo " ruby server log $( date) " > " $ruby_logfile "
164
+ fi
165
+ timeout 6 killme &
166
+ _timeout_pid=$!
167
+ if ! ruby " $testname " killme & > " $ruby_logfile "
168
+ then
169
+ fail " test $testname finished with non zero exit code"
170
+ fi
171
+
172
+ if [[ " $testname " =~ ^server/ ]]
173
+ then
174
+ connect_ddnet7_client & > " $logdir /client.txt" &
175
+ sleep 1
176
+ echo " connect 127.0.0.1" > " $cl_fifo "
139
177
fi
140
- timeout 3 killme &
141
- _timout_pid=$!
142
- ruby " $testname " killme & > " $ruby_logfile "
143
178
144
179
if [ " $testname " == " client/chat.rb" ]
145
180
then
@@ -196,14 +231,19 @@ then
196
231
then
197
232
fail " Error: 'block 1' found after 'block 2' in client log"
198
233
fi
234
+ elif [ " $testname " == " server/connect.rb" ]
235
+ then
236
+ echo " rcon test" > " $cl_fifo "
237
+ sleep 1
238
+ echo " shutdown" > " $cl_fifo "
199
239
else
200
240
echo " Error: unkown test '$testname '"
201
241
exit 1
202
242
fi
203
243
204
244
if [ -f timeout.txt ]
205
245
then
206
- echo " [-] Error timouted "
246
+ echo " [-] Error timeouted "
207
247
exit 1
208
248
fi
209
249
0 commit comments