AtlatestRepositorysigil-wm

sigil-wm / tree / scriptstest-foot-blink

1#!/usr/bin/env bash
2set -euo pipefail
3cd "$(dirname "$0")/.."
4if [[ ${1:-} != --inside ]]; then
5 exec guix time-machine -C channels.scm -- shell -m draw-manifest.scm foot -- bash scripts/test-foot-blink --inside
6fi
7make -j2 all build/surface-frames build/frame-fault.so
8unset TMUX TMUX_PANE
9unset SIGIL_WM_FOOT_MODERN
10foot_version=$(foot --version)
11if [[ $foot_version =~ ([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
12 if (( BASH_REMATCH[1] > 1 || (BASH_REMATCH[1] == 1 && BASH_REMATCH[2] >= 28) )); then
13 export SIGIL_WM_FOOT_MODERN=1
14 fi
15else
16 printf 'unrecognized foot version: %s\n' "$foot_version" >&2
17 exit 2
18fi
19out=$PWD/build/receipts/foot-blink
20mkdir -p "$out"
21parent_runtime=$(mktemp -d /tmp/sigil-foot-parent.XXXXXXXX)
22child_runtime=$(mktemp -d /tmp/sigil-foot-child.XXXXXXXX)
23chmod 700 "$parent_runtime" "$child_runtime"
24parent_pid=
25cleanup() {
26 if [[ -n $parent_pid ]]; then kill "$parent_pid" 2>/dev/null || true; wait "$parent_pid" 2>/dev/null || true; fi
27 rm -rf "$parent_runtime" "$child_runtime"
29trap cleanup EXIT
30XDG_RUNTIME_DIR=$parent_runtime WLR_BACKENDS=headless WLR_RENDERER=pixman WLR_HEADLESS_OUTPUTS=1 \
31 SIGIL_WM_REPL=$parent_runtime/repl timeout 60 bash scripts/run-sigil -L src -L examples eval -f examples/tiling.sgl > "$out/parent.log" 2>&1 &
32parent_pid=$!
33for ((attempt=0;attempt<400;attempt++)); do
34 if grep -q '^WAYLAND_SOCKET=' "$out/parent.log"; then break; fi
35 sleep 0.025
36done
37parent_display=$(sed -n 's/^WAYLAND_SOCKET=//p' "$out/parent.log" | head -1)
38[[ -n $parent_display ]] || { cat "$out/parent.log"; exit 2; }
39for terminal in direct tmux; do
40for clip in 0 1; do
41for failure in ${SIGIL_WM_FOOT_FAILURES:-clean}; do
42 unset SIGIL_WM_FRAMES_TMUX
43 if [[ $terminal == tmux ]]; then export SIGIL_WM_FRAMES_TMUX=1; fi
44 unset SIGIL_WM_FRAME_FAILURE
45 rm -f "$child_runtime/fail"
46 if [[ $failure == busy ]]; then export SIGIL_WM_FRAME_FAILURE=$child_runtime/fail; fi
47 rc=0
48 XDG_RUNTIME_DIR=$child_runtime WAYLAND_DISPLAY=$parent_runtime/$parent_display WLR_BACKENDS=wayland WLR_RENDERER=pixman \
49 SIGIL_WM_FRAMES_FOOT=1 LD_PRELOAD=$PWD/build/frame-fault.so \
50 timeout 20 build/surface-frames "$out/$terminal-$clip-$failure.samples" "$clip" > "$out/$terminal-$clip-$failure.log" 2>&1 || rc=$?
51 cat "$out/$terminal-$clip-$failure.log"
52 test "$rc" == 0
53 if grep -q '^ err:' "$out/$terminal-$clip-$failure.log"; then exit 2; fi
54 if [[ $failure == busy ]]; then
55 awk '
56 /^FRAME_COMMIT_EBUSY / { pending=1; failures++ }
57 /^FRAME_COMMIT_ACCEPTED / { pending=0 }
58 /^FRAME_CALLBACK / && pending { print "FOOT_CALLBACK_BEFORE_ACCEPTED=FAIL"; failed=1 }
59 END { if (failures != 1) failed=1; exit failed }
60 ' "$out/$terminal-$clip-$failure.log"
61 fi
62done
63done
64done
65XDG_RUNTIME_DIR=$parent_runtime bash scripts/msg "$parent_runtime/repl" '(stop-host! host)' > "$out/quit.log"
66wait "$parent_pid"
67parent_pid=
68printf 'FOOT_NESTED_BLINK=PASS clipped-and-unclipped sampled-on-off-phases\n'