Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/build-firmware.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Build Firmware

on: [push, pull_request, workflow_dispatch]
on:
push:
branches:
- master
- prod-*
pull_request:
workflow_dispatch:


jobs:
build-firmware:
Expand Down
29 changes: 27 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Unit Tests

on: [push,pull_request]
on:
push:
branches:
- master
- prod-*
pull_request:
workflow_dispatch:

jobs:
build:
Expand All @@ -24,21 +30,40 @@ 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
working-directory: .
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

- name: Generate Code Coverage
if: ${{ matrix.os != 'macos-latest' }}
working-directory: ./test/
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: ./test/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' }}
Expand Down
17 changes: 17 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -198,6 +211,10 @@ ifeq ($(SANITIZE),yes)
ULIBS += -fsanitize=address -fsanitize=undefined
endif

ifeq ($(COVERAGE),yes)
ULIBS += $(COVERAGE_FLAGS)
endif

#
# End of user defines
##############################################################################
Expand Down
18 changes: 18 additions & 0 deletions test/ci_gcov.sh
Original file line number Diff line number Diff line change
@@ -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