Skip to content

Commit 2d64de2

Browse files
committed
Debug sdl2 in CI
1 parent 55549ea commit 2d64de2

File tree

2 files changed

+61
-17
lines changed

2 files changed

+61
-17
lines changed

.github/workflows/integration.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ jobs:
1919
- name: Prepare
2020
run: |
2121
sudo apt-get update -y
22-
sudo apt-get install -y shellcheck teeworlds-server
22+
sudo apt-get install -y shellcheck teeworlds-server teeworlds-data
23+
sudo apt install -y build-essential glslang-tools libavcodec-extra libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libcurl4-openssl-dev libfreetype6-dev libglew-dev libnotify-dev libogg-dev libopus-dev libopusfile-dev libpng-dev libsdl2-dev libsqlite3-dev libssl-dev libvulkan-dev libwavpack-dev libx264-dev
2324
gem install bundler
2425
gem install rubocop:1.31.2
2526
bundle install --jobs 4 --retry 3
@@ -32,11 +33,11 @@ jobs:
3233
unzip DDNet-headless.zip
3334
sudo mv DDNet-headless /usr/local/bin
3435
rm DDNet-headless.zip
35-
wget https://github.com/ChillerDragon/ddnet/releases/download/v17.4.2-headless-0.7/DDNet7-headless.zip
36-
unzip DDNet7-headless.zip
36+
wget https://github.com/ChillerDragon/ddnet/releases/download/v17.4.2-headless-0.7/DDNet7-headless-linux.zip
37+
unzip DDNet7-headless-linux.zip
3738
chmod +x DDNet7-headless
3839
sudo mv DDNet7-headless /usr/local/bin
39-
rm DDNet7-headless.zip
40+
rm DDNet7-headless-linux.zip
4041
- name: '[CLIENT] Test sending chat messages'
4142
run: |
4243
./integration_test/run.sh client/chat.rb

integration_test/run.sh

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ kill_marker=kill_me_d5af0410
99
server_port=8377
1010
srvcfg="sv_rcon_password rcon;sv_port $server_port;$kill_marker"
1111
cl_fifo="$PWD/$tmpdir/client.fifo"
12-
clcfg="cl_input_fifo $cl_fifo;connect 127.0.0.1:$server_port;$kill_marker"
12+
clcfg="cl_input_fifo $cl_fifo;connect 127.0.0.1:$server_port;player_name test_client;$kill_marker"
1313
tw_srv_running=0
1414
ruby_logfile=ruby_client.txt
1515

16+
_client_pid=''
1617
_kill_pids=()
1718

1819
mkdir -p logs
1920
mkdir -p tmp
2021

21-
function start_tw_server() {
22+
start_tw_server() {
2223
if [[ -x "$(command -v teeworlds_srv)" ]]
2324
then
2425
teeworlds_srv "$srvcfg" &> "$logdir/server.txt"
@@ -37,7 +38,7 @@ function start_tw_server() {
3738
tw_srv_running=1
3839
}
3940

40-
function connect_tw_client() {
41+
connect_tw_client() {
4142
if [[ -x "$(command -v teeworlds-headless)" ]]
4243
then
4344
teeworlds-headless "$clcfg"
@@ -53,7 +54,7 @@ function connect_tw_client() {
5354
fi
5455
}
5556

56-
function connect_ddnet7_client() {
57+
connect_ddnet7_client() {
5758
local clcfg_dd7
5859
clcfg_dd7="$(echo "$clcfg" | sed 's/127.0.0.1/tw-0.7+udp:\/\/127.0.0.1/')"
5960
if [[ -x "$(command -v DDNet7-headless)" ]]
@@ -68,10 +69,10 @@ function connect_ddnet7_client() {
6869
fi
6970
}
7071

71-
function get_test_names() {
72+
get_test_names() {
7273
(find client -name "*.rb";find server -name "*.rb") | tr '\n' ' '
7374
}
74-
function invalid_test() {
75+
invalid_test() {
7576
local name="$1"
7677
echo "Error: invalid test name '$name'"
7778
echo " valid tests: $(get_test_names)"
@@ -99,7 +100,7 @@ else
99100
ruby_logfile="$logdir/ruby_server.txt"
100101
fi
101102

102-
function kill_all_jobs() {
103+
kill_all_jobs() {
103104
local i
104105
local kill_pid
105106
for i in "${!_kill_pids[@]}"
@@ -114,7 +115,7 @@ function kill_all_jobs() {
114115
pkill -f "$kill_marker"
115116
}
116117

117-
function cleanup() {
118+
cleanup() {
118119
if [ "$tw_srv_running" == "1" ]
119120
then
120121
echo "[*] shutting down server ..."
@@ -127,7 +128,7 @@ function cleanup() {
127128

128129
trap cleanup EXIT
129130

130-
function fail() {
131+
fail() {
131132
local msg="$1"
132133
if [ ! -f "$tmpdir/fail.txt" ]
133134
then
@@ -156,7 +157,7 @@ function fail() {
156157
exit 1
157158
}
158159

159-
function timeout() {
160+
timeout() {
160161
local seconds="$1"
161162
sleep "$seconds"
162163
echo "[-] Timeout -> killing: $testname"
@@ -178,7 +179,7 @@ else
178179
echo "ddnet7 client log $(date)" > "$logdir/client.txt"
179180
echo "ruby server log $(date)" > "$ruby_logfile"
180181
fi
181-
function run_ruby_test() {
182+
run_ruby_test() {
182183
if ! ruby "$testname" "$kill_marker" &> "$ruby_logfile"
183184
then
184185
fail "test $testname finished with non zero exit code"
@@ -196,18 +197,55 @@ fi
196197
if [[ "$testname" =~ ^server/ ]]
197198
then
198199
connect_ddnet7_client "$kill_marker" &>> "$logdir/client.txt" &
199-
_kill_pids+=($!)
200+
_client_pid=$!
201+
_kill_pids+=("$_client_pid")
200202
sleep 1
201203
fi
202204
timeout 6 "$kill_marker" &
203205
_timeout_pid=$!
204206

205-
function fifo() {
207+
fifo() {
206208
local cmd="$1"
207209
local fifo_file="$2"
208210
echo "[*] $cmd >> $fifo_file"
209211
echo "$cmd" >> "$fifo_file"
210212
}
213+
assert_in_log() {
214+
# usage: assert_in_log string path [num_matches"
215+
# examples:
216+
# assert_in_log "string to find" "/path/to/log.txt"
217+
# assert_in_log "string to find" "/path/to/log.txt" 2
218+
local needle="$1"
219+
local logfile_path="$2"
220+
local num_matches="$3"
221+
if ! grep -q "$needle" "$logfile_path"
222+
then
223+
echo "[-] Error: did not find expected string in logs"
224+
echo "[-]"
225+
echo "[-] expected: $needle"
226+
echo "[-] in file: $ruby_logfile"
227+
echo "[-]"
228+
fail "assert failed"
229+
fi
230+
if [ "$num_matches" != "" ]
231+
then
232+
local actual_matches
233+
actual_matches="$(grep -c "$needle" "$logfile_path")"
234+
if [ "$actual_matches" != "$num_matches" ]
235+
then
236+
echo "[-] Error: found string unexpected amount of times in log file"
237+
echo "[-]"
238+
echo "[-] expected: $needle"
239+
echo "[-] in file: $ruby_logfile"
240+
echo "[-]"
241+
echo "[-] expected num hits: $num_matches"
242+
echo "[-] got num hits: $actual_matches"
243+
echo "[-]"
244+
fail "assert failed"
245+
fi
246+
fi
247+
echo "[*] $needle .. OK"
248+
}
211249

212250
if [ "$testname" == "client/chat.rb" ]
213251
then
@@ -271,6 +309,11 @@ then
271309
fifo "rcon shutdown" "$cl_fifo"
272310
sleep 1
273311
fifo "quit" "$cl_fifo"
312+
# ddnet quitting can get stuck so send a kill to ensure it dies
313+
kill "$_client_pid"
314+
315+
assert_in_log "'test_client' joined the game" "$ruby_logfile" 1
316+
assert_in_log "rcon='shutdown'" "$ruby_logfile" 1
274317
else
275318
echo "Error: unkown test '$testname'"
276319
exit 1

0 commit comments

Comments
 (0)