mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-08 15:28:42 +00:00

This code ended up ignoring *all* MP test failures, in particular the one fixed in commit 11d7b9f0cfe29ab6d6b5829c8e337b7cb67eeb18. I'd test the code and fix it if I could, but unfortunately I can no longer develop on GNU/Linux because of PC issues (which I mentioned in Discord). Therefore I'm just reverting the entire change.
65 lines
1.5 KiB
Bash
Executable File
65 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e #Error if any line errors
|
|
set -m #Enable job control
|
|
set -v #Print shell commands as they are read
|
|
|
|
TIMEOUT_TIME=300
|
|
LOOP_TIME=6
|
|
|
|
./wesnothd --port 12345 --log-debug=server --log-warning=config &
|
|
serverpid=$!
|
|
|
|
./wesnoth --plugin=host.lua --server=localhost:12345 --username=host --mp-test --noaddons --nogui &
|
|
hostpid=$!
|
|
|
|
./wesnoth --plugin=join.lua --server=localhost:12345 --username=join --mp-test --noaddons --nogui &
|
|
joinpid=$!
|
|
|
|
START_TIME=$SECONDS
|
|
HOST_RUNNING=yes
|
|
JOIN_RUNNING=yes
|
|
while true; do
|
|
# Timeout
|
|
EXEC_TIME=$(($SECONDS - $START_TIME))
|
|
if [ $EXEC_TIME -gt $TIMEOUT_TIME ]; then
|
|
kill $hostpid 2>/dev/null
|
|
kill $joinpid 2>/dev/null
|
|
break
|
|
fi
|
|
# Check if clients still running
|
|
if ! kill -0 $hostpid 2>/dev/null; then
|
|
HOST_RUNNING=no
|
|
fi
|
|
if ! kill -0 $joinpid 2>/dev/null; then
|
|
JOIN_RUNNING=no
|
|
fi
|
|
|
|
sleep $LOOP_TIME
|
|
|
|
# If both are finished, we're done
|
|
if ! (kill -0 $hostpid 2>/dev/null || kill -0 $joinpid 2>/dev/null); then
|
|
break
|
|
fi
|
|
# If one has finished previously, kill the other
|
|
if [ $HOST_RUNNING = "no" ]; then
|
|
echo "Host finished at least $LOOP_TIME seconds ago. Killing join"
|
|
kill $joinpid 2>/dev/null
|
|
break
|
|
fi
|
|
if [ $JOIN_RUNNING = "no" ]; then
|
|
echo "Join finished at least $LOOP_TIME seconds ago. Killing host"
|
|
kill $hostpid 2>/dev/null
|
|
break
|
|
fi
|
|
done
|
|
|
|
STATUS=0
|
|
|
|
wait $hostpid || STATUS=1
|
|
|
|
wait $joinpid || STATUS=1
|
|
|
|
kill $serverpid
|
|
|
|
exit $STATUS
|