diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 168f5d2..4fc19d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,4 +16,16 @@ jobs: - name: Build run: make dockerbuild && make docker working-directory: uvm32 + - name: Code Coverage Report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: uvm32/test/coverage.xml + badge: true + fail_below_min: false + format: markdown + hide_branch_rate: false + hide_complexity: true + indicators: true + output: both + thresholds: '60 80' diff --git a/Dockerfile b/Dockerfile index fb7bb0d..9928149 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,3 +35,7 @@ RUN apt-get install -y qemu-system-misc # host-sdl RUN apt-get install -y libsdl3-0 libsdl3-dev + +# code coverage +RUN apt-get install -y gcovr + diff --git a/Makefile b/Makefile index b4f911c..4341c60 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ .PHONY: test all: - make -C test + (cd test && make clean) (cd hosts && make) (cd apps && make) clean: - make -C test clean + (cd test && make clean) (cd hosts && make clean) (cd apps && make clean) diff --git a/test/Makefile b/test/Makefile index ac178c9..4e16274 100644 --- a/test/Makefile +++ b/test/Makefile @@ -9,9 +9,17 @@ TESTS = \ RUNCMD = $(foreach TEST,${TESTS},make -C ${TEST} &&) CLEANCMD = $(foreach TEST,${TESTS},make -C ${TEST} clean &&) +ifeq (,$(shell which gcovr)) + GCOVRCMD=echo Install gcovr for code coverage reports +else + GCOVRCMD=gcovr -r ../ --filter ".*uvm32.c" && gcovr -r ../ --filter ".*uvm32.c" --cobertura-pretty --cobertura coverage.xml +endif + all: ${RUNCMD} true + ${GCOVRCMD} clean: ${CLEANCMD} true + rm -f coverage.xml diff --git a/test/common/makefile.common b/test/common/makefile.common index 715c70d..e7d35aa 100644 --- a/test/common/makefile.common +++ b/test/common/makefile.common @@ -7,8 +7,8 @@ UVM32_MEMORY_SIZE ?= 16384 CFLAGS +=-std=c99 CFLAGS += -Wall CFLAGS += -Werror - CFLAGS += -DUVM32_MEMORY_SIZE=${UVM32_MEMORY_SIZE} +CFLAGS += -fprofile-arcs -ftest-coverage SUITE_NAME=tests @@ -31,6 +31,6 @@ test/test_runners/${SUITE_NAME}_Runner.c: test/${SUITE_NAME}.c @ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c clean: - rm -rf $(TARGET1) test/test_runners + rm -rf $(TARGET1) test/test_runners *.gcno *.gcda *.gcov (cd rom && make clean)