AtlatestRepositorysigil-wm
1
#!/usr/bin/env bash2
set -euo pipefail3
cd "$(dirname "$0")/.."4
if [[ ${1:-} != --inside ]]; then5
exec guix time-machine -C channels.scm -- shell -m draw-manifest.scm -- bash scripts/test-examples --inside6
fi7
make -j2 all build/pixel-client build/readback build/input-driver build/lock-client8
bash scripts/run-sigil -L src -L examples -L .deps eval -f test/imports.sgl9
bash scripts/run-sigil -L src eval -f test/model.sgl10
bash scripts/run-sigil -L src -L .deps eval -f test/draw.sgl11
mkdir -p build/receipts12
runtime_dir=$(mktemp -d /tmp/sigil-wm-test.XXXXXX)13
chmod 700 "$runtime_dir"14
export XDG_RUNTIME_DIR=$runtime_dir15
export WLR_BACKENDS=${SIGIL_WM_TEST_BACKEND:-headless} WLR_RENDERER=pixman WLR_HEADLESS_OUTPUTS=116
export SIGIL_WM_EXAMPLE_PROTOCOLS=${SIGIL_WM_EXAMPLE_PROTOCOLS:-27}17
security_pid=18
WAYLAND_DISPLAY=${SIGIL_WM_TEST_PARENT_DISPLAY:-${WAYLAND_DISPLAY:-}} timeout 20 bash scripts/run-sigil -L src eval -f test/reentry.sgl19
manager_pid= client_one= client_two=20
cleanup() {21
for child in "$client_one" "$client_two" "$manager_pid" "$security_pid"; do22
[[ -z $child ]] || kill "$child" 2>/dev/null || true23
done24
for child in "$client_one" "$client_two" "$manager_pid" "$security_pid"; do25
[[ -z $child ]] || wait "$child" 2>/dev/null || true26
done27
rm -rf "$runtime_dir"28
}29
trap cleanup EXIT30
wait_log() {31
local file=$1 pattern=$232
for ((attempt=0; attempt<200; attempt++)); do33
if grep -q "$pattern" "$file"; then return; fi34
sleep 0.0535
done36
cat "$file" >&237
echo "missing log marker: $pattern" >&238
return 139
}40
for manager in stacking tiling tabbed; do41
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_DISPLAY46
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_ENTER50
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_ENTER53
bash scripts/msg "$SIGIL_WM_REPL" '(host-snapshot host)' > "build/receipts/$manager-snapshot"54
if [[ $manager == stacking ]]; then source scripts/input-assertions; fi55
if [[ $manager == stacking ]] && (( (SIGIL_WM_EXAMPLE_PROTOCOLS & 27) == 27 )); then source scripts/security-assertions; fi56
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++)); do58
[[ ! -f build/receipts/$manager.ppm ]] || break59
sleep 0.0560
done61
[[ -s build/receipts/$manager.ppm ]]62
sleep 0.263
build/readback "build/receipts/$manager.ppm" "build/receipts/$manager.png" "$manager"64
if [[ -n ${SIGIL_WM_TEST_PARENT_REPL:-} ]]; then65
sleep 0.1566
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++)); do68
[[ ! -f build/receipts/$manager-parent.ppm ]] || break69
sleep 0.0570
done71
sleep 0.272
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
fi75
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 || true79
wait "$client_one" 2>/dev/null || true80
wait "$client_two" 2>/dev/null || true81
client_one= client_two=82
if grep -q "event handler failed" "build/receipts/$manager.log"; then cat "build/receipts/$manager.log" >&2; exit 1; fi83
echo "EXAMPLE=$manager PASS"84
done