Compare commits

...

2 Commits

Author SHA1 Message Date
2bea87b39a Run tests in the validate gitea action
All checks were successful
Validate the build / validate-build (push) Successful in 29s
2025-04-06 09:23:25 +02:00
2eb7b3c2f1 use llvm to generate test coverage 2025-04-06 09:17:51 +02:00
2 changed files with 17 additions and 1 deletions

View File

@ -34,3 +34,7 @@ jobs:
- name: make validate
run: |
make validate
- name: make test
run: |
make test

View File

@ -1,9 +1,21 @@
.PHONY: test
CFLAGS?=-Wall -Wextra -Wpedantic -O0 -g3 -std=c23 -fno-omit-frame-pointer -fno-optimize-sibling-calls -D_POSIX_C_SOURCE=200809L -fprofile-instr-generate -fcoverage-mapping
LDFLAGS?=-fprofile-instr-generate
BUILD_DIR=build/test/
TARGET=oas-tests
SOURCES = $(filter-out src/main.c, $(shell find src/ tests/ -type f -name '*.c'))
-include make/base.mk
test: $(BUILD_DIR)$(TARGET)
$(BUILD_DIR)$(TARGET)
mkdir -p reports/coverage
LLVM_PROFILE_FILE="reports/coverage/tests.profraw" $(BUILD_DIR)$(TARGET)
llvm-profdata merge -sparse reports/coverage/tests.profraw -o reports/coverage/tests.profdata
llvm-cov show $(BUILD_DIR)$(TARGET) -instr-profile=reports/coverage/tests.profdata -format=html -output-dir=reports/coverage/html -ignore-filename-regex="tests/.*"
@echo "--"
@echo "Test coverage:"
@echo "file://$$(realpath reports/coverage/html/index.html)"
@echo "--"
clean:
rm -rf reports/coverage