From 2cdd7a3cbf969e865d9496663562897372fff3ba Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Fri, 14 Aug 2026 08:12:05 +1000 Subject: [PATCH] Re-add labwc stress harness scripts nested-labwc.sh runs a command inside a nested labwc (wlroots-family host) so the clipboard bridge exercises the data-control backend; stress-clipboard.sh loops the clipboard smoke tests, snapshotting logs into /tmp/stress-fail/ on any failure. Recovered verbatim after the history rewrite dropped scripts/. Usage: scripts/nested-labwc.sh scripts/stress-clipboard.sh [iterations] --- scripts/nested-labwc.sh | 72 +++++++++++++++++++++++++++++++++++++ scripts/stress-clipboard.sh | 39 ++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100755 scripts/nested-labwc.sh create mode 100755 scripts/stress-clipboard.sh diff --git a/scripts/nested-labwc.sh b/scripts/nested-labwc.sh new file mode 100755 index 0000000..186f306 --- /dev/null +++ b/scripts/nested-labwc.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Throwaway dev wrapper: run a command inside a nested labwc (wlroots-family +# host) so the clipboard bridge uses the wlr-data-control backend. +# Usage: nested-labwc.sh [--x11] +# Default command: tabbed-wlroots with two wltest tabs. +set -e + +REPO="${TABBED_REPO:-/home/ahamilton/code/tabbed-wayland}" +RUNTIME="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" +export WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}" +export WLR_WL_OUTPUTS="${WLR_WL_OUTPUTS:-1}" + +MODE=wayland +if [ "$1" = "--x11" ]; then + MODE=x11 + shift +fi + +if [ "$MODE" = x11 ]; then + export WLR_BACKENDS=x11 + export DISPLAY="${DISPLAY:-:0}" + echo "[nested-labwc] x11 backend on $DISPLAY" +else + export WLR_BACKENDS=wayland + echo "[nested-labwc] wayland backend under $WAYLAND_DISPLAY" +fi + +before="$(ls "$RUNTIME"/wayland-* 2>/dev/null || true)" + +labwc -t "labwc-dev" >/tmp/labwc.log 2>&1 & +LABWC_PID=$! +trap 'kill "$LABWC_PID" 2>/dev/null || true' EXIT INT TERM + +# Discover labwc's socket: the wayland-N that wasn't there before. Only match +# plain wayland- sockets (labwc's name); portal/other compositors create +# wayland-proxy-* sockets at arbitrary times and must be ignored. +SOCK="" +for i in $(seq 1 150); do + for s in "$RUNTIME"/wayland-*; do + [ -e "$s" ] || continue + b="${s##*/}" + case "$b" in *.lock|*proxy*) continue ;; + wayland-[0-9]*) case "$before" in *"$s"*) ;; *) SOCK="$b"; break 2 ;; esac ;; + esac + done + if ! kill -0 "$LABWC_PID" 2>/dev/null; then + echo "[nested-labwc] labwc exited early; tail:" >&2 + tail -20 /tmp/labwc.log >&2 + exit 1 + fi + sleep 0.1 +done + +if [ -z "$SOCK" ]; then + echo "[nested-labwc] no new wayland socket appeared" >&2 + tail -20 /tmp/labwc.log >&2 + exit 1 +fi + +echo "[nested-labwc] nested labwc socket: $SOCK" +export WAYLAND_DISPLAY="$SOCK" + +if [ "$#" -eq 0 ]; then + set -- "$REPO/build/tabbed-wlroots" \ + "$REPO/build/wltest '#ff0000'" \ + "$REPO/build/wltest '#0000ff'" +fi + +"$@" +rc=$? +kill "$LABWC_PID" 2>/dev/null || true +exit "$rc" \ No newline at end of file diff --git a/scripts/stress-clipboard.sh b/scripts/stress-clipboard.sh new file mode 100755 index 0000000..4b79358 --- /dev/null +++ b/scripts/stress-clipboard.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Stress-run the clipboard smoke tests against a wlroots-family host. +# Meant to be run inside scripts/nested-labwc.sh so the data-control +# backend is exercised: +# scripts/nested-labwc.sh scripts/stress-clipboard.sh [iterations] [pytest-args...] +# Prints PASS/FAIL per iteration and snapshots logs on any failure into +# /tmp/stress-fail/iter-/ for diagnosis (the Pi's intermittent labwc +# clipboard failures are the motivation). +set -u + +REPO="${TABBED_REPO:-$(cd "$(dirname "$0")/.." && pwd)}" +ITER="${1:-30}" +shift 2>/dev/null || shift + +FAIL_DIR=/tmp/stress-fail +rm -rf "$FAIL_DIR" +mkdir -p "$FAIL_DIR" + +pass=0 +fail=0 +for i in $(seq 1 "$ITER"); do + out=$(cd "$REPO" && python3 -m pytest tests/test_smoke.py -k clipboard -q "$@" 2>&1) + rc=$? + if [ "$rc" -eq 0 ]; then + pass=$((pass + 1)) + echo "[$(date +%H:%M:%S)] iter $i/$ITER PASS" + else + fail=$((fail + 1)) + d="$FAIL_DIR/iter-$i" + mkdir -p "$d" + printf '%s\n' "$out" >"$d/pytest.txt" + cp /tmp/tabtest.log "$d/tabtest.log" 2>/dev/null || true + cp /tmp/labwc.log "$d/labwc.log" 2>/dev/null || true + echo "[$(date +%H:%M:%S)] iter $i/$ITER FAIL (snapshot in $d)" + fi +done + +echo "=== $pass passed, $fail failed (of $ITER) ===" +[ "$fail" -eq 0 ]