test: add target to gen coverage report (#295)
* test: add target to gen coverage report * test: show branch coverage * ci: setup codecov * Readme: add codecov badge * ci: upload coverage report * test: add note for CODE_COVERAGE flag
This commit is contained in:
@@ -42,3 +42,19 @@ jobs:
|
|||||||
install: base-devel mingw-w64-${{matrix.env}}-toolchain
|
install: base-devel mingw-w64-${{matrix.env}}-toolchain
|
||||||
- run: make
|
- run: make
|
||||||
- run: make test
|
- run: make test
|
||||||
|
code-coverage:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup LCOV
|
||||||
|
uses: hrishikesh-kadam/setup-lcov@v1
|
||||||
|
- name: Build and Run tests
|
||||||
|
run: make coverage -j
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
files: ./cov-html/libopenlibm.info
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: code-coverage-report
|
||||||
|
path: ./cov-html/
|
||||||
|
|||||||
@@ -5,3 +5,8 @@
|
|||||||
*.so*
|
*.so*
|
||||||
*.dylib*
|
*.dylib*
|
||||||
*.pc
|
*.pc
|
||||||
|
|
||||||
|
# code coverage
|
||||||
|
cov-html/
|
||||||
|
*.gcda
|
||||||
|
*.gcno
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ else
|
|||||||
pkgconfigdir ?= $(libdir)/pkgconfig
|
pkgconfigdir ?= $(libdir)/pkgconfig
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Build with Code Coverage
|
||||||
|
# Only test with Ubuntu + gcc + lcov, may not work for other platform.
|
||||||
|
# deps: https://github.com/linux-test-project/lcov
|
||||||
|
# You don't need to set this flag manually, `make coverage` will do it for you.
|
||||||
|
# Just Run: make clean && make coverage -j
|
||||||
|
CODE_COVERAGE ?= 0
|
||||||
|
|
||||||
USEGCC ?= 1
|
USEGCC ?= 1
|
||||||
USECLANG ?= 0
|
USECLANG ?= 0
|
||||||
|
|
||||||
@@ -162,6 +169,12 @@ LONG_DOUBLE_NOT_DOUBLE := 1
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CODE_COVERAGE),1)
|
||||||
|
CFLAGS_add += -g -O0 --coverage
|
||||||
|
LDFLAGS_add += --coverage
|
||||||
|
endif # CODE_COVERAGE==1
|
||||||
|
|
||||||
|
|
||||||
%.c.o: %.c
|
%.c.o: %.c
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) -c $< -o $@
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) -c $< -o $@
|
||||||
|
|
||||||
|
|||||||
@@ -80,9 +80,29 @@ test/test-double: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
|
|||||||
test/test-float: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
|
test/test-float: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
|
||||||
$(MAKE) -C test test-float
|
$(MAKE) -C test test-float
|
||||||
|
|
||||||
clean:
|
COVERAGE_DIR:=cov-html
|
||||||
|
COVERAGE_FILE:=$(COVERAGE_DIR)/libopenlibm.info
|
||||||
|
# Gen cov report with: make clean && make coverage -j
|
||||||
|
coverage: clean-coverage
|
||||||
|
mkdir $(COVERAGE_DIR)
|
||||||
|
$(MAKE) test CODE_COVERAGE=1
|
||||||
|
lcov -d amd64 -d bsdsrc -d ld80 -d src \
|
||||||
|
--rc lcov_branch_coverage=1 --capture --output-file $(COVERAGE_FILE)
|
||||||
|
genhtml --legend --branch-coverage \
|
||||||
|
--title "Openlibm commit `git rev-parse HEAD`" \
|
||||||
|
--output-directory $(COVERAGE_DIR)/ \
|
||||||
|
$(COVERAGE_FILE)
|
||||||
|
|
||||||
|
# Zero coverage statistics and Delete report
|
||||||
|
clean-coverage:
|
||||||
|
-lcov -d amd64 -d bsdsrc -d ld80 -d src --zerocounters
|
||||||
|
rm -f ./*/*.gcda
|
||||||
|
rm -rf $(COVERAGE_DIR)/
|
||||||
|
|
||||||
|
clean: clean-coverage
|
||||||
rm -f aarch64/*.o amd64/*.o arm/*.o bsdsrc/*.o i387/*.o loongarch64/*.o ld80/*.o ld128/*.o src/*.o powerpc/*.o mips/*.o s390/*.o riscv64/*.o
|
rm -f aarch64/*.o amd64/*.o arm/*.o bsdsrc/*.o i387/*.o loongarch64/*.o ld80/*.o ld128/*.o src/*.o powerpc/*.o mips/*.o s390/*.o riscv64/*.o
|
||||||
rm -f libopenlibm.a libopenlibm.*$(SHLIB_EXT)*
|
rm -f libopenlibm.a libopenlibm.*$(SHLIB_EXT)*
|
||||||
|
rm -f ./*/*.gcno
|
||||||
$(MAKE) -C test clean
|
$(MAKE) -C test clean
|
||||||
|
|
||||||
openlibm.pc: openlibm.pc.in Make.inc Makefile
|
openlibm.pc: openlibm.pc.in Make.inc Makefile
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# OpenLibm
|
# OpenLibm
|
||||||
|
|
||||||
|
[](https://codecov.io/gh/JuliaMath/openlibm)
|
||||||
|
|
||||||
[OpenLibm](https://openlibm.org/) is an effort to have a high quality, portable, standalone
|
[OpenLibm](https://openlibm.org/) is an effort to have a high quality, portable, standalone
|
||||||
C mathematical library ([`libm`](http://en.wikipedia.org/wiki/libm)).
|
C mathematical library ([`libm`](http://en.wikipedia.org/wiki/libm)).
|
||||||
It can be used standalone in applications and programming language
|
It can be used standalone in applications and programming language
|
||||||
|
|||||||
Reference in New Issue
Block a user