Files
Waybar/test/smoke/leakcheck.sh
T
Alex 9a10949938 ci(smoke): cover teardown, state transitions and fake hardware
The smoke test only exercised steady-state rendering and killed waybar with
SIGTERM, so whole crash classes were invisible: exit-time use-after-free
(#5182), module state transitions (#5183) and hardware-backed modules (#5179).
Add tiers that hit those paths under ASan (+ _GLIBCXX_ASSERTIONS):

- lib.sh: assert_clean_exit (SIGINT teardown -> checks segfault/abort + ASan
  report emitted during destruction), output hotplug helpers, signal/reload,
  WAYBAR_WRAP hook, opt-in leak detection.
- lifecycle.sh (gating): clean exit, runtime output hotplug (Bar/module
  destroy), toggle/reload churn, fast-interval teardown race (#5182 class).
- fuzz.sh (gating): pathological custom-backend output (empty, nonzero exit,
  invalid JSON, huge, non-UTF8, empty format).
- coverage.sh (gating): every Factory module must be classified for smoke
  coverage; a new unlisted module fails the job (#5179 slipped through).
- modules.sh: also render the whole matrix inside a group; SIGINT teardown per
  module instead of SIGTERM.
- state.sh (best-effort): real mpd driven through an empty queue (#5183) +
  stop/clear; pulseaudio + slider on a null sink.
- hardware.sh (best-effort): backlight, backlight/slider (#5179) and battery
  via umockdev.
- leakcheck.sh (report-only): clean-exit run under LSan.
2026-07-05 22:21:46 +02:00

35 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Report-only leak check. Runs the deterministic config, exits cleanly (SIGINT,
# so LeakSanitizer's atexit hook actually runs -- a SIGTERM kill would skip it),
# and surfaces any leak report. Never fails the job: leaks in GTK/GLib are too
# noisy to gate on, but regressions in our own code are worth seeing.
#
# Usage: leakcheck.sh
set -uo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib.sh
source "$DIR/lib.sh"
export SMOKE_DETECT_LEAKS=1
smoke::setup
smoke::start_compositor
trap smoke::stop EXIT
smoke::launch_waybar "$DIR/config.jsonc" "$DIR/style.css" 5
smoke::assert_alive || true
# Clean exit so LSan runs.
kill -INT "$WAYBAR_PID" 2>/dev/null || true
for _ in $(seq 1 20); do kill -0 "$WAYBAR_PID" 2>/dev/null || break; sleep 0.5; done
kill -9 "$WAYBAR_PID" 2>/dev/null || true
if grep -iqE 'LeakSanitizer|Direct leak|Indirect leak' "$SMOKE_LOG"; then
echo "::warning::LeakSanitizer reported leaks (report-only)"
echo "::group::leak report"
grep -iE 'leak|SUMMARY|#[0-9]+ 0x' "$SMOKE_LOG" || true
echo "::endgroup::"
else
echo "✓ no leaks reported"
fi
WAYBAR_PID=""