Files
Waybar/test/smoke/leakcheck.sh
T
Alex 74f0d3393a ci(smoke): fix the mpd / hardware / leak tiers so they actually run
The first run went green but the best-effort tiers silently didn't exercise
anything:

- state.sh: the mpd `audio_output { ... }` block was on one line, which mpd
  rejects ("Unknown tokens after '{'"), so mpd never started and the mpd
  sub-tier (the #5183 empty-queue repro) skipped. Split the block across lines.
  Also move teardown into a cleanup() with `|| true` so a dead-pid kill under
  `set -e` no longer makes the step exit 1.
- hardware.sh: umockdev-run's LD_PRELOAD lands ahead of the linked-in ASan
  runtime, so ASan aborted before main() ("ASan runtime does not come first")
  and waybar never started -- the backlight/slider (#5179) path wasn't tested.
  Set verify_asan_link_order=0 so the instrumented binary runs under the preload.
- leakcheck.sh: abort_on_error=1 turned LSan's exit report into a core dump;
  force abort_on_error=0 for this report-only tier.
- lib.sh: assert_clean now also flags "ASan runtime does not come first" so a
  future preload/link-order regression fails loudly instead of passing.
2026-07-05 22:39:35 +02:00

38 lines
1.4 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
# Report leaks without aborting: abort_on_error=1 (the default gate) would turn
# LSan's exit-time report into a core dump. This tier only reports.
export ASAN_OPTIONS="detect_leaks=1:halt_on_error=0:abort_on_error=0:detect_odr_violation=0"
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=""