diff --git a/tools/smoke.sh b/tools/smoke.sh index aacbcc5..fe9185b 100755 --- a/tools/smoke.sh +++ b/tools/smoke.sh @@ -77,7 +77,26 @@ run --listen --port="$port" --seed="$seed" --bots=4 --ticks=120 --unthrottled [[ "$(field start listening)" == "true" ]] || fail "a listening server didn't say it was listening" [[ "$(field start match_phase)" == "lobby" ]] || fail "a listening server didn't start in the lobby" +# SIGTERM to the packaged wrapper becomes a clean stop: stats and stop lines, exit 0. +state="$(mktemp -d)" +TIDEWALL_ENGINE="$(pwd)/tools/godot/$(sed -n 's/^\([0-9a-f]*\) *tools\/godot\/\(.*_linux\.x86_64\)$/\2/p' tools/engine.sha512)" \ + TIDEWALL_GAME="$(pwd)" TIDEWALL_STATE="$state" \ + packaging/server/tidewall-server --seed="$seed" --bots=2 >"$state/log" 2>&1 & +wrapper=$! +for _ in $(seq 1 100); do + grep -q '"event":"start"' "$state/log" 2>/dev/null && break + sleep 0.1 +done +kill -TERM "$wrapper" +wait "$wrapper" +code=$? +output="$(grep '^{' "$state/log")" +rm -rf "$state" +[[ "$code" -eq 0 ]] || fail "SIGTERM to the server wrapper exited $code, expected 0" +grep -q '"event":"stats"' <<<"$output" || fail "SIGTERM left no stats line" +[[ "$(field stop exit_code)" == "0" ]] || fail "SIGTERM left no clean stop line" + if [[ "$status" -eq 0 ]]; then - echo "smoke: ok (clean run, reproducible hash, script error exits 1, bad config exits 2, listens)" + echo "smoke: ok (clean run, reproducible hash, script error exits 1, bad config exits 2, listens, SIGTERM stops cleanly)" fi exit "$status"