Skip to content

Commit ba40b39

Browse files
committedMay 5, 2021
Add basic client-server test to CI
1 parent 08f1a7f commit ba40b39

File tree

3 files changed

+63
-40
lines changed

3 files changed

+63
-40
lines changed
 

Diff for: ‎.github/workflows/build.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
- name: Install deps
8181
run: |
8282
source ./util/ci/common.sh
83-
install_linux_deps clang-3.9
83+
install_linux_deps clang-3.9 gdb
8484
8585
- name: Build
8686
run: |
@@ -89,10 +89,14 @@ jobs:
8989
CC: clang-3.9
9090
CXX: clang++-3.9
9191

92-
- name: Test
92+
- name: Unittest
9393
run: |
9494
./bin/minetest --run-unittests
9595
96+
- name: Integration test
97+
run: |
98+
./util/test_multiplayer.sh
99+
96100
# This is the current clang version
97101
clang_9:
98102
runs-on: ubuntu-18.04

Diff for: ‎util/ci/common.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ install_linux_deps() {
1111
shift
1212
pkgs+=(libirrlicht-dev)
1313
else
14-
wget "https://github.com/minetest/irrlicht/releases/download/1.9.0mt1/ubuntu-bionic.tar.gz"
14+
# TODO: return old URL when IrrlichtMt 1.9.0mt2 is tagged
15+
#wget "https://github.com/minetest/irrlicht/releases/download/1.9.0mt1/ubuntu-bionic.tar.gz"
16+
wget "http://minetest.kitsunemimi.pw/irrlichtmt-patched-temporary.tgz" -O ubuntu-bionic.tar.gz
1517
sudo tar -xaf ubuntu-bionic.tar.gz -C /usr/local
1618
fi
1719

Diff for: ‎util/test_multiplayer.sh

+54-37
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,58 @@ dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
33
gameid=devtest
44
minetest=$dir/../bin/minetest
55
testspath=$dir/../tests
6-
worldpath=$testspath/testworld_$gameid
7-
configpath=$testspath/configs
8-
logpath=$testspath/log
9-
conf_server=$configpath/minetest.conf.multi.server
10-
conf_client1=$configpath/minetest.conf.multi.client1
11-
conf_client2=$configpath/minetest.conf.multi.client2
12-
log_server=$logpath/server.log
13-
log_client1=$logpath/client1.log
14-
log_client2=$logpath/client2.log
15-
16-
mkdir -p $worldpath
17-
mkdir -p $configpath
18-
mkdir -p $logpath
19-
20-
echo -ne 'client1::shout,interact,settime,teleport,give
21-
client2::shout,interact,settime,teleport,give
22-
' > $worldpath/auth.txt
23-
24-
echo -ne '' > $conf_server
25-
26-
echo -ne '# client 1 config
27-
screenW=500
28-
screenH=380
29-
name=client1
30-
viewing_range_nodes_min=10
31-
' > $conf_client1
32-
33-
echo -ne '# client 2 config
34-
screenW=500
35-
screenH=380
36-
name=client2
37-
viewing_range_nodes_min=10
38-
' > $conf_client2
39-
40-
echo $(sleep 1; $minetest --disable-unittests --logfile $log_client1 --config $conf_client1 --go --address localhost) &
41-
echo $(sleep 2; $minetest --disable-unittests --logfile $log_client2 --config $conf_client2 --go --address localhost) &
42-
$minetest --disable-unittests --server --logfile $log_server --config $conf_server --world $worldpath --gameid $gameid
6+
conf_client1=$testspath/client1.conf
7+
conf_server=$testspath/server.conf
8+
worldpath=$testspath/world
439

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+
gdbrun () {
23+
gdb -q -ex 'set confirm off' -ex 'r' -ex 'bt' -ex 'quit' --args "$@"
24+
}
25+
26+
[ -e $minetest ] || { echo "executable $minetest missing"; exit 1; }
27+
28+
rm -rf $worldpath
29+
mkdir -p $worldpath/worldmods/test
30+
31+
printf '%s\n' >$testspath/client1.conf \
32+
video_driver=null name=client1 viewing_range=10 \
33+
enable_{sound,minimap,shaders}=false
34+
35+
printf '%s\n' >$testspath/server.conf \
36+
max_block_send_distance=1
37+
38+
cat >$worldpath/worldmods/test/init.lua <<"LUA"
39+
core.after(0, function()
40+
io.close(io.open(core.get_worldpath() .. "/startup", "w"))
41+
end)
42+
core.register_on_joinplayer(function(player)
43+
io.close(io.open(core.get_worldpath() .. "/player_joined", "w"))
44+
core.request_shutdown("", false, 2)
45+
end)
46+
LUA
47+
48+
echo "Starting server"
49+
gdbrun $minetest --server --config $conf_server --world $worldpath --gameid $gameid 2>&1 | sed -u 's/^/(server) /' &
50+
waitfor $worldpath/startup
51+
52+
echo "Starting client"
53+
gdbrun $minetest --config $conf_client1 --go --address 127.0.0.1 2>&1 | sed -u 's/^/(client) /' &
54+
waitfor $worldpath/player_joined
55+
56+
echo "Waiting for client and server to exit"
57+
wait
58+
59+
echo "Success"
60+
exit 0

0 commit comments

Comments
 (0)
Please sign in to comment.