AtlatestRepositorysigil-wm
1
#!/usr/bin/env bash2
set -euo pipefail3
cd "$(dirname "$0")/.."4
make -j2 all build/pixel-client build/readback5
runtime_dir=$(mktemp -d /tmp/sigil-wm-layer.XXXXXX)6
export XDG_RUNTIME_DIR=$runtime_dir7
export WLR_BACKENDS=headless WLR_RENDERER=pixman WLR_HEADLESS_OUTPUTS=18
export SIGIL_WM_REPL="$runtime_dir/repl"9
server_pid= client_pid=10
cleanup() {11
for child in "$client_pid" "$server_pid"; do12
[[ -z $child ]] || kill "$child" 2>/dev/null || true13
[[ -z $child ]] || wait "$child" 2>/dev/null || true14
done15
rm -rf "$runtime_dir"16
}17
trap cleanup EXIT18
wait_log() {19
for ((attempt=0; attempt<200; attempt++)); do20
if grep -q "$2" "$1"; then return; fi21
sleep 0.0522
done23
cat "$1" >&224
return 125
}26
timeout 45 bash scripts/run-sigil -L src eval -f test/layers.sgl > build/receipts/layers.log 2>&1 &27
server_pid=$!28
wait_log build/receipts/layers.log '^WAYLAND_SOCKET='29
export WAYLAND_DISPLAY30
WAYLAND_DISPLAY=$(sed -n 's/^WAYLAND_SOCKET=//p' build/receipts/layers.log)31
timeout 45 build/pixel-client 00cc44 'Layer client' layer > build/receipts/layer-client.log 2>&1 &32
client_pid=$!33
wait_log build/receipts/layers.log '^LAYER_READY=PASS'34
wait_log build/receipts/layer-client.log '^CLIENT_KEYBOARD_ENTER'35
bash scripts/msg "$SIGIL_WM_REPL" "(capture-output! host output-id \"$PWD/build/receipts/layer.ppm\")"36
for ((attempt=0; attempt<200; attempt++)); do37
[[ ! -s build/receipts/layer.ppm ]] || break38
sleep 0.0539
done40
sleep 0.241
build/readback build/receipts/layer.ppm build/receipts/layer.png layer42
bash scripts/msg "$SIGIL_WM_REPL" '(close-window! host layer-id)'43
wait "$server_pid"44
server_pid=45
wait "$client_pid"46
client_pid=47
grep -q '^LAYERS=PASS' build/receipts/layers.log48
if grep -q 'event handler failed' build/receipts/layers.log; then cat build/receipts/layers.log >&2; exit 1; fi49
echo 'LAYER_CLIENT=PASS'