make dist (tools/dist.sh) checks the official export templates against tools/engine.sha512, installs only the Linux x86_64 ones into the repo-local engine data, exports the "Linux" preset, checks the binary is the verified release template, and packs build/dist/tidewall-<version>-linux-x86_64.tar.gz with a .sha256: tidewall.x86_64, tidewall.pck, a tidewall-server launcher that runs the same game headless with clean SIGTERM handling, an example server.cfg, README, VERSION, licences and asset provenance. BuildInfo gives the version (application/config/version, now 0.9.0) and the commit (build_commit.txt written by make dist, or .git in a checkout). The main menu shows "Version 0.9.0 (commit)" and the server's start log line carries version and commit. make dist-check (tools/dist_check.sh) unpacks the package outside the repo with HOME and XDG dirs in a temp dir and runs smoke against it (new SMOKE_DIST mode), a whole bot match, and the exported game joining the exported server over loopback. A release template crashes on a call on null (exit 139) and ignores invalid calls, so in package mode smoke's fault check expects only a non-zero exit. Closes #60 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
127 lines
5.2 KiB
Bash
Executable File
127 lines
5.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Boots the headless server, runs a full-size match for 1,000 ticks, prints the timing
|
|
# statistics, and checks that the server:
|
|
# - exits 0 and logs start, stats and stop lines that all carry the seed,
|
|
# - produces the same state hash when run again with the same seed,
|
|
# - exits non-zero when a script error happens (a deliberate --fault),
|
|
# - exits non-zero on a bad command line,
|
|
# - listens on a UDP port when asked to.
|
|
#
|
|
# tools/smoke.sh unthrottled, so it finishes in seconds
|
|
# SMOKE_REALTIME=1 tools/smoke.sh at the real 30 Hz tick rate (about 34 seconds)
|
|
# SMOKE_DIST=DIR tools/smoke.sh the same checks on an unpacked release package
|
|
# (R1): DIR/tidewall-server instead of the repo
|
|
set -uo pipefail
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
|
|
|
seed="${SMOKE_SEED:-20261109}"
|
|
ticks="${SMOKE_TICKS:-1000}"
|
|
pace="--unthrottled"
|
|
[[ "${SMOKE_REALTIME:-0}" == "1" ]] && pace=""
|
|
status=0
|
|
code=0
|
|
dist="${SMOKE_DIST:-}"
|
|
if [[ -n "$dist" ]]; then
|
|
[[ -x "$dist/tidewall-server" ]] || { echo "smoke FAIL: no $dist/tidewall-server"; exit 2; }
|
|
dist_state="$(mktemp -d)"
|
|
trap 'rm -rf "$dist_state"' EXIT
|
|
fi
|
|
|
|
# run <args...>: runs the server, sets $output (JSON lines only) and $code.
|
|
run() {
|
|
local raw
|
|
if [[ -n "$dist" ]]; then
|
|
raw="$(TIDEWALL_STATE="$dist_state" timeout --signal=KILL 300 "$dist/tidewall-server" "$@" 2>&1)"
|
|
else
|
|
raw="$(timeout --signal=KILL 300 tools/godot.sh -- --server "$@" 2>&1)"
|
|
fi
|
|
code=$?
|
|
output="$(grep '^{' <<<"$raw")"
|
|
stderr_tail="$(grep -v '^{' <<<"$raw" | tail -n 15)"
|
|
}
|
|
|
|
# field <event> <key>: prints a value from the first log line of that event.
|
|
field() {
|
|
grep -m1 "\"event\":\"$1\"" <<<"$output" | sed -E "s/.*\"$2\":(\"[^\"]*\"|[^,}]*).*/\1/" | tr -d '"'
|
|
}
|
|
|
|
fail() {
|
|
echo "smoke FAIL: $*"
|
|
status=1
|
|
}
|
|
|
|
run --seed="$seed" --bots=24 --ticks="$ticks" --log-every=250 $pace
|
|
if [[ "$code" -ne 0 ]]; then
|
|
fail "server exited $code"
|
|
echo "$output"
|
|
echo "$stderr_tail"
|
|
fi
|
|
for event in start stats stop; do
|
|
grep -q "\"event\":\"$event\"" <<<"$output" || fail "no '$event' log line"
|
|
done
|
|
lines="$(wc -l <<<"$output")"
|
|
seeded="$(grep -c "\"seed\":$seed[,}]" <<<"$output")"
|
|
[[ "$lines" -eq "$seeded" ]] || fail "only $seeded of $lines log lines carry the seed"
|
|
[[ "$(field stats ticks)" == "$ticks" ]] || fail "ran $(field stats ticks) ticks, expected $ticks"
|
|
hash="$(field stats state_hash)"
|
|
echo "smoke: $ticks ticks, 24 bots, seed $seed${dist:+, release package $dist}"
|
|
echo "smoke: tick us min $(field stats min_us) mean $(field stats mean_us) p50 $(field stats p50_us)" \
|
|
"p95 $(field stats p95_us) p99 $(field stats p99_us) max $(field stats max_us)," \
|
|
"$(field stats over_budget) over the $(field stats budget_us) us budget"
|
|
echo "smoke: state hash $hash"
|
|
|
|
run --seed="$seed" --bots=24 --ticks="$ticks" --unthrottled
|
|
[[ "$code" -eq 0 && "$(field stats state_hash)" == "$hash" ]] \
|
|
|| fail "a second run with the same seed gave a different state hash"
|
|
|
|
run --seed="$seed" --bots=2 --ticks=50 --unthrottled --fault=script-error
|
|
if [[ -n "$dist" ]]; then
|
|
# A release template has no script error checks: the call on null crashes the
|
|
# process (139) rather than being reported. Either way it must not exit 0.
|
|
[[ "$code" -ne 0 ]] || fail "a script error exited 0 in the release package"
|
|
else
|
|
[[ "$code" -eq 1 ]] || fail "a script error exited $code, expected 1"
|
|
[[ "$(field stop errors)" -ge 1 ]] || fail "a script error wasn't counted in the stop line"
|
|
fi
|
|
|
|
run --bots=99 --nonsense
|
|
[[ "$code" -eq 2 ]] || fail "a bad command line exited $code, expected 2"
|
|
grep -q '"event":"config_error"' <<<"$output" || fail "a bad command line logged no config_error"
|
|
|
|
# A listening server opens its port, waits in the lobby with nobody there, and stops cleanly.
|
|
port=$((20000 + RANDOM % 20000))
|
|
run --listen --port="$port" --seed="$seed" --bots=4 --ticks=120 --unthrottled
|
|
[[ "$code" -eq 0 ]] || fail "a listening server exited $code"
|
|
[[ "$(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)"
|
|
if [[ -n "$dist" ]]; then
|
|
TIDEWALL_STATE="$state" "$dist/tidewall-server" --seed="$seed" --bots=2 >"$state/log" 2>&1 &
|
|
else
|
|
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 &
|
|
fi
|
|
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
|
|
fault_exit="1"
|
|
[[ -n "$dist" ]] && fault_exit="non-zero"
|
|
echo "smoke: ok (clean run, reproducible hash, script error exits $fault_exit, bad config exits 2, listens, SIGTERM stops cleanly)"
|
|
fi
|
|
exit "$status"
|