]> git.lizzy.rs Git - minetest.git/blob - util/test_multiplayer.sh
Implement --debugger option to improve UX when debugging crashes (#13157)
[minetest.git] / util / test_multiplayer.sh
1 #!/bin/bash
2 dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3 gameid=${gameid:-devtest}
4 minetest=$dir/../bin/minetest
5 testspath=$dir/../tests
6 conf_client1=$testspath/client1.conf
7 conf_server=$testspath/server.conf
8 worldpath=$testspath/world
9
10 waitfor () {
11         n=30
12         while [ $n -gt 0 ]; do
13                 [ -f "$1" ] && return 0
14                 sleep 0.5
15                 ((n-=1))
16         done
17         echo "Waiting for ${1##*/} timed out"
18         pkill -P $$
19         exit 1
20 }
21
22 [ -e "$minetest" ] || { echo "executable $minetest missing"; exit 1; }
23
24 rm -rf "$worldpath"
25 mkdir -p "$worldpath/worldmods"
26
27 printf '%s\n' >"$testspath/client1.conf" \
28         video_driver=null name=client1 viewing_range=10 \
29         enable_{sound,minimap,shaders}=false
30
31 printf '%s\n' >"$testspath/server.conf" \
32         max_block_send_distance=1 devtest_unittests_autostart=true \
33         helper_mode=devtest
34
35 ln -s "$dir/helper_mod" "$worldpath/worldmods/"
36
37 echo "Starting server"
38 "$minetest" --debugger --server --config "$conf_server" --world "$worldpath" --gameid $gameid 2>&1 | sed -u 's/^/(server) /' &
39 waitfor "$worldpath/startup"
40
41 echo "Starting client"
42 "$minetest" --debugger --config "$conf_client1" --go --address 127.0.0.1 2>&1 | sed -u 's/^/(client) /' &
43 waitfor "$worldpath/done"
44
45 echo "Waiting for client and server to exit"
46 wait
47
48 if [ -f "$worldpath/test_failure" ]; then
49         echo "There were test failures."
50         exit 1
51 fi
52 echo "Success"
53 exit 0