-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from ckormanyos/coverage_in_ci
Fix #161 code coverage in CI
- Loading branch information
Showing
8 changed files
with
342 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright Christopher Kormanyos 2022. | ||
# Distributed under the Boost Software License, | ||
# Version 1.0. (See accompanying file LICENSE_1_0.txt | ||
# or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
# ------------------------------------------------------------------------------ | ||
|
||
PATH_MAKE = $(CURDIR) | ||
PATH_PRJ = $(PATH_MAKE)/../.. | ||
PATH_SRC = $(PATH_PRJ) | ||
PATH_BIN = $(PATH_MAKE)/bin | ||
PATH_ERR = $(PATH_MAKE)/err | ||
PATH_OBJ = $(PATH_MAKE)/obj | ||
|
||
CAT = cat | ||
GNUECHO = echo | ||
LS = ls | ||
MKDIR = mkdir | ||
GCOV = gcov | ||
LCOV = lcov | ||
GENHTML = genhtml | ||
RM = rm | ||
SED = sed | ||
|
||
include make_gcov_02_files.gmk | ||
include make_gcov_03_flags.gmk | ||
|
||
FILES_ALL = $(FILES_PRJ) | ||
FILES_O = $(addprefix $(PATH_OBJ)/, $(notdir $(addsuffix .o, $(FILES_ALL)))) | ||
FILES_GCOV = $(addprefix $(PATH_OBJ)/, $(notdir $(addsuffix .gcov, $(FILES_ALL)))) | ||
|
||
# ------------------------------------------------------------------------------ | ||
# VPATH definition: VPATH is required for make to find the source files. | ||
# ------------------------------------------------------------------------------ | ||
VPATH := $(sort $(dir $(FILES_ALL))) | ||
|
||
|
||
# ------------------------------------------------------------------------------ | ||
# Executable file: | ||
# ------------------------------------------------------------------------------ | ||
|
||
.PHONY: $(PATH_BIN)/wide_integer.exe | ||
$(PATH_BIN)/wide_integer.exe: $(FILES_O) | ||
# Link coverage-instrumented executable | ||
@$(GNUECHO) +++ link object files to $(PATH_BIN)/wide_integer.exe | ||
@$(CC) -x none $(CXXFLAGS) $(FILES_O) -o $(PATH_BIN)/wide_integer.exe | ||
@$(GNUECHO) | ||
|
||
|
||
# ------------------------------------------------------------------------------ | ||
# Main dependency: | ||
# Compile all files and link them. | ||
# Run gcov and get results. | ||
# (See also https://github.com/codecov/example-cpp11-cmake) | ||
# ------------------------------------------------------------------------------ | ||
|
||
.PHONY: gcov | ||
gcov: $(PATH_BIN)/wide_integer.exe | ||
# Obtain results | ||
@$(GNUECHO) +++ execute $(PATH_BIN)/wide_integer.exe | ||
@$(PATH_BIN)/wide_integer.exe | ||
@$(GNUECHO) | ||
@$(GNUECHO) +++ running gcov | ||
@$(GCOV) $(GCOV_FLAGS) $(addsuffix .cpp,$(FILES_PRJ)) | ||
@$(GNUECHO) | ||
@$(GNUECHO) +++ running lcov | ||
@$(LCOV) $(LCOV_BRANCH) -c --directory obj --output-file coverage_unfiltered.info | ||
@$(LCOV) $(LCOV_BRANCH) --remove coverage_unfiltered.info $(LCOV_REMOVES) --output-file coverage.info | ||
@$(GNUECHO) | ||
@$(GNUECHO) +++ running genhtml | ||
@$(GENHTML) coverage.info $(LCOV_BRANCH) --demangle-cpp --output-directory $(PATH_BIN)/report | ||
@$(GNUECHO) | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Clean temporary files. | ||
# ------------------------------------------------------------------------------ | ||
|
||
.PHONY: clean | ||
clean: | ||
# creating output directories | ||
@$(GNUECHO) +++ cleaning output directories | ||
@-$(RM) -rf $(PATH_BIN)* || uname -r | ||
@-$(RM) -rf $(PATH_ERR)* || uname -r | ||
@-$(RM) -rf $(PATH_OBJ)* || uname -r | ||
@-$(RM) -f *.gcov || uname -r | ||
@-$(RM) -f coverage* || uname -r | ||
@$(GNUECHO) | ||
|
||
|
||
# ------------------------------------------------------------------------------ | ||
# Prepare the gcov build. | ||
# ------------------------------------------------------------------------------ | ||
|
||
.PHONY: prepare | ||
prepare: clean | ||
@$(GNUECHO) +++ creating output directories | ||
@-$(MKDIR) -p $(PATH_BIN) | ||
@-$(MKDIR) -p $(PATH_ERR) | ||
@-$(MKDIR) -p $(PATH_OBJ) | ||
@$(GNUECHO) | ||
@$(GNUECHO) +++ print gcov version | ||
@$(GCOV) --version | ||
@$(GNUECHO) | ||
@$(GNUECHO) +++ print include paths | ||
@$(GNUECHO) $(C_INCLUDES) | ||
@$(GNUECHO) | ||
|
||
# ------------------------------------------------------------------------------ | ||
# pattern rule for compilation of cpp-files | ||
# ------------------------------------------------------------------------------ | ||
$(PATH_OBJ)/%.o : %.cpp | ||
@-$(GNUECHO) +++ compiling: $(notdir $<) to $(notdir $(PATH_OBJ)/$(basename $(@F)).o) | ||
@-$(CC) $(CXXFLAGS) -x c++ -c $(C_INCLUDES) $(C_DEFINES) $< -o $(PATH_OBJ)/$(basename $(@F)).o 2> $(PATH_ERR)/$(basename $(@F)).err | ||
@-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|:\([0-9]*\):|(\1) :|' $(PATH_ERR)/$(basename $(@F)).err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright Christopher Kormanyos 2022. | ||
# Distributed under the Boost Software License, | ||
# Version 1.0. (See accompanying file LICENSE_1_0.txt | ||
# or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
# ------------------------------------------------------------------------------ | ||
|
||
FILES_PRJ = $(PATH_SRC)/test/test \ | ||
$(PATH_SRC)/test/test_uintwide_t_boost_backend \ | ||
$(PATH_SRC)/test/test_uintwide_t_edge_cases \ | ||
$(PATH_SRC)/test/test_uintwide_t_examples \ | ||
$(PATH_SRC)/test/test_uintwide_t_float_convert \ | ||
$(PATH_SRC)/test/test_uintwide_t_int_convert \ | ||
$(PATH_SRC)/test/test_uintwide_t_n_base \ | ||
$(PATH_SRC)/test/test_uintwide_t_n_binary_ops_base \ | ||
$(PATH_SRC)/test/test_uintwide_t_spot_values \ | ||
$(PATH_SRC)/examples/example000a_builtin_convert \ | ||
$(PATH_SRC)/examples/example000_numeric_limits \ | ||
$(PATH_SRC)/examples/example001_mul_div \ | ||
$(PATH_SRC)/examples/example001a_div_mod \ | ||
$(PATH_SRC)/examples/example002_shl_shr \ | ||
$(PATH_SRC)/examples/example003_sqrt \ | ||
$(PATH_SRC)/examples/example003a_cbrt \ | ||
$(PATH_SRC)/examples/example004_rootk_pow \ | ||
$(PATH_SRC)/examples/example005_powm \ | ||
$(PATH_SRC)/examples/example005a_pow_factors_of_p99 \ | ||
$(PATH_SRC)/examples/example006_gcd \ | ||
$(PATH_SRC)/examples/example007_random_generator \ | ||
$(PATH_SRC)/examples/example008_miller_rabin_prime \ | ||
$(PATH_SRC)/examples/example008a_miller_rabin_prime \ | ||
$(PATH_SRC)/examples/example009_timed_mul \ | ||
$(PATH_SRC)/examples/example009a_timed_mul_4_by_4 \ | ||
$(PATH_SRC)/examples/example009b_timed_mul_8_by_8 \ | ||
$(PATH_SRC)/examples/example010_uint48_t \ | ||
$(PATH_SRC)/examples/example011_uint24_t \ | ||
$(PATH_SRC)/examples/example012_rsa_crypto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright Christopher Kormanyos 2022. | ||
# Distributed under the Boost Software License, | ||
# Version 1.0. (See accompanying file LICENSE_1_0.txt | ||
# or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
# ------------------------------------------------------------------------------ | ||
|
||
BOOST_ROOT_FOR_GCOV = /mnt/c/boost/boost_1_78_0 | ||
CC = g++ | ||
STD = c++11 | ||
ALL_COV = 0 | ||
|
||
ifneq ($(MY_BOOST_ROOT),) | ||
BOOST_ROOT_FOR_GCOV := $(MY_BOOST_ROOT) | ||
endif | ||
|
||
ifneq ($(MY_CC),) | ||
CC := $(MY_CC) | ||
endif | ||
|
||
ifneq ($(MY_STD),) | ||
STD := $(MY_STD) | ||
endif | ||
|
||
ifneq ($(MY_STD),) | ||
STD := $(MY_STD) | ||
endif | ||
|
||
ifneq ($(MY_ALL_COV),) | ||
ALL_COV := $(MY_ALL_COV) | ||
endif | ||
|
||
CXXFLAGS = -march=native \ | ||
-mtune=native \ | ||
-O2 \ | ||
-Wall \ | ||
-Wextra \ | ||
-Wconversion \ | ||
-Wsign-conversion \ | ||
-std=$(STD) \ | ||
-pthread \ | ||
-lpthread \ | ||
-fno-inline-functions \ | ||
-fprofile-arcs \ | ||
-ftest-coverage | ||
|
||
C_DEFINES = WIDE_INTEGER_HAS_COVERAGE \ | ||
WIDE_INTEGER_HAS_LIMB_TYPE_UINT64 | ||
|
||
C_INCLUDES = $(PATH_SRC) \ | ||
$(BOOST_ROOT_FOR_GCOV) | ||
|
||
C_DEFINES :=$(addprefix -D,$(C_DEFINES)) | ||
C_INCLUDES :=$(addprefix -I,$(C_INCLUDES)) | ||
|
||
GCOV_FLAGS = --object-directory obj \ | ||
--demangled-names | ||
|
||
|
||
# ------------------------------------------------------------------------------ | ||
# All gcov flags: The GCOV_FLAGS below are equivalent to -abcfu | ||
# ------------------------------------------------------------------------------ | ||
|
||
ifneq ($(ALL_COV),0) | ||
GCOV_FLAGS := $(GCOV_FLAGS) \ | ||
--all-blocks \ | ||
--branch-counts \ | ||
--branch-probabilities \ | ||
--function-summaries \ | ||
--unconditional-branches | ||
endif | ||
|
||
LCOV_BRANCH = | ||
|
||
ifneq ($(ALL_COV),0) | ||
LCOV_BRANCH := --rc lcov_branch_coverage=1 | ||
endif | ||
|
||
LCOV_REMOVES = '/usr/*' \ | ||
'*boost/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright Christopher Kormanyos 2022. | ||
# Distributed under the Boost Software License, | ||
# Version 1.0. (See accompanying file LICENSE_1_0.txt | ||
# or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
# ------------------------------------------------------------------------------ | ||
|
||
name: wide_integer_codecov | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
gnumake-gcc-gcov-native: | ||
runs-on: ubuntu-20.04 | ||
defaults: | ||
run: | ||
shell: bash | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
standard: [ c++11 ] | ||
compiler: [ g++ ] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: '0' | ||
- name: update-tools | ||
run: sudo apt install lcov | ||
- name: clone-submods-bootstrap-headers-boost-develop | ||
run: | | ||
git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root | ||
cd ../boost-root | ||
git submodule update --init tools | ||
git submodule update --init libs/config | ||
git submodule update --init libs/multiprecision | ||
./bootstrap.sh | ||
./b2 headers | ||
- name: gnumake-gcc-gcov-native | ||
run: | | ||
grep BOOST_VERSION ../boost-root/boost/version.hpp | ||
cd .gcov/make | ||
echo "build and run gcov/lcov/genhtml" | ||
echo "make prepare -f make_gcov_01_generic.gmk MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}" | ||
echo | ||
make prepare -f make_gcov_01_generic.gmk MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }} | ||
echo | ||
echo "make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}" | ||
echo | ||
make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }} | ||
echo | ||
echo "return to wide-integer root directory" | ||
cd ../.. | ||
- name: upload-codecov | ||
uses: codecov/codecov-action@v2 | ||
with: | ||
files: .gcov/make/coverage.info | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: true | ||
functionalities: fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.