1
0

test_error_cases.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. gameid=${gameid:-devtest}
  4. executable=$dir/../bin/luanti
  5. testspath=$dir/../tests
  6. conf_server=$testspath/server.conf
  7. worldpath=$testspath/world
  8. [ -e "$executable" ] || { echo "executable $executable missing"; exit 1; }
  9. write_config () {
  10. printf '%s\n' >"$conf_server" \
  11. helper_mode=error mg_name=singlenode "$@"
  12. }
  13. run () {
  14. timeout 10 "$@"
  15. r=$?
  16. echo "Exit status: $r"
  17. [ $r -eq 124 ] && echo "(timed out)"
  18. if [ $r -ne 1 ]; then
  19. echo "-> Test failed"
  20. exit 1
  21. fi
  22. }
  23. rm -rf "$worldpath"
  24. mkdir -p "$worldpath/worldmods"
  25. ln -s "$dir/helper_mod" "$worldpath/worldmods/"
  26. args=(--server --config "$conf_server" --world "$worldpath" --gameid $gameid)
  27. # make sure we can tell apart sanitizer and luanti errors
  28. export ASAN_OPTIONS="exitcode=42"
  29. export MSAN_OPTIONS="exitcode=42"
  30. # see helper_mod/init.lua for the different types
  31. for n in $(seq 1 4); do
  32. write_config error_type=$n
  33. run "$executable" "${args[@]}"
  34. echo "---------------"
  35. done
  36. echo "All done."
  37. exit 0