2022-11-05 17:41:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
cd "$(dirname "$0")" || exit 1
|
|
|
|
|
2022-11-12 15:47:12 +00:00
|
|
|
tw_srv_bin=teeworlds_srv
|
2024-01-20 15:49:14 +00:00
|
|
|
logdir=logs
|
|
|
|
tmpdir=tmp
|
2024-01-22 07:23:10 +00:00
|
|
|
kill_marker=kill_me_d5af0410
|
2024-01-22 13:55:36 +00:00
|
|
|
server_port=8377
|
|
|
|
srvcfg="sv_rcon_password rcon;sv_port $server_port;$kill_marker"
|
2024-01-22 15:16:56 +00:00
|
|
|
cl_fifo="$PWD/$tmpdir/client.fifo"
|
2024-01-22 15:38:31 +00:00
|
|
|
clcfg="cl_input_fifo $cl_fifo;connect 127.0.0.1:$server_port;player_name test_client;$kill_marker"
|
2022-11-12 17:31:40 +00:00
|
|
|
tw_srv_running=0
|
2022-11-12 18:32:48 +00:00
|
|
|
ruby_logfile=ruby_client.txt
|
2024-01-22 15:38:31 +00:00
|
|
|
ruby_logfile_err=ruby_client_stderr.txt
|
2022-11-05 17:41:06 +00:00
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
_client_pid=''
|
2024-01-21 07:32:43 +00:00
|
|
|
_kill_pids=()
|
|
|
|
|
2024-02-20 03:23:40 +00:00
|
|
|
[[ -d tmp ]] && rm -rf tmp
|
|
|
|
|
2022-11-12 17:31:40 +00:00
|
|
|
mkdir -p logs
|
2024-01-20 15:49:14 +00:00
|
|
|
mkdir -p tmp
|
2022-11-05 17:41:06 +00:00
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
start_tw_server() {
|
2022-11-12 17:31:40 +00:00
|
|
|
if [[ -x "$(command -v teeworlds_srv)" ]]
|
|
|
|
then
|
2024-01-22 15:26:05 +00:00
|
|
|
teeworlds_srv "$srvcfg" &> "$logdir/server.txt"
|
2022-11-12 17:31:40 +00:00
|
|
|
elif [[ -x "$(command -v teeworlds-server)" ]]
|
|
|
|
then
|
2024-01-22 15:26:05 +00:00
|
|
|
teeworlds-server "$srvcfg" &> "$logdir/server.txt"
|
2022-11-12 17:31:40 +00:00
|
|
|
tw_srv_bin='teeworlds-server'
|
|
|
|
elif [[ -x "$(command -v teeworlds-srv)" ]]
|
|
|
|
then
|
2024-01-22 15:26:05 +00:00
|
|
|
teeworlds-srv "$srvcfg" &> "$logdir/server.txt"
|
2022-11-12 17:31:40 +00:00
|
|
|
tw_srv_bin='teeworlds-srv'
|
2024-02-20 03:23:40 +00:00
|
|
|
elif [ -f /usr/games/teeworlds-server ] # needed for docker ubuntu:24.04
|
|
|
|
then
|
|
|
|
/usr/games/teeworlds-server "$srvcfg" &> "$logdir/server.txt"
|
|
|
|
tw_srv_bin='/usr/games/teeworlds-server'
|
2022-11-12 17:31:40 +00:00
|
|
|
else
|
|
|
|
echo "Error: please install a teeworlds_srv"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
tw_srv_running=1
|
|
|
|
}
|
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
connect_tw_client() {
|
2022-11-12 18:32:48 +00:00
|
|
|
if [[ -x "$(command -v teeworlds-headless)" ]]
|
2022-11-12 17:31:40 +00:00
|
|
|
then
|
2024-01-20 15:49:14 +00:00
|
|
|
teeworlds-headless "$clcfg"
|
2022-11-12 18:32:48 +00:00
|
|
|
elif [[ -x "$(command -v /usr/local/bin/teeworlds-headless)" ]]
|
|
|
|
then
|
2024-01-20 15:49:14 +00:00
|
|
|
/usr/local/bin/teeworlds-headless "$clcfg"
|
2022-11-12 18:32:48 +00:00
|
|
|
elif [[ -x "$(command -v teeworlds)" ]]
|
|
|
|
then
|
|
|
|
teeworlds "$clcfg" "$logdir/client.txt"
|
2022-11-12 17:31:40 +00:00
|
|
|
else
|
|
|
|
echo "Error: please install a teeworlds"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2022-11-12 15:47:12 +00:00
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
connect_ddnet7_client() {
|
2024-01-22 13:55:36 +00:00
|
|
|
local clcfg_dd7
|
|
|
|
clcfg_dd7="$(echo "$clcfg" | sed 's/127.0.0.1/tw-0.7+udp:\/\/127.0.0.1/')"
|
2024-01-20 15:49:14 +00:00
|
|
|
if [[ -x "$(command -v DDNet7-headless)" ]]
|
|
|
|
then
|
2024-01-22 13:55:36 +00:00
|
|
|
DDNet7-headless "$clcfg_dd7"
|
2024-01-20 15:49:14 +00:00
|
|
|
elif [[ -x "$(command -v /usr/local/bin/DDNet7-headless)" ]]
|
|
|
|
then
|
2024-01-22 13:55:36 +00:00
|
|
|
/usr/local/bin/DDNet7-headless "$clcfg_dd7"
|
2024-01-20 15:49:14 +00:00
|
|
|
else
|
|
|
|
echo "Error: please install a DDNet7-headless"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
get_test_names() {
|
2022-11-12 15:47:12 +00:00
|
|
|
(find client -name "*.rb";find server -name "*.rb") | tr '\n' ' '
|
|
|
|
}
|
2024-01-22 15:38:31 +00:00
|
|
|
invalid_test() {
|
2022-11-12 15:47:12 +00:00
|
|
|
local name="$1"
|
|
|
|
echo "Error: invalid test name '$name'"
|
|
|
|
echo " valid tests: $(get_test_names)"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
testname="${1:-client/chat.rb}"
|
|
|
|
|
|
|
|
if ! [[ "$testname" =~ (client|server)/.*\.rb$ ]]
|
2022-11-06 17:26:14 +00:00
|
|
|
then
|
2022-11-12 15:47:12 +00:00
|
|
|
invalid_test "$testname"
|
|
|
|
fi
|
|
|
|
if [ ! -f "$testname" ]
|
2022-11-06 17:26:14 +00:00
|
|
|
then
|
2022-11-12 15:47:12 +00:00
|
|
|
testname=${testname##*integration_test/}
|
|
|
|
if [ ! -f "$testname" ]
|
|
|
|
then
|
|
|
|
invalid_test "$testname"
|
|
|
|
fi
|
2022-11-06 17:26:14 +00:00
|
|
|
fi
|
2022-11-12 18:32:48 +00:00
|
|
|
if [[ "$testname" =~ ^client/ ]]
|
|
|
|
then
|
2022-11-14 09:25:28 +00:00
|
|
|
ruby_logfile="$logdir/ruby_client.txt"
|
2024-01-22 15:38:31 +00:00
|
|
|
ruby_logfile_err="$logdir/ruby_client_stderr.txt"
|
2022-11-12 18:32:48 +00:00
|
|
|
else
|
2022-11-14 09:25:28 +00:00
|
|
|
ruby_logfile="$logdir/ruby_server.txt"
|
2024-01-22 15:38:31 +00:00
|
|
|
ruby_logfile_err="$logdir/ruby_server_stderr.txt"
|
2022-11-12 18:32:48 +00:00
|
|
|
fi
|
2022-11-06 17:26:14 +00:00
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
kill_all_jobs() {
|
2024-01-21 07:32:43 +00:00
|
|
|
local i
|
|
|
|
local kill_pid
|
|
|
|
for i in "${!_kill_pids[@]}"
|
|
|
|
do
|
|
|
|
kill_pid="${_kill_pids[i]}"
|
|
|
|
[[ "$kill_pid" != "" ]] || continue
|
|
|
|
ps -p "$kill_pid" > /dev/null || continue
|
|
|
|
|
|
|
|
kill "$kill_pid" &> /dev/null
|
|
|
|
_kill_pids[i]='' # does not work because different job
|
|
|
|
done
|
2024-01-22 07:23:10 +00:00
|
|
|
pkill -f "$kill_marker"
|
2024-01-21 07:32:43 +00:00
|
|
|
}
|
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
cleanup() {
|
2022-11-12 17:31:40 +00:00
|
|
|
if [ "$tw_srv_running" == "1" ]
|
|
|
|
then
|
|
|
|
echo "[*] shutting down server ..."
|
|
|
|
pkill -f "$tw_srv_bin $srvcfg"
|
|
|
|
fi
|
2024-01-21 07:32:43 +00:00
|
|
|
kill_all_jobs
|
|
|
|
# timeout is extra otherwise it kills it self
|
|
|
|
[[ "$_timeout_pid" != "" ]] && ps -p "$_timeout_pid" >/dev/null && kill "$_timeout_pid"
|
2022-11-12 15:47:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup EXIT
|
2022-11-06 17:26:14 +00:00
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
fail() {
|
2022-11-05 17:41:06 +00:00
|
|
|
local msg="$1"
|
2024-01-21 08:05:02 +00:00
|
|
|
if [ ! -f "$tmpdir/fail.txt" ]
|
2024-01-20 15:49:14 +00:00
|
|
|
then
|
2024-01-21 08:05:02 +00:00
|
|
|
touch "$tmpdir/fail.txt"
|
|
|
|
# the first tail get swalloed
|
|
|
|
# idk why so tail twice to ensure
|
|
|
|
# getting output
|
|
|
|
# this is a bit ugly but it works
|
|
|
|
# maybe a sleep does as well
|
|
|
|
# or I still did not get flushing
|
|
|
|
tail "$ruby_logfile" &>/dev/null
|
2024-01-22 15:38:31 +00:00
|
|
|
tail "$ruby_logfile_err" &>/dev/null
|
2024-01-21 08:05:02 +00:00
|
|
|
if [[ "$testname" =~ ^client/ ]]
|
|
|
|
then
|
|
|
|
echo "[-] end of ruby client log:"
|
2024-01-22 15:38:31 +00:00
|
|
|
tail -n 10 "$ruby_logfile"
|
2024-01-21 08:05:02 +00:00
|
|
|
echo "[-] end of server log:"
|
|
|
|
tail "$logdir/server.txt"
|
|
|
|
else
|
|
|
|
echo "[-] end of ruby server log:"
|
2024-01-24 09:44:09 +00:00
|
|
|
cat "$ruby_logfile"
|
2024-01-21 08:05:02 +00:00
|
|
|
echo "[-] end of client log:"
|
2024-01-24 09:44:09 +00:00
|
|
|
cat "$logdir/client.txt"
|
2024-01-22 15:38:31 +00:00
|
|
|
fi
|
2024-01-24 10:07:17 +00:00
|
|
|
echo "CAT IF EMPTY OR NOT: $ruby_logfile_err"
|
|
|
|
cat "$ruby_logfile_err"
|
|
|
|
if grep -q '[^[:space:]]' "$ruby_logfile_err"
|
2024-01-22 15:38:31 +00:00
|
|
|
then
|
|
|
|
echo "[-] got ruby stderr $ruby_logfile_err"
|
|
|
|
cat "$ruby_logfile_err"
|
2024-01-21 08:05:02 +00:00
|
|
|
fi
|
2024-01-20 15:49:14 +00:00
|
|
|
fi
|
2024-01-22 15:38:31 +00:00
|
|
|
echo "[-][FATAL] $msg"
|
2022-11-05 17:41:06 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
timeout() {
|
2022-11-12 15:47:12 +00:00
|
|
|
local seconds="$1"
|
|
|
|
sleep "$seconds"
|
|
|
|
echo "[-] Timeout -> killing: $testname"
|
2024-01-21 08:05:02 +00:00
|
|
|
touch "$tmpdir/timeout.txt"
|
2024-01-21 07:32:43 +00:00
|
|
|
kill_all_jobs
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "Timeout"
|
2022-11-12 15:47:12 +00:00
|
|
|
}
|
|
|
|
|
2022-11-12 17:31:40 +00:00
|
|
|
echo "[*] running test '$testname' ..."
|
2024-01-21 08:05:02 +00:00
|
|
|
[[ -f "$tmpdir/timeout.txt" ]] && rm "$tmpdir"/timeout.txt
|
|
|
|
[[ -f "$tmpdir/fail.txt" ]] && rm "$tmpdir"/fail.txt
|
2024-01-22 15:38:31 +00:00
|
|
|
:>"$ruby_logfile_err"
|
2022-11-12 18:32:48 +00:00
|
|
|
if [[ "$testname" =~ ^client/ ]]
|
|
|
|
then
|
|
|
|
echo "ruby client log $(date)" > "$ruby_logfile"
|
|
|
|
echo "server log $(date)" > "$logdir/server.txt"
|
2024-01-22 15:26:05 +00:00
|
|
|
start_tw_server &
|
|
|
|
_kill_pids+=($!)
|
2022-11-12 18:32:48 +00:00
|
|
|
else
|
2024-01-20 15:49:14 +00:00
|
|
|
echo "ddnet7 client log $(date)" > "$logdir/client.txt"
|
|
|
|
echo "ruby server log $(date)" > "$ruby_logfile"
|
|
|
|
fi
|
2024-01-22 15:38:31 +00:00
|
|
|
run_ruby_test() {
|
|
|
|
if ! ruby "$testname" "$kill_marker" 2> "$ruby_logfile_err" 1> "$ruby_logfile"
|
2024-01-21 07:32:43 +00:00
|
|
|
then
|
|
|
|
fail "test $testname finished with non zero exit code"
|
|
|
|
fi
|
|
|
|
}
|
2024-01-22 15:26:05 +00:00
|
|
|
if [[ "$testname" =~ ^server/ ]]
|
|
|
|
then
|
|
|
|
run_ruby_test &
|
|
|
|
_kill_pids+=($!)
|
|
|
|
else
|
|
|
|
run_ruby_test
|
|
|
|
kill_all_jobs
|
|
|
|
fi
|
2024-01-20 15:49:14 +00:00
|
|
|
|
|
|
|
if [[ "$testname" =~ ^server/ ]]
|
|
|
|
then
|
2024-01-22 07:23:10 +00:00
|
|
|
connect_ddnet7_client "$kill_marker" &>> "$logdir/client.txt" &
|
2024-01-22 15:38:31 +00:00
|
|
|
_client_pid=$!
|
|
|
|
_kill_pids+=("$_client_pid")
|
2024-01-20 15:49:14 +00:00
|
|
|
sleep 1
|
2022-11-12 18:32:48 +00:00
|
|
|
fi
|
2024-01-22 15:38:31 +00:00
|
|
|
timeout 20 "$kill_marker" &
|
2024-01-21 07:32:43 +00:00
|
|
|
_timeout_pid=$!
|
2022-11-12 15:47:12 +00:00
|
|
|
|
2024-01-22 15:38:31 +00:00
|
|
|
fifo() {
|
2024-01-22 15:16:56 +00:00
|
|
|
local cmd="$1"
|
|
|
|
local fifo_file="$2"
|
|
|
|
echo "[*] $cmd >> $fifo_file"
|
2024-02-20 03:23:40 +00:00
|
|
|
local cmd_slug
|
|
|
|
cmd_slug="${cmd//[^a-zA-Z0-9]/_}"
|
|
|
|
echo "echo \"FIFO: $cmd_slug\"" >> "$fifo_file"
|
2024-01-22 15:16:56 +00:00
|
|
|
echo "$cmd" >> "$fifo_file"
|
|
|
|
}
|
2024-01-22 15:38:31 +00:00
|
|
|
assert_in_log() {
|
|
|
|
# usage: assert_in_log string path [num_matches"
|
|
|
|
# examples:
|
|
|
|
# assert_in_log "string to find" "/path/to/log.txt"
|
|
|
|
# assert_in_log "string to find" "/path/to/log.txt" 2
|
|
|
|
local needle="$1"
|
|
|
|
local logfile_path="$2"
|
|
|
|
local num_matches="$3"
|
2024-01-23 14:00:31 +00:00
|
|
|
if ! grep -qF "$needle" "$logfile_path"
|
2024-01-22 15:38:31 +00:00
|
|
|
then
|
|
|
|
echo "[-] Error: did not find expected string in logs"
|
|
|
|
echo "[-]"
|
|
|
|
echo "[-] expected: $needle"
|
|
|
|
echo "[-] in file: $ruby_logfile"
|
|
|
|
echo "[-]"
|
2024-01-24 10:07:17 +00:00
|
|
|
# fail "assert failed"
|
2024-01-22 15:38:31 +00:00
|
|
|
fi
|
|
|
|
if [ "$num_matches" != "" ]
|
|
|
|
then
|
|
|
|
local actual_matches
|
2024-01-23 14:00:31 +00:00
|
|
|
actual_matches="$(grep -cF "$needle" "$logfile_path")"
|
2024-01-22 15:38:31 +00:00
|
|
|
if [ "$actual_matches" != "$num_matches" ]
|
|
|
|
then
|
|
|
|
echo "[-] Error: found string unexpected amount of times in log file"
|
|
|
|
echo "[-]"
|
|
|
|
echo "[-] expected: $needle"
|
|
|
|
echo "[-] in file: $ruby_logfile"
|
|
|
|
echo "[-]"
|
|
|
|
echo "[-] expected num hits: $num_matches"
|
|
|
|
echo "[-] got num hits: $actual_matches"
|
|
|
|
echo "[-]"
|
2024-01-24 10:07:17 +00:00
|
|
|
# fail "assert failed"
|
2024-01-22 15:38:31 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "[*] $needle .. OK"
|
|
|
|
}
|
2024-01-22 15:16:56 +00:00
|
|
|
|
2022-11-12 15:47:12 +00:00
|
|
|
if [ "$testname" == "client/chat.rb" ]
|
2022-11-05 17:41:06 +00:00
|
|
|
then
|
2022-11-12 17:31:40 +00:00
|
|
|
if ! grep -q 'hello world' "$logdir/server.txt"
|
2022-11-05 17:41:06 +00:00
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "did not find chat message in server log"
|
2022-11-05 17:41:06 +00:00
|
|
|
fi
|
2022-11-12 15:47:12 +00:00
|
|
|
elif [ "$testname" == "client/reconnect.rb" ]
|
2022-11-05 17:41:06 +00:00
|
|
|
then
|
2022-11-12 17:31:40 +00:00
|
|
|
if ! grep -q 'bar' "$logdir/server.txt"
|
2022-11-05 17:41:06 +00:00
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "did not find 2nd chat message in server log"
|
2022-11-05 17:41:06 +00:00
|
|
|
fi
|
2022-11-12 15:47:12 +00:00
|
|
|
elif [ "$testname" == "client/rcon.rb" ]
|
2022-11-06 17:26:14 +00:00
|
|
|
then
|
2022-11-12 17:31:40 +00:00
|
|
|
sleep 1
|
2022-11-12 15:47:12 +00:00
|
|
|
if pgrep -f "$tw_srv_bin $srvcfg"
|
2022-11-06 17:26:14 +00:00
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "server still running rcon shutdown failed"
|
2022-11-06 17:26:14 +00:00
|
|
|
fi
|
2022-11-20 09:13:07 +00:00
|
|
|
elif [ "$testname" == "client/srv_say.rb" ]
|
|
|
|
then
|
|
|
|
if ! grep -q '^\[chat\].*hello' "$logdir/ruby_client.txt"
|
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "missing 'hello' chat message in client log"
|
2022-11-20 09:13:07 +00:00
|
|
|
fi
|
2022-11-14 09:25:28 +00:00
|
|
|
elif [ "$testname" == "client/multiple_blocks.rb" ]
|
|
|
|
then
|
|
|
|
sleep 1
|
|
|
|
if pgrep -f "$tw_srv_bin $srvcfg"
|
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "server still running rcon shutdown failed (2 blocks)"
|
2022-11-14 09:25:28 +00:00
|
|
|
fi
|
|
|
|
block1_ln="$(grep -n "block 1" "$ruby_logfile" | cut -d':' -f1)"
|
|
|
|
block2_ln="$(grep -n "block 2" "$ruby_logfile" | cut -d':' -f1)"
|
|
|
|
if [ "$block1_ln" == "" ]
|
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "'block 1' not found in client log"
|
2022-11-14 09:25:28 +00:00
|
|
|
fi
|
|
|
|
if [ "$block2_ln" == "" ]
|
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "'block 2' not found in client log"
|
2022-11-14 09:25:28 +00:00
|
|
|
fi
|
|
|
|
if [[ ! "$block1_ln" =~ ^[0-9]+$ ]]
|
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "failed to parse line number of 'block 1' got='$block1_ln'"
|
2022-11-14 09:25:28 +00:00
|
|
|
fi
|
|
|
|
if [[ ! "$block2_ln" =~ ^[0-9]+$ ]]
|
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "failed to parse line number of 'block 2' got='$block2_ln'"
|
2022-11-14 09:25:28 +00:00
|
|
|
fi
|
|
|
|
# ensure block call order matches definition order
|
|
|
|
if [ "$block1_ln" -gt "$block2_ln" ]
|
|
|
|
then
|
2024-01-22 15:38:31 +00:00
|
|
|
fail "'block 1' found after 'block 2' in client log"
|
2022-11-14 09:25:28 +00:00
|
|
|
fi
|
2024-01-20 15:49:14 +00:00
|
|
|
elif [ "$testname" == "server/connect.rb" ]
|
|
|
|
then
|
2024-01-22 15:16:56 +00:00
|
|
|
fifo "rcon_auth test" "$cl_fifo"
|
|
|
|
sleep 1
|
|
|
|
fifo "rcon shutdown" "$cl_fifo"
|
2024-01-20 15:49:14 +00:00
|
|
|
sleep 1
|
2024-01-22 15:16:56 +00:00
|
|
|
fifo "quit" "$cl_fifo"
|
2024-01-22 15:38:31 +00:00
|
|
|
# ddnet quitting can get stuck so send a kill to ensure it dies
|
|
|
|
kill "$_client_pid"
|
|
|
|
|
|
|
|
assert_in_log "'test_client' joined the game" "$ruby_logfile" 1
|
|
|
|
assert_in_log "rcon='shutdown'" "$ruby_logfile" 1
|
2024-01-23 14:00:31 +00:00
|
|
|
elif [ "$testname" == "server/chat.rb" ]
|
|
|
|
then
|
|
|
|
fifo "say hello gamers" "$cl_fifo"
|
|
|
|
sleep 1
|
|
|
|
fifo "say uwu" "$cl_fifo"
|
|
|
|
sleep 1
|
|
|
|
fifo "rcon_auth test" "$cl_fifo"
|
|
|
|
sleep 1
|
|
|
|
fifo "rcon shutdown" "$cl_fifo"
|
|
|
|
sleep 1
|
|
|
|
fifo "quit" "$cl_fifo"
|
|
|
|
# ddnet quitting can get stuck so send a kill to ensure it dies
|
|
|
|
kill "$_client_pid"
|
|
|
|
|
2024-01-24 09:44:09 +00:00
|
|
|
sleep 1 # wait for logfiles to be written
|
|
|
|
|
2024-01-23 14:00:31 +00:00
|
|
|
assert_in_log "hello gamers" "$ruby_logfile" 1
|
|
|
|
assert_in_log "[testchat] test_client: uwu" "$ruby_logfile" 1
|
2022-11-05 17:41:06 +00:00
|
|
|
else
|
|
|
|
echo "Error: unkown test '$testname'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-01-21 07:32:43 +00:00
|
|
|
echo "[*] waiting for jobs to finish ..."
|
2024-01-22 15:16:56 +00:00
|
|
|
while true
|
|
|
|
do
|
|
|
|
running_jobs="$(jobs | grep -v timeout)"
|
|
|
|
if [ "$running_jobs" == "" ]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "[*] waiting for:"
|
|
|
|
echo "$running_jobs"
|
|
|
|
sleep 1
|
|
|
|
done
|
2024-01-21 07:32:43 +00:00
|
|
|
|
2024-01-21 08:05:02 +00:00
|
|
|
if [ -f "$tmpdir/timeout.txt" ]
|
2022-11-12 15:47:12 +00:00
|
|
|
then
|
2024-01-20 15:49:14 +00:00
|
|
|
echo "[-] Error timeouted"
|
2022-11-12 15:47:12 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-11-06 17:26:14 +00:00
|
|
|
echo "[+] Test passed"
|
2022-11-05 17:41:06 +00:00
|
|
|
|