AtlatestRepositorysigil-wm

sigil-wm / tree / scriptstest-layers

1#!/usr/bin/env bash
2set -euo pipefail
3cd "$(dirname "$0")/.."
4make -j2 all build/pixel-client build/readback
5runtime_dir=$(mktemp -d /tmp/sigil-wm-layer.XXXXXX)
6export XDG_RUNTIME_DIR=$runtime_dir
7export WLR_BACKENDS=headless WLR_RENDERER=pixman WLR_HEADLESS_OUTPUTS=1
8export SIGIL_WM_REPL="$runtime_dir/repl"
9server_pid= client_pid=
10cleanup() {
11 for child in "$client_pid" "$server_pid"; do
12 [[ -z $child ]] || kill "$child" 2>/dev/null || true
13 [[ -z $child ]] || wait "$child" 2>/dev/null || true
14 done
15 rm -rf "$runtime_dir"
17trap cleanup EXIT
18wait_log() {
19 for ((attempt=0; attempt<200; attempt++)); do
20 if grep -q "$2" "$1"; then return; fi
21 sleep 0.05
22 done
23 cat "$1" >&2
24 return 1
26timeout 45 bash scripts/run-sigil -L src eval -f test/layers.sgl > build/receipts/layers.log 2>&1 &
27server_pid=$!
28wait_log build/receipts/layers.log '^WAYLAND_SOCKET='
29export WAYLAND_DISPLAY
30WAYLAND_DISPLAY=$(sed -n 's/^WAYLAND_SOCKET=//p' build/receipts/layers.log)
31timeout 45 build/pixel-client 00cc44 'Layer client' layer > build/receipts/layer-client.log 2>&1 &
32client_pid=$!
33wait_log build/receipts/layers.log '^LAYER_READY=PASS'
34wait_log build/receipts/layer-client.log '^CLIENT_KEYBOARD_ENTER'
35bash scripts/msg "$SIGIL_WM_REPL" "(capture-output! host output-id \"$PWD/build/receipts/layer.ppm\")"
36for ((attempt=0; attempt<200; attempt++)); do
37 [[ ! -s build/receipts/layer.ppm ]] || break
38 sleep 0.05
39done
40sleep 0.2
41build/readback build/receipts/layer.ppm build/receipts/layer.png layer
42bash scripts/msg "$SIGIL_WM_REPL" '(close-window! host layer-id)'
43wait "$server_pid"
44server_pid=
45wait "$client_pid"
46client_pid=
47grep -q '^LAYERS=PASS' build/receipts/layers.log
48if grep -q 'event handler failed' build/receipts/layers.log; then cat build/receipts/layers.log >&2; exit 1; fi
49echo 'LAYER_CLIENT=PASS'