aboutsummaryrefslogtreecommitdiff
path: root/tests/pi-live.sh
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-11-09 03:09:33 +0200
committerIgor Soarez <igor@soarez.org>2026-11-09 03:09:33 +0200
commit87001d7d380173c3d76246d4c0ecdd7b037a619f (patch)
tree293f12afb1a9a91990caa366de28b8c30d63ec64 /tests/pi-live.sh
parent1231244bafa0f48b302b596a407512d494494f3b (diff)
test: restore after tmux is stopped the ways a restart or logout stops it
Diffstat (limited to 'tests/pi-live.sh')
-rwxr-xr-xtests/pi-live.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/pi-live.sh b/tests/pi-live.sh
index 5839aa5..98f0e36 100755
--- a/tests/pi-live.sh
+++ b/tests/pi-live.sh
@@ -35,6 +35,8 @@ note() { echo " note $1"; }
t() { tmux -u -L "$R" "$@"; }
cleanup() {
t kill-server 2>/dev/null
+ # A server stopped with SIGKILL leaves its socket.
+ rm -f "${TMUX_TMPDIR:-/tmp}/tmux-$(id -u)/$R"
[ -n "${DAEMON_PID:-}" ] && kill "$DAEMON_PID" 2>/dev/null
[ -n "${FAKE_PID:-}" ] && kill "$FAKE_PID" 2>/dev/null
if [ -n "${PI_LIVE_KEEP:-}" ]; then echo "kept $D"; else rm -rf "$D"; fi
@@ -382,7 +384,17 @@ expect "the snapshot has the agent's session" "grep -c \"\\\"session\\\": \\\"$S
# (`\;`: send-keys would end its command at a trailing ;)
t send-keys -t main:agent -l 'an unsent idea\;'
expect "a draft before the crash" "t show -pv -t main:agent @dingger_draft 2>/dev/null" "an unsent idea;" 30
-t kill-server
+# Stopped the way a restart or logout stops it: SIGTERM to tmux and to
+# everything in its panes (the real pis among them) at once, SIGKILL to what
+# is left (the shells ignore SIGTERM) a little later.
+STOPPED=$( { t display -p '#{pid}'; for tty in $(t list-panes -a -F '#{pane_tty}' | sed 's|/dev/||'); do ps -o pid= -t "$tty"; done; } | awk 'NF' | sort -u | tr '\n' ' ')
+for p in $STOPPED; do ps -o comm=,args= -p "$p"; done >"$D/stopped"
+# (pi names its process "pi".)
+expect "real pis are among what is stopped" "grep -c '^pi ' $D/stopped | awk '\$1 > 0 {print \"yes\"}'" yes
+kill -TERM $STOPPED 2>/dev/null
+sleep 2
+kill -KILL $STOPPED 2>/dev/null
+expect "tmux is gone" "t has-session 2>/dev/null && echo up || echo gone" gone 30
expect "the layout becomes the restore candidate" "python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))[\"status\"])' $D/state/restore.json 2>/dev/null" offered 80
"$DINGGER" restore >"$D/restore.out" 2>&1
expect "restore resumes it by its session file" "grep -c -- \"resume .*pi --session\" $D/restore.out" 1