AtlatestRepositorysigil-wm
1
#!/usr/bin/env bash2
set -Eeuo pipefail3
cd -P "$(dirname "$0")/.."4
if [[ -z ${GUIX_ENVIRONMENT:-} ]]; then5
exec guix time-machine -C channels.scm -- shell -m draw-manifest.scm -- bash scripts/test-pointer-geometry --inside6
fi7
make -j2 all build/geometry-client8
bash scripts/run-sigil --version9
library=$PWD10
runtime=$PWD/build/runtime/sigil-linux-amd64.runnable11
out=$PWD/build/receipts/pointer-geometry12
mkdir -p "$out"13
export LD_LIBRARY_PATH=$PWD/build:$GUIX_ENVIRONMENT/lib14
export SIGIL_WM_LIBRARY=$PWD/build/libsigil-wm.so15
parent_runtime=$(mktemp -d /tmp/sigil-geometry-parent.XXXXXXXX)16
child_runtime=$(mktemp -d /tmp/sigil-geometry-child.XXXXXXXX)17
chmod 700 "$parent_runtime" "$child_runtime"18
parent_pid= child_pid= client_pid=19
cd "$library"20
request() {21
CHECK_SOCKET=$1 CHECK_EXPRESSION=$2 timeout --foreground 15 "$runtime" -L src eval -f "$library/test/pointer-geometry-request.sgl"22
}23
value() {24
local result25
result=$(request "$child_runtime/repl" "$1")26
printf '%s\n' "$result"27
[[ $result != *'(error '* ]]28
}29
cleanup() {30
local rc=$?31
if [[ -n $child_pid ]]; then request "$child_runtime/repl" '(stop-host! host)' > "$out/cleanup-child.log" 2>&1 || true; fi32
if [[ -n $parent_pid ]]; then request "$parent_runtime/repl" '(stop-host! host)' > "$out/cleanup-parent.log" 2>&1 || true; fi33
for pid in "$client_pid" "$child_pid" "$parent_pid"; do34
if [[ -n $pid ]]; then kill -TERM "$pid" 2>/dev/null || true; wait "$pid" 2>/dev/null || true; fi35
done36
rm -rf -- "$parent_runtime" "$child_runtime"37
exit "$rc"38
}39
trap cleanup EXIT40
wait_log() {41
for ((attempt=0;attempt<400;attempt++)); do42
if grep -q "$2" "$1" 2>/dev/null; then return 0; fi43
sleep 0.02544
done45
cat "$1" >&246
return 147
}48
wait_value() {49
for ((attempt=0;attempt<160;attempt++)); do50
if value "$1" | grep -q '(value #t)'; then return 0; fi51
sleep 0.02552
done53
cat "$out/child.log" >&254
return 155
}56
XDG_RUNTIME_DIR=$parent_runtime WLR_BACKENDS=headless WLR_RENDERER=pixman WLR_HEADLESS_OUTPUTS=1 \57
SIGIL_WM_REPL=$parent_runtime/repl timeout --foreground 240 \58
"$runtime" -L src -L examples eval -f examples/tiling.sgl > "$out/parent.log" 2>&1 &59
parent_pid=$!60
wait_log "$out/parent.log" '^WAYLAND_SOCKET='61
parent_display=$parent_runtime/$(sed -n 's/^WAYLAND_SOCKET=//p' "$out/parent.log" | head -n1)62
XDG_RUNTIME_DIR=$child_runtime WAYLAND_DISPLAY=$parent_display WLR_BACKENDS=wayland WLR_RENDERER=pixman \63
SIGIL_WM_REPL=$child_runtime/repl timeout --foreground 220 \64
"$runtime" -L src eval -f "$library/test/pointer-geometry.sgl" > "$out/child.log" 2>&1 &65
child_pid=$!66
wait_log "$out/child.log" '^WAYLAND_SOCKET='67
child_display=$(sed -n 's/^WAYLAND_SOCKET=//p' "$out/child.log" | head -n1)68
clicks() {69
for ((index=0;index<5;index++)); do70
value '(emulate-button! host 1 272 #t)' > "$out/press.log"71
sleep 0.02572
value '(emulate-button! host 1 272 #f)' > "$out/release.log"73
sleep 0.02574
done75
}76
for arm in ${SIGIL_WM_GEOMETRY_ARMS:-tiled:0,0 tiled:20,20 floating:20,20 tiled:32,16}; do77
kind=${arm%%:*}78
origin=${arm#*:}79
name=$kind-${origin/,/-}80
tiled=1581
if [[ $kind == floating ]]; then tiled=0; fi82
value "(set! initial-tiled $tiled)" > "$out/placement-$name.log"83
log=$out/client-$name.log84
hold=$out/hold-$name85
popup_open=$out/popup-open-$name86
popup_close=$out/popup-close-$name87
XDG_RUNTIME_DIR=$child_runtime WAYLAND_DISPLAY=$child_display \88
SIGIL_WM_CLIENT_GEOMETRY=$origin SIGIL_WM_CLIENT_HOLD=$hold \89
SIGIL_WM_CLIENT_POPUP_OPEN=$popup_open SIGIL_WM_CLIENT_POPUP_CLOSE=$popup_close \90
timeout --foreground 90 "$library/build/geometry-client" 00cc44 'Geometry input proof' > "$log" 2>&1 &91
client_pid=$!92
wait_log "$log" '^CLIENT_KEYBOARD_ENTER'93
wait_value '(and (= (length windows) 1) (= (host-statistic host 7) 0) (equal? last-plan applied-plan))'94
if [[ ${SIGIL_WM_GEOMETRY_EXTRA:-0} == 1 ]]; then95
if ! grep -q '^CLIENT_TOPLEVEL tiled=15 fullscreen=0' "$log"; then96
printf 'TILED_STATE_MISSING=FAIL expected=15\n'97
exit 198
fi99
fi100
value '(emulate-motion! host 1 200 180)' > "$out/motion-$name.log"101
wait_log "$log" '^CLIENT_POINTER_ENTER='102
clicks103
test "$(grep -c '^CLIENT_BUTTON=272,0' "$log")" == 5104
cp "$log" "$out/live-$name.log"105
touch "$hold"106
value "(test-plan! 500 $tiled 10000)" > "$out/saved-plan-$name.log"107
wait_log "$log" '^CLIENT_CONFIGURE_HELD='108
wait_value '(= (host-statistic host 7) 1)'109
start_line=$(wc -l < "$log")110
clicks111
for ((attempt=0;attempt<100;attempt++)); do112
if [[ $(grep -c '^CLIENT_BUTTON=272,0' "$log") == 10 ]]; then break; fi113
sleep 0.025114
done115
test "$(grep -c '^CLIENT_BUTTON=272,0' "$log")" == 10116
tail -n +"$((start_line+1))" "$log" > "$out/saved-$name.log"117
test "$(grep -c '^STATIONARY_CLICK=PASS' "$out/saved-$name.log")" == 5118
if grep -q '^STATIONARY_CLICK=FAIL' "$out/saved-$name.log"; then exit 1; fi119
rm "$hold"120
wait_value '(and (= (host-statistic host 7) 0) (equal? last-plan applied-plan))'121
if [[ ${SIGIL_WM_GEOMETRY_EXTRA:-0} == 1 ]]; then122
for edges in 0 15; do123
before=$(wc -l < "$log")124
value "(test-plan! 500 $edges 200)" > "$out/tiled-transition-$edges.log"125
for ((attempt=0;attempt<200;attempt++)); do126
if tail -n +"$((before+1))" "$log" | grep -q "^CLIENT_TOPLEVEL tiled=$edges fullscreen=0"; then break; fi127
sleep 0.025128
done129
tail -n +"$((before+1))" "$log" | grep -q "^CLIENT_TOPLEVEL tiled=$edges fullscreen=0"130
wait_value '(and (= (host-statistic host 7) 0) (equal? last-plan applied-plan))'131
done132
printf 'TILED_STATES=PASS delivered-all cleared-floating restored-all\n'133
value '(emulate-motion! host 1 200 180)' > "$out/popup-root-motion.log"134
value '(query-pointer! host)' > "$out/popup-query.log"135
wait_value '(pair? pointer-position)'136
value 'pointer-position' > "$out/popup-pointer-position.log"137
touch "$popup_open"138
value '(emulate-button! host 1 272 #t)' > "$out/popup-open-press.log"139
wait_log "$log" '^POPUP_MAPPED'140
wait_value '(= (length popups) 1)'141
value '(emulate-button! host 1 272 #f)' > "$out/popup-open-release.log"142
wait_log "$log" '^CLIENT_POINTER_ENTER=26,24'143
before=$(wc -l < "$log")144
clicks145
tail -n +"$((before+1))" "$log" > "$out/popup-clicks.log"146
test "$(grep -c '^STATIONARY_CLICK=PASS' "$out/popup-clicks.log")" == 5147
if grep -q '^STATIONARY_CLICK=FAIL' "$out/popup-clicks.log"; then exit 1; fi148
touch "$popup_close"149
wait_log "$log" '^POPUP_DESTROYED'150
wait_value '(null? popups)'151
value '(emulate-motion! host 1 200 180)' > "$out/restored-root-motion.log"152
before=$(wc -l < "$log")153
clicks154
tail -n +"$((before+1))" "$log" > "$out/restored-root-clicks.log"155
test "$(grep -c '^STATIONARY_CLICK=PASS' "$out/restored-root-clicks.log")" == 5156
if grep -q '^STATIONARY_CLICK=FAIL' "$out/restored-root-clicks.log"; then exit 1; fi157
printf 'GRABBED_POPUP=PASS admitted five-paired-clicks retired parent-five-clicks-restored\n'158
fi159
value '(close-window! host (car windows))' > "$out/close-$name.log"160
wait "$client_pid"161
client_pid=162
wait_value '(null? windows)'163
if [[ ${GEOMETRY_EXPECT_RED:-0} == 1 && $origin != 0,0 && $kind == tiled ]]; then164
test "$(grep -c '^STATIONARY_CLICK=FAIL' "$out/live-$name.log")" == 5165
grep -q "^HELD_COORDINATE_SHIFT=-${origin/,/\.000,-}.000" "$out/live-$name.log"166
printf 'GEOMETRY_RED=PASS kind=%s origin=%s five-live-shifts five-saved-clicks-correct\n' "$kind" "$origin"167
else168
test "$(grep -c '^STATIONARY_CLICK=PASS' "$out/live-$name.log")" == 5169
if grep -q '^HELD_COORDINATE_SHIFT=' "$out/live-$name.log"; then exit 1; fi170
printf 'GEOMETRY_GREEN=PASS kind=%s origin=%s five-live-and-five-saved-stationary-clicks\n' "$kind" "$origin"171
fi172
done173
value '(stop-host! host)' > "$out/quit.log"174
wait "$child_pid"175
child_pid=176
request "$parent_runtime/repl" '(stop-host! host)' > "$out/parent-quit.log"177
wait "$parent_pid"178
parent_pid=179
grep -q '^POINTER_GEOMETRY_HOST=PASS' "$out/child.log"180
if grep -q 'event handler failed' "$out/child.log"; then exit 1; fi181
printf 'POINTER_GEOMETRY=PASS nested zero-origin asymmetric-origin tiled floating live saved paired-delivery clean-join\n'