kick/scripts/stress-clipboard.sh

39 lines
1.3 KiB
Bash
Executable file

#!/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-<n>/ for diagnosis (the Pi's intermittent labwc
# clipboard failures are the motivation).
set -u
REPO="${KICK_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 ]