Skip to content

Commit aa36a7e

Browse files
committed
Merge branch 'ddnet' into chillerbot
2 parents fb9f2a7 + 07fd8c1 commit aa36a7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1617
-1207
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,7 @@ set(EXPECTED_DATA
15631563
particles.png
15641564
playerpics/ChillerDragon.png
15651565
playerpics/jao.png
1566+
race_flag.png
15661567
shader/pipeline.frag
15671568
shader/pipeline.vert
15681569
shader/prim.frag
@@ -2273,10 +2274,10 @@ if(CLIENT)
22732274
components/ghost.h
22742275
components/hud.cpp
22752276
components/hud.h
2277+
components/infomessages.cpp
2278+
components/infomessages.h
22762279
components/items.cpp
22772280
components/items.h
2278-
components/killmessages.cpp
2279-
components/killmessages.h
22802281
components/mapimages.cpp
22812282
components/mapimages.h
22822283
components/maplayers.cpp

data/race_flag.png

1.95 KB
Loading

datasrc/content.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ def FileList(fmt, num):
255255
container.images.Add(image_strongweak)
256256
container.images.Add(image_hud)
257257
container.images.Add(image_extras)
258+
container.images.Add(Image("raceflag", "race_flag.png"))
258259

259260
container.pickups.Add(Pickup("health"))
260261
container.pickups.Add(Pickup("armor"))

datasrc/network.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,4 +558,12 @@
558558
NetMessageEx("Sv_YourVote", "yourvote@netmsg.ddnet.org", [
559559
NetIntRange("m_Voted", -1, 1),
560560
]),
561+
562+
NetMessageEx("Sv_RaceFinish", "racefinish@netmsg.ddnet.org", [
563+
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
564+
NetIntAny("m_Time"),
565+
NetIntAny("m_Diff"),
566+
NetBool("m_RecordPersonal"),
567+
NetBool("m_RecordServer", default=False),
568+
]),
561569
]

scripts/integration_test.sh

Lines changed: 64 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ for arg in "$@"
77
do
88
if [ "$arg" == "-h" ] || [ "$arg" == "--help" ]
99
then
10-
echo "usage: $(basename "$0") [OPTION..] [build dir]"
10+
echo "usage: $(basename "$0") [OPTION..]"
1111
echo "description:"
1212
echo " Runs a simple integration test of the client and server"
13-
echo " binaries from the given build dir"
13+
echo " binaries from the current build directory."
1414
echo "options:"
15-
echo " --help|-h show this help"
16-
echo " --verbose|-v verbose output"
17-
echo " --valgrind-memcheck use valgrind's memcheck to run server and client"
15+
echo " --help|-h show this help"
16+
echo " --verbose|-v verbose output"
17+
echo " --valgrind-memcheck use valgrind's memcheck to run server and client"
1818
exit 0
1919
elif [ "$arg" == "-v" ] || [ "$arg" == "--verbose" ]
2020
then
@@ -23,22 +23,23 @@ do
2323
then
2424
arg_valgrind_memcheck=1
2525
else
26-
echo "Error: unknown arg '$arg'"
26+
echo "Error: unknown argument '$arg'"
2727
exit 1
2828
fi
2929
done
3030

3131
if [ ! -f DDNet ]
3232
then
33-
echo "Error: client binary not found DDNet' not found"
33+
echo "[-] Error: client binary 'DDNet' not found"
3434
exit 1
3535
fi
3636
if [ ! -f DDNet-Server ]
3737
then
38-
echo "Error: server binary not found DDNet-Server' not found"
38+
echo "[-] Error: server binary 'DDNet-Server' not found"
3939
exit 1
4040
fi
4141

42+
echo "[*] Setup"
4243
got_killed=0
4344

4445
function kill_all() {
@@ -51,24 +52,27 @@ function kill_all() {
5152

5253
if [ "$arg_verbose" == "1" ]
5354
then
54-
echo "[*] shutting down test clients and server ..."
55+
echo "[*] Shutting down test clients and server"
5556
fi
56-
5757
sleep 1
58+
5859
if [[ ! -f fail_server.txt ]]
5960
then
60-
echo "[*] shutting down server"
61+
echo "[*] Shutting down server"
6162
echo "shutdown" > server.fifo
6263
fi
64+
sleep 1
65+
6366
local i
6467
for ((i=1;i<3;i++))
6568
do
6669
if [[ ! -f fail_client$i.txt ]]
6770
then
68-
echo "[*] shutting down client$i"
71+
echo "[*] Shutting down client$i"
6972
echo "quit" > "client$i.fifo"
7073
fi
7174
done
75+
sleep 1
7276
}
7377

7478
function cleanup() {
@@ -85,8 +89,8 @@ function fail()
8589
echo "[-] $1 exited with code $2"
8690
}
8791

88-
# TODO: check for open ports instead
89-
port=17822
92+
# Get unused port from the system by binding to port 0 and immediately closing the socket again
93+
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()');
9094

9195
if [[ $OSTYPE == 'darwin'* ]]; then
9296
DETECT_LEAKS=0
@@ -100,13 +104,18 @@ export LSAN_OPTIONS=suppressions=../lsan.supp:print_suppressions=0
100104

101105
function print_results() {
102106
if [ "$arg_valgrind_memcheck" == "1" ]; then
103-
if grep "ERROR SUMMARY" server.log client1.log client2.log | grep -q -v "ERROR SUMMARY: 0"; then
104-
grep "^==" server.log client1.log client2.log
107+
# Wait to ensure that the error summary was written to the stderr files because valgrind takes some time
108+
# TODO: Instead wait for all started processes to finish
109+
sleep 20
110+
if grep "== ERROR SUMMARY: " stderr_server.txt stderr_client1.txt stderr_client2.txt | grep -q -v "ERROR SUMMARY: 0"; then
111+
echo "[-] Error: Valgrind has detected the following errors:"
112+
grep "^==" stderr_server.txt stderr_client1.txt stderr_client2.txt
105113
return 1
106114
fi
107115
else
108116
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
109117
then
118+
echo "[-] Error: ASAN has detected the following errors:"
110119
cat SAN.*
111120
return 1
112121
fi
@@ -127,39 +136,54 @@ cd integration_test || exit 1
127136
echo $'add_path ../data'
128137
} > storage.cfg
129138

139+
tool=""
140+
client_args="cl_download_skins 0;
141+
gfx_fullscreen 0;
142+
snd_enable 0;"
143+
130144
if [ "$arg_valgrind_memcheck" == "1" ]; then
131145
tool="valgrind --tool=memcheck --gen-suppressions=all --suppressions=../memcheck.supp --track-origins=yes"
132-
client_args="cl_menu_map \"\";"
133-
else
134-
tool=""
135-
client_args=""
146+
client_args="$client_args cl_menu_map \"\";"
136147
fi
137148

138149
function wait_for_fifo() {
139150
local fifo="$1"
140151
local tries="$2"
141152
local fails=0
142-
# give the client time to launch and create the fifo file
143-
# but assume after X secs that the client crashed before
153+
# give the server/client time to launch and create the fifo file
154+
# but assume after X secs that the server/client crashed before
144155
# being able to create the file
145156
while [[ ! -p "$fifo" ]]
146157
do
147158
fails="$((fails+1))"
148159
if [ "$arg_verbose" == "1" ]
149160
then
150-
echo "[!] client fifos not found (attempts $fails/$tries)"
161+
echo "[!] Note: $fifo not found (attempts $fails/$tries)"
151162
fi
152163
if [ "$fails" -gt "$tries" ]
153164
then
165+
echo "[-] Error: $(basename "$fifo" .fifo) possibly crashed on launch"
166+
kill_all
154167
print_results
155-
echo "[-] Error: client possibly crashed on launch"
156168
exit 1
157169
fi
158170
sleep 1
159171
done
160172
}
161173

162-
echo "[*] launch server"
174+
function wait_for_launch() {
175+
local fifo="$1"
176+
local baseDuration="$2"
177+
if [ "$arg_valgrind_memcheck" == "1" ]; then
178+
wait_for_fifo "$fifo" $((40 * baseDuration))
179+
sleep $((8 * baseDuration))
180+
else
181+
wait_for_fifo "$fifo" $((10 * baseDuration))
182+
sleep "$baseDuration"
183+
fi
184+
}
185+
186+
echo "[*] Launch server"
163187
$tool ../DDNet-Server \
164188
"sv_input_fifo server.fifo;
165189
sv_rcon_password rcon;
@@ -169,50 +193,34 @@ $tool ../DDNet-Server \
169193
sv_register 0;
170194
sv_port $port" > stdout_server.txt 2> stderr_server.txt || fail server "$?" &
171195

172-
echo "[*] launch client 1"
196+
wait_for_launch server.fifo 1
197+
198+
echo "[*] Launch client 1"
173199
$tool ../DDNet \
174200
"cl_input_fifo client1.fifo;
175201
player_name client1;
176-
cl_download_skins 0;
177-
gfx_fullscreen 0;
178-
snd_enable 0;
179202
logfile client1.log;
180203
$client_args
181204
connect localhost:$port" > stdout_client1.txt 2> stderr_client1.txt || fail client1 "$?" &
182205

183-
if [ "$arg_valgrind_memcheck" == "1" ]; then
184-
wait_for_fifo client1.fifo 180
185-
sleep 40
186-
else
187-
wait_for_fifo client1.fifo 50
188-
sleep 1
189-
fi
206+
wait_for_launch client1.fifo 5
190207

191-
echo "[*] start demo recording"
208+
echo "[*] Start demo recording"
192209
echo "record server" > server.fifo
193210
echo "record client1" > client1.fifo
194211
sleep 1
195212

196-
echo "[*] launch client 2"
213+
echo "[*] Launch client 2"
197214
$tool ../DDNet \
198215
"cl_input_fifo client2.fifo;
199216
player_name client2;
200-
cl_download_skins 0;
201-
gfx_fullscreen 0;
202-
snd_enable 0;
203217
logfile client2.log;
204218
$client_args
205219
connect localhost:$port" > stdout_client2.txt 2> stderr_client2.txt || fail client2 "$?" &
206220

207-
if [ "$arg_valgrind_memcheck" == "1" ]; then
208-
wait_for_fifo client2.fifo 180
209-
sleep 40
210-
else
211-
wait_for_fifo client2.fifo 50
212-
sleep 2
213-
fi
221+
wait_for_launch client2.fifo 5
214222

215-
echo "[*] test chat and chat commands"
223+
echo "[*] Test chat and chat commands"
216224
echo "say hello world" > client1.fifo
217225
echo "rcon_auth rcon" > client1.fifo
218226
sleep 1
@@ -236,7 +244,7 @@ say "/mc
236244
EOF
237245
sleep 1
238246

239-
echo "[*] test rcon commands"
247+
echo "[*] Test rcon commands"
240248
tr -d '\n' > client1.fifo << EOF
241249
rcon say hello from admin;
242250
rcon broadcast test;
@@ -247,20 +255,20 @@ unban_all;
247255
EOF
248256
sleep 1
249257

250-
echo "[*] stop demo recording"
258+
echo "[*] Stop demo recording"
251259
echo "stoprecord" > server.fifo
252260
echo "stoprecord" > client1.fifo
253261
sleep 1
254262

255-
echo "[*] test map change"
263+
echo "[*] Test map change"
256264
echo "rcon sv_map Tutorial" > client1.fifo
257265
if [ "$arg_valgrind_memcheck" == "1" ]; then
258266
sleep 60
259267
else
260268
sleep 15
261269
fi
262270

263-
echo "[*] play demos"
271+
echo "[*] Play demos"
264272
echo "play demos/server.demo" > client1.fifo
265273
echo "play demos/client1.demo" > client2.fifo
266274
if [ "$arg_valgrind_memcheck" == "1" ]; then
@@ -271,8 +279,6 @@ fi
271279

272280
# Kill all processes first so all outputs are fully written
273281
kill_all
274-
wait
275-
sleep 1
276282

277283
if ! grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2} ([0-9]{2}:){2}[0-9]{2} I chat: 0:-2:client1: hello world$' server.log
278284
then
@@ -331,7 +337,7 @@ do
331337
fi
332338
if [ ! -f "$logfile" ]
333339
then
334-
echo "[-] Error: logfile '$logfile' not found."
340+
echo "[-] Error: logfile '$logfile' not found"
335341
touch fail_logs.txt
336342
continue
337343
fi
@@ -366,10 +372,9 @@ then
366372
cat "$fail"
367373
done
368374
print_results
369-
echo "[-] Test failed. See errors above."
375+
echo "[-] Test failed. See errors above"
370376
exit 1
371-
else
372-
echo "[*] all tests passed"
373377
fi
374378

379+
echo "[*] All tests passed"
375380
print_results || exit 1

0 commit comments

Comments
 (0)