-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test script for server error cases
- Loading branch information
Showing
4 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
error("intentional") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
gameid=${gameid:-devtest} | ||
minetest=$dir/../bin/minetest | ||
testspath=$dir/../tests | ||
conf_server=$testspath/server.conf | ||
worldpath=$testspath/world | ||
|
||
[ -e "$minetest" ] || { echo "executable $minetest missing"; exit 1; } | ||
|
||
write_config () { | ||
printf '%s\n' >"$conf_server" \ | ||
helper_mode=error mg_name=singlenode "$@" | ||
} | ||
|
||
run () { | ||
timeout 10 "$@" | ||
r=$? | ||
echo "Exit status: $r" | ||
[ $r -eq 124 ] && echo "(timed out)" | ||
if [ $r -ne 1 ]; then | ||
echo "-> Test failed" | ||
exit 1 | ||
fi | ||
} | ||
|
||
rm -rf "$worldpath" | ||
mkdir -p "$worldpath/worldmods" | ||
|
||
ln -s "$dir/helper_mod" "$worldpath/worldmods/" | ||
|
||
args=(--server --config "$conf_server" --world "$worldpath" --gameid $gameid) | ||
|
||
# make sure we can tell apart sanitizer and minetest errors | ||
export ASAN_OPTIONS="exitcode=42" | ||
export MSAN_OPTIONS="exitcode=42" | ||
|
||
# see helper_mod/init.lua for the different types | ||
for n in $(seq 1 4); do | ||
write_config error_type=$n | ||
run "$minetest" "${args[@]}" | ||
echo "---------------" | ||
done | ||
|
||
echo "All done." | ||
exit 0 |