Files
BT411/scratchpad/night15/fade_bench.sh
T

45 lines
2.0 KiB
Bash

#!/usr/bin/env bash
# #156: the mission start/end fade. 2-node, 40s round -- the relay owns the
# clock and sends StopMission at length end (btconsole.py), so both fade edges
# fire: MissionStarting (white flash 0.1s + 1.0s fade-in from white) and
# MissionEnding (1.0s fade-out to black; the app stops ~2s later inside the
# player's 3.0s ladder). Receipts: [fade] armed + phase 1/2/3/4 transitions
# (BT_FADE_LOG). PASS: node A's log shows armed, then phases 1,2,3,4 in
# order, and the phase-4 line's simState is the ending state (4).
set -x
. /c/git/bt411/scratchpad/night6/bench_common.sh
cd /c/git/bt411/content || exit 1
taskkill //F //IM btl4.exe >/dev/null 2>&1; sleep 3
rm -f fade_a.log fade_b.log fade_r.log
bt_expert_egg MP.EGG FADE.EGG
sed -i "s/^map=.*/map=grass/; s/^time=.*/time=day/; s/^vehicle=.*/vehicle=madcat/; s/^length=.*/length=40/" FADE.EGG
grep -aq "^length=40" FADE.EGG || { echo "FAIL: egg length not set"; exit 1; }
( export BT_FADE_LOG=1 BT_MATCHLOG=1
bt_launch fade_b.log FADE.EGG 0x0C -net 1601 )
sleep 2
( export BT_FADE_LOG=1 BT_MATCHLOG=1
bt_launch fade_a.log FADE.EGG 0x03 -net 1501 )
sleep 5
python ../tools/btconsole.py FADE.EGG 127.0.0.1:1501 127.0.0.1:1601 > fade_r.log 2>&1 &
R=$!; sleep 110; kill $R 2>/dev/null; sleep 2
bt_kill_ours; sleep 2; taskkill //F //IM btl4.exe >/dev/null 2>&1
python - <<'PY'
import io, re, sys
ok = True
for node in ("fade_a.log", "fade_b.log"):
txt = io.open(node, encoding="latin-1", errors="replace").read()
armed = "[fade] armed" in txt
phases = [int(m.group(1)) for m in re.finditer(r"\[fade\] phase (\d)", txt)]
end4 = re.search(r"\[fade\] phase 4 \(simState=4\)", txt) is not None
print("%s: armed=%d phases=%s end-edge-ok=%d" % (node, armed, phases, end4))
want = [1, 2, 3, 4]
seq_ok = [p for p in phases if p in want] [:4] == want
if not (armed and seq_ok and end4):
ok = False
print("VERDICT:", "PASS -- flash + fade-in + fade-out ran on both nodes"
if ok else "FAIL -- phase sequence incomplete (see above)")
sys.exit(0 if ok else 1)
PY