1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#!/bin/bash
# Copyright 2015 - 2025, GIBIS-Unifesp and the wiRedPanda contributors
# SPDX-License-Identifier: GPL-3.0-or-later
set -e
echo "๐ Building with coverage enabled..."
cmake -B build -G Ninja -DENABLE_COVERAGE=ON
cmake --build build --config Release
echo "๐งช Running tests with coverage collection..."
QT_QPA_PLATFORM=offscreen ./build/wiredpanda-test
echo "๐ Generating coverage data..."
cd build
gcov -abcfu $(find . -name "*.gcno")
echo "๐ Generating HTML coverage report..."
# Install lcov if not available
if ! command -v lcov &> /dev/null; then
echo "Installing lcov..."
sudo apt-get update && sudo apt-get install -y lcov
fi
# Generate lcov info file
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/test/*' '*/build/*' --output-file coverage_filtered.info
# Generate HTML report with dark theme
genhtml coverage_filtered.info --output-directory coverage_html --css-file ../lcov-dark-theme.css
echo "โ
Coverage report generated!"
echo "๐ Open coverage_html/index.html in your browser to view the report"
echo "๐ Coverage data location: build/coverage.info"
echo "๐ HTML report location: build/coverage_html/"
|