AtlatestRepositorysigil-wm

sigil-wm / tree / scriptstest-examples

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 -- bash scripts/test-examples --inside
6fi
7make -j2 all build/pixel-client build/readback build/input-driver build/lock-client
8bash scripts/run-sigil -L src -L examples -L .deps eval -f test/imports.sgl
9bash scripts/run-sigil -L src eval -f test/model.sgl
10bash scripts/run-sigil -L src -L .deps eval -f test/draw.sgl
11mkdir -p build/receipts
12runtime_dir=$(mktemp -d /tmp/sigil-wm-test.XXXXXX)
13chmod 700 "$runtime_dir"
14export XDG_RUNTIME_DIR=$runtime_dir
15export WLR_BACKENDS=${SIGIL_WM_TEST_BACKEND:-headless} WLR_RENDERER=pixman WLR_HEADLESS_OUTPUTS=1
16export SIGIL_WM_EXAMPLE_PROTOCOLS=${SIGIL_WM_EXAMPLE_PROTOCOLS:-27}
17security_pid=
18WAYLAND_DISPLAY=${SIGIL_WM_TEST_PARENT_DISPLAY:-${WAYLAND_DISPLAY:-}} timeout 20 bash scripts/run-sigil -L src eval -f test/reentry.sgl
19manager_pid= client_one= client_two=
20cleanup() {
21 for child in "$client_one" "$client_two" "$manager_pid" "$security_pid"; do
22 [[ -z $child ]] || kill "$child" 2>/dev/null || true
23 done
24 for child in "$client_one" "$client_two" "$manager_pid" "$security_pid"; do
25 [[ -z $child ]] || wait "$child" 2>/dev/null || true
26 done
27 rm -rf "$runtime_dir"
29trap cleanup EXIT
30wait_log() {
31 local file=$1 pattern=$2
32 for ((attempt=0; attempt<200; attempt++)); do
33 if grep -q "$pattern" "$file"; then return; fi
34 sleep 0.05
35 done
36 cat "$file" >&2
37 echo "missing log marker: $pattern" >&2
38 return 1
40for manager in stacking tiling tabbed; do
41 export SIGIL_WM_REPL="$runtime_dir/$manager.repl"
42 WAYLAND_DISPLAY=${SIGIL_WM_TEST_PARENT_DISPLAY:-${WAYLAND_DISPLAY:-}} timeout 90 bash scripts/run-sigil -L src -L examples -L .deps eval -f "examples/$manager.sgl" > "build/receipts/$manager.log" 2>&1 &
43 manager_pid=$!
44 wait_log "build/receipts/$manager.log" WAYLAND_SOCKET=
45 export WAYLAND_DISPLAY
46 WAYLAND_DISPLAY=$(sed -n 's/^WAYLAND_SOCKET=//p' "build/receipts/$manager.log" | head -1)
47 build/pixel-client 00cc44 'Green window' > "build/receipts/$manager-green.log" 2>&1 &
48 client_one=$!
49 wait_log "build/receipts/$manager-green.log" CLIENT_KEYBOARD_ENTER
50 build/pixel-client cc2244 'Red window' > "build/receipts/$manager-red.log" 2>&1 &
51 client_two=$!
52 wait_log "build/receipts/$manager-red.log" CLIENT_KEYBOARD_ENTER
53 bash scripts/msg "$SIGIL_WM_REPL" '(host-snapshot host)' > "build/receipts/$manager-snapshot"
54 if [[ $manager == stacking ]]; then source scripts/input-assertions; fi
55 if [[ $manager == stacking ]] && (( (SIGIL_WM_EXAMPLE_PROTOCOLS & 27) == 27 )); then source scripts/security-assertions; fi
56 bash scripts/msg "$SIGIL_WM_REPL" "(capture-output! host (dict-ref (car (dict-ref (host-snapshot host) outputs:)) id:) \"$PWD/build/receipts/$manager.ppm\")"
57 for ((attempt=0; attempt<100; attempt++)); do
58 [[ ! -f build/receipts/$manager.ppm ]] || break
59 sleep 0.05
60 done
61 [[ -s build/receipts/$manager.ppm ]]
62 sleep 0.2
63 build/readback "build/receipts/$manager.ppm" "build/receipts/$manager.png" "$manager"
64 if [[ -n ${SIGIL_WM_TEST_PARENT_REPL:-} ]]; then
65 sleep 0.15
66 bash scripts/msg "$SIGIL_WM_TEST_PARENT_REPL" "(capture-output! host (dict-ref (car (dict-ref (host-snapshot host) outputs:)) id:) \"$PWD/build/receipts/$manager-parent.ppm\")"
67 for ((attempt=0; attempt<100; attempt++)); do
68 [[ ! -f build/receipts/$manager-parent.ppm ]] || break
69 sleep 0.05
70 done
71 sleep 0.2
72 build/readback "build/receipts/$manager-parent.ppm" "build/receipts/$manager-parent.png" "$manager"
73 cmp "build/receipts/$manager.ppm" "build/receipts/$manager-parent.ppm"
74 fi
75 bash scripts/msg "$SIGIL_WM_REPL" '(stop-host! host)'
76 wait "$manager_pid"
77 manager_pid=
78 kill "$client_one" "$client_two" 2>/dev/null || true
79 wait "$client_one" 2>/dev/null || true
80 wait "$client_two" 2>/dev/null || true
81 client_one= client_two=
82 if grep -q "event handler failed" "build/receipts/$manager.log"; then cat "build/receipts/$manager.log" >&2; exit 1; fi
83 echo "EXAMPLE=$manager PASS"
84done