File tree Expand file tree Collapse file tree 5 files changed +57
-1
lines changed Expand file tree Collapse file tree 5 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 4242 install : base-devel mingw-w64-${{matrix.env}}-toolchain
4343 - run : make
4444 - run : make test
45+ code-coverage :
46+ runs-on : ubuntu-latest
47+ steps :
48+ - uses : actions/checkout@v4
49+ - name : Setup LCOV
50+ uses : hrishikesh-kadam/setup-lcov@v1
51+ - name : Build and Run tests
52+ run : make coverage -j
53+ - name : Upload coverage to Codecov
54+ uses : codecov/codecov-action@v3
55+ with :
56+ files : ./cov-html/libopenlibm.info
57+ - uses : actions/upload-artifact@v4
58+ with :
59+ name : code-coverage-report
60+ path : ./cov-html/
Original file line number Diff line number Diff line change 55* .so *
66* .dylib *
77* .pc
8+
9+ # code coverage
10+ cov-html /
11+ * .gcda
12+ * .gcno
Original file line number Diff line number Diff line change 2121pkgconfigdir ?= $(libdir )/pkgconfig
2222endif
2323
24+ # Build with Code Coverage
25+ # Only test with Ubuntu + gcc + lcov, may not work for other platform.
26+ # deps: https://github.com/linux-test-project/lcov
27+ # You don't need to set this flag manually, `make coverage` will do it for you.
28+ # Just Run: make clean && make coverage -j
29+ CODE_COVERAGE ?= 0
30+
2431USEGCC ?= 1
2532USECLANG ?= 0
2633
@@ -162,6 +169,12 @@ LONG_DOUBLE_NOT_DOUBLE := 1
162169endif
163170endif
164171
172+ ifeq ($(CODE_COVERAGE ), 1 )
173+ CFLAGS_add += -g -O0 --coverage
174+ LDFLAGS_add += --coverage
175+ endif # CODE_COVERAGE==1
176+
177+
165178%. c . o : %. c
166179 $(CC ) $(CPPFLAGS ) $(CFLAGS ) $(CFLAGS_add ) -c $< -o $@
167180
Original file line number Diff line number Diff line change @@ -80,9 +80,29 @@ test/test-double: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
8080test/test-float : libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT )
8181 $(MAKE ) -C test test-float
8282
83- clean :
83+ COVERAGE_DIR: =cov-html
84+ COVERAGE_FILE: =$(COVERAGE_DIR ) /libopenlibm.info
85+ # Gen cov report with: make clean && make coverage -j
86+ coverage : clean-coverage
87+ mkdir $(COVERAGE_DIR )
88+ $(MAKE ) test CODE_COVERAGE=1
89+ lcov -d amd64 -d bsdsrc -d ld80 -d src \
90+ --rc lcov_branch_coverage=1 --capture --output-file $(COVERAGE_FILE )
91+ genhtml --legend --branch-coverage \
92+ --title " Openlibm commit ` git rev-parse HEAD` " \
93+ --output-directory $(COVERAGE_DIR ) / \
94+ $(COVERAGE_FILE )
95+
96+ # Zero coverage statistics and Delete report
97+ clean-coverage :
98+ -lcov -d amd64 -d bsdsrc -d ld80 -d src --zerocounters
99+ rm -f ./* /* .gcda
100+ rm -rf $(COVERAGE_DIR ) /
101+
102+ clean : clean-coverage
84103 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
85104 rm -f libopenlibm.a libopenlibm.* $(SHLIB_EXT ) *
105+ rm -f ./* /* .gcno
86106 $(MAKE ) -C test clean
87107
88108openlibm.pc : openlibm.pc.in Make.inc Makefile
Original file line number Diff line number Diff line change 11# OpenLibm
22
3+ [ ![ codecov] ( https://codecov.io/gh/JuliaMath/openlibm/graph/badge.svg?token=eTAdN7d9cg )] ( https://codecov.io/gh/JuliaMath/openlibm )
4+
35[ OpenLibm] ( https://openlibm.org/ ) is an effort to have a high quality, portable, standalone
46C mathematical library ([ ` libm ` ] ( http://en.wikipedia.org/wiki/libm ) ).
57It can be used standalone in applications and programming language
You can’t perform that action at this time.
0 commit comments