Try to fix zombies in integration test

This commit is contained in:
ChillerDragon 2024-01-22 15:23:10 +08:00
parent 8b74e2929d
commit 741ed69337

View file

@ -5,9 +5,10 @@ cd "$(dirname "$0")" || exit 1
tw_srv_bin=teeworlds_srv tw_srv_bin=teeworlds_srv
logdir=logs logdir=logs
tmpdir=tmp tmpdir=tmp
srvcfg='sv_rcon_password rcon;sv_port 8377;killme' kill_marker=kill_me_d5af0410
srvcfg="sv_rcon_password rcon;sv_port 8377;$kill_marker"
cl_fifo="$tmpdir/client.fifo" cl_fifo="$tmpdir/client.fifo"
clcfg="cl_input_fifo $cl_fifo;connect 127.0.0.1:8377;killme" clcfg="cl_input_fifo $cl_fifo;connect 127.0.0.1:8377;$kill_marker"
tw_srv_running=0 tw_srv_running=0
ruby_logfile=ruby_client.txt ruby_logfile=ruby_client.txt
@ -107,6 +108,7 @@ function kill_all_jobs() {
kill "$kill_pid" &> /dev/null kill "$kill_pid" &> /dev/null
_kill_pids[i]='' # does not work because different job _kill_pids[i]='' # does not work because different job
done done
pkill -f "$kill_marker"
} }
function cleanup() { function cleanup() {
@ -156,7 +158,6 @@ function timeout() {
sleep "$seconds" sleep "$seconds"
echo "[-] Timeout -> killing: $testname" echo "[-] Timeout -> killing: $testname"
touch "$tmpdir/timeout.txt" touch "$tmpdir/timeout.txt"
pkill -f "$testname killme"
kill_all_jobs kill_all_jobs
fail "[-] Timeout" fail "[-] Timeout"
} }
@ -174,7 +175,7 @@ else
echo "ruby server log $(date)" > "$ruby_logfile" echo "ruby server log $(date)" > "$ruby_logfile"
fi fi
function run_ruby_test() { function run_ruby_test() {
if ! ruby "$testname" killme &> "$ruby_logfile" if ! ruby "$testname" "$kill_marker" &> "$ruby_logfile"
then then
fail "test $testname finished with non zero exit code" fail "test $testname finished with non zero exit code"
fi fi
@ -184,12 +185,12 @@ _kill_pids+=($!)
if [[ "$testname" =~ ^server/ ]] if [[ "$testname" =~ ^server/ ]]
then then
connect_ddnet7_client killme &>> "$logdir/client.txt" & connect_ddnet7_client "$kill_marker" &>> "$logdir/client.txt" &
_kill_pids+=($!) _kill_pids+=($!)
sleep 1 sleep 1
echo "connect 127.0.0.1" > "$cl_fifo" echo "connect 127.0.0.1" > "$cl_fifo"
fi fi
timeout 6 killme & timeout 6 "$kill_marker" &
_timeout_pid=$! _timeout_pid=$!
if [ "$testname" == "client/chat.rb" ] if [ "$testname" == "client/chat.rb" ]