Generate coverage report (#106)
* Add check for test coverage * Add coverage html report * Install llvm * Save coverage report before doing check * Update coverate report path * Remove coverage check * Remove coverage report in make clean * Remove extra CFLAG
This commit is contained in:
parent
eb17071bf3
commit
471245001d
|
@ -23,3 +23,14 @@ jobs:
|
|||
run: |
|
||||
cd src
|
||||
make test
|
||||
- name: Install LLVM
|
||||
uses: egor-tensin/setup-clang@v1
|
||||
- name: Generate coverage report
|
||||
run: |
|
||||
cd src
|
||||
make test_cov
|
||||
- name: Save coverage report
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage
|
||||
path: src/coverage.html
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
test_c_kzg_4844
|
||||
coverage.html
|
||||
*.profraw
|
||||
*.profdata
|
||||
*.o
|
||||
*.s
|
||||
*.a
|
||||
|
@ -6,6 +9,7 @@ test_c_kzg_4844
|
|||
inc/blst.h*
|
||||
inc/blst_aux.h*
|
||||
.vscode/
|
||||
.idea/
|
||||
.clang-format
|
||||
*bindings/*/*.so
|
||||
*bindings/rust/target
|
||||
|
|
18
src/Makefile
18
src/Makefile
|
@ -4,6 +4,10 @@ ifeq ($(OS),Windows_NT)
|
|||
CFLAGS += -O2
|
||||
else
|
||||
CFLAGS += -O2 -fPIC
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
XCRUN = xcrun
|
||||
endif
|
||||
endif
|
||||
|
||||
CLANG_EXECUTABLE=clang
|
||||
|
@ -31,7 +35,17 @@ test_c_kzg_4844: test_c_kzg_4844.c c_kzg_4844.c Makefile
|
|||
${CLANG_EXECUTABLE} -Wall -I$(INCLUDE_DIRS) -DFIELD_ELEMENTS_PER_BLOB=$(FIELD_ELEMENTS_PER_BLOB) $(CFLAGS) test_c_kzg_4844.o -L ../lib -lblst -o test_c_kzg_4844 $<
|
||||
|
||||
test: test_c_kzg_4844
|
||||
./test_c_kzg_4844
|
||||
./test_c_kzg_4844
|
||||
|
||||
test_c_kzg_4844_cov: test_c_kzg_4844.c c_kzg_4844.c Makefile
|
||||
@${CLANG_EXECUTABLE} -fprofile-instr-generate -fcoverage-mapping -Wall -I$(INCLUDE_DIRS) -DFIELD_ELEMENTS_PER_BLOB=$(FIELD_ELEMENTS_PER_BLOB) -DUNIT_TESTS $(CFLAGS) -c c_kzg_4844.c -o test_c_kzg_4844.o
|
||||
@${CLANG_EXECUTABLE} -fprofile-instr-generate -fcoverage-mapping -Wall -I$(INCLUDE_DIRS) -DFIELD_ELEMENTS_PER_BLOB=$(FIELD_ELEMENTS_PER_BLOB) $(CFLAGS) test_c_kzg_4844.o -L../lib -lblst -o test_c_kzg_4844 $<
|
||||
|
||||
test_cov: test_c_kzg_4844_cov
|
||||
@LLVM_PROFILE_FILE="ckzg.profraw" ./test_c_kzg_4844
|
||||
@$(XCRUN) llvm-profdata merge --sparse ckzg.profraw -o ckzg.profdata
|
||||
@$(XCRUN) llvm-cov show ./test_c_kzg_4844 --instr-profile=ckzg.profdata --format=html c_kzg_4844.c > coverage.html
|
||||
@$(XCRUN) llvm-cov report ./test_c_kzg_4844 --instr-profile=ckzg.profdata --show-functions c_kzg_4844.c
|
||||
|
||||
clean:
|
||||
rm -f *.o test_c_kzg_4844
|
||||
rm -f *.o test_c_kzg_4844 *.profraw *.profdata *.html
|
||||
|
|
Loading…
Reference in New Issue