From 2094ec327db0147678bf531a8fb614fd36daa399 Mon Sep 17 00:00:00 2001 From: FDSoftware Date: Sat, 24 Jan 2026 19:33:50 -0300 Subject: [PATCH 1/4] gcov coverage report --- .github/workflows/tests.yaml | 24 +++++++++++++++++++++--- test/Makefile | 17 +++++++++++++++++ test/ci_gcov.sh | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100755 test/ci_gcov.sh diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5474b39e..d954229c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,6 +1,11 @@ name: Unit Tests -on: [push,pull_request] +on: + push: + branches: + - master + pull_request: + workflow_dispatch: jobs: build: @@ -24,7 +29,8 @@ jobs: if: ${{ matrix.os != 'macos-latest' }} run: | sudo apt-get update - sudo apt-get install valgrind + sudo apt-get install valgrind python3-pip + pip install gcovr==8.5 - name: Print Compiler version # NOTE: on mac, this is actually symlink'd to clang, not gcc, but that's ok - we want to build on both @@ -33,12 +39,24 @@ jobs: - name: Build Tests working-directory: test - run: make -j4 SANITIZE=yes + run: make -j4 SANITIZE=yes COVERAGE=yes - name: Run Tests working-directory: test run: ASAN_OPTIONS=detect_stack_use_after_return=1 build/wideband_test + - name: Generate Code Coverage + if: ${{ matrix.os != 'macos-latest' }} + working-directory: ./unit_tests/ + run: ./ci_gcov.sh + + - name: Upload code coverage artifacts + if: ${{ matrix.os != 'macos-latest' }} + uses: actions/upload-artifact@v6 + with: + name: rusefi_wideband_code_coverage + path: ./unit_tests/gcov_working_area/gcov + - name: Rebuild Tests For Valgrind # Valgrind isn't compatible with address sanitizer, so we have to rebuild the code if: ${{ matrix.os != 'macos-latest' }} diff --git a/test/Makefile b/test/Makefile index e90319e9..a1d2ff26 100644 --- a/test/Makefile +++ b/test/Makefile @@ -50,6 +50,19 @@ ifeq ($(SANITIZE),) endif endif +ifeq ($(COVERAGE),yes) + ifeq ($(IS_CLANG),1) + COVERAGE_FLAGS := -fprofile-instr-generate -fcoverage-mapping + $(info Detected Clang: using LLVM-style coverage flags) + else + COVERAGE_FLAGS := --coverage + $(info Detected GCC: using GCC-style coverage flags) + endif + USE_COPT += $(COVERAGE_FLAGS) + USE_CPPOPT += $(COVERAGE_FLAGS) +endif + + IS_MAC = no ifneq ($(OS),Windows_NT) UNAME_S := $(shell uname -s) @@ -198,6 +211,10 @@ ifeq ($(SANITIZE),yes) ULIBS += -fsanitize=address -fsanitize=undefined endif +ifeq ($(COVERAGE),yes) + ULIBS += $(COVERAGE_FLAGS) +endif + # # End of user defines ############################################################################## diff --git a/test/ci_gcov.sh b/test/ci_gcov.sh new file mode 100755 index 00000000..80144725 --- /dev/null +++ b/test/ci_gcov.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# +# this script is used by github actions +# + +rm -rf gcov_working_area + +mkdir gcov_working_area +cd gcov_working_area +mkdir gcov + +echo -e "\nGenerating rusEFI wideband unit test coverage" + +# for debug use --html-details --html-single-page --verbose to generate a single html +gcovr --exclude-throw-branches --exclude-unreachable-branches --decisions --merge-mode-functions=separate \ + --exclude '/.*/googletest/' \ + -j4 -r ../.. --html-nested gcov/index.html \ No newline at end of file From daebaa0ea1ff8c9b1ca2ff4398b6e6784990cf5a Mon Sep 17 00:00:00 2001 From: FDSoftware Date: Sat, 24 Jan 2026 19:39:40 -0300 Subject: [PATCH 2/4] dont build with coverage for macos --- .github/workflows/build-firmware.yaml | 8 +++++++- .github/workflows/tests.yaml | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml index 17b169b0..67aa9449 100644 --- a/.github/workflows/build-firmware.yaml +++ b/.github/workflows/build-firmware.yaml @@ -1,6 +1,12 @@ name: Build Firmware -on: [push, pull_request, workflow_dispatch] +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + jobs: build-firmware: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d954229c..f3a5aa3d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -38,9 +38,15 @@ jobs: run: gcc -v - name: Build Tests + if: ${{ matrix.os != 'macos-latest' }} working-directory: test run: make -j4 SANITIZE=yes COVERAGE=yes + - name: Build Tests + if: ${{ matrix.os == 'macos-latest' }} + working-directory: test + run: make -j4 SANITIZE=yes + - name: Run Tests working-directory: test run: ASAN_OPTIONS=detect_stack_use_after_return=1 build/wideband_test From 26d22d61237aa5e9895fa90a6b7a949b7477b37e Mon Sep 17 00:00:00 2001 From: FDSoftware Date: Sat, 24 Jan 2026 19:42:36 -0300 Subject: [PATCH 3/4] unit_tests => tests --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f3a5aa3d..d0bf9db4 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -53,7 +53,7 @@ jobs: - name: Generate Code Coverage if: ${{ matrix.os != 'macos-latest' }} - working-directory: ./unit_tests/ + working-directory: ./test/ run: ./ci_gcov.sh - name: Upload code coverage artifacts @@ -61,7 +61,7 @@ jobs: uses: actions/upload-artifact@v6 with: name: rusefi_wideband_code_coverage - path: ./unit_tests/gcov_working_area/gcov + path: ./test/gcov_working_area/gcov - name: Rebuild Tests For Valgrind # Valgrind isn't compatible with address sanitizer, so we have to rebuild the code From 09fb032003820e521058a23c5b3cf5450f518063 Mon Sep 17 00:00:00 2001 From: FDSoftware Date: Sat, 24 Jan 2026 21:41:23 -0300 Subject: [PATCH 4/4] fix branch target --- .github/workflows/build-firmware.yaml | 1 + .github/workflows/tests.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml index 67aa9449..252e2d6c 100644 --- a/.github/workflows/build-firmware.yaml +++ b/.github/workflows/build-firmware.yaml @@ -4,6 +4,7 @@ on: push: branches: - master + - prod-* pull_request: workflow_dispatch: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d0bf9db4..95654c4e 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -4,6 +4,7 @@ on: push: branches: - master + - prod-* pull_request: workflow_dispatch: