2024-09-27 20:26:12 +02:00
|
|
|
#!/bin/bash
|
|
|
|
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
gameid=${gameid:-devtest}
|
2024-10-27 14:04:51 +01:00
|
|
|
executable=$dir/../bin/luanti
|
2024-09-27 20:26:12 +02:00
|
|
|
testspath=$dir/../tests
|
|
|
|
conf_server=$testspath/server.conf
|
|
|
|
worldpath=$testspath/world
|
|
|
|
|
2024-10-27 14:04:51 +01:00
|
|
|
[ -e "$executable" ] || { echo "executable $executable missing"; exit 1; }
|
2024-09-27 20:26:12 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2024-10-27 14:04:51 +01:00
|
|
|
# make sure we can tell apart sanitizer and luanti errors
|
2024-09-27 20:26:12 +02:00
|
|
|
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
|
2024-10-27 14:04:51 +01:00
|
|
|
run "$executable" "${args[@]}"
|
2024-09-27 20:26:12 +02:00
|
|
|
echo "---------------"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "All done."
|
|
|
|
exit 0
|