diff --git a/coverage.sh b/coverage.sh index 601367c..fcdf53d 100755 --- a/coverage.sh +++ b/coverage.sh @@ -1,4 +1,12 @@ -#!/bin/bash -e +#!/bin/bash + +set -e + +if [ "$#" != "5" ]; then + echo "Usage is: ${0} \"coverage\" \"\" \"\" \"\" " + echo "CC=gcc ${0} \"coverage\" \" \" \"makefile\" \"-DUSE_LTM -DLTM_DESC -I../libtommath\" ../libtommath/libtommath.a" + exit -1 +fi if [ -z "$(echo $CC | grep "gcc")" ]; then echo "no gcc detected, early exit success" @@ -8,7 +16,7 @@ fi # output version bash printinfo.sh -bash build.sh " $1" " $2" " $3 " "$4 -fprofile-arcs -ftest-coverage " "$5 -lgcov" +bash build.sh " $1" " $2" " $3 COVERAGE=1" "$4 -fprofile-arcs -ftest-coverage " "$5 -lgcov" if [ -a testok.txt ] && [ -f testok.txt ]; then echo else @@ -20,7 +28,12 @@ fi ./sizes ./constants -cpp-coveralls -e 'demos/' -e 'testprof/' -e 'notes/' -e 'src/headers/' +# if this was executed as './coverage.sh ...' create coverage locally +if [[ "${0%% *}" == "./${0##*/}" ]]; then + make lcov-single +else + cpp-coveralls -e 'demos/' -e 'testprof/' -e 'notes/' -e 'src/headers/' +fi exit 0 diff --git a/makefile b/makefile index f603b81..4652277 100644 --- a/makefile +++ b/makefile @@ -231,14 +231,14 @@ timing: library testprof/$(LIBTEST) $(TIMINGS) ifneq ($V,1) @echo " * ${CC} $@" endif - ${silent} $(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) + ${silent} $(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING) .PHONY: test test: library testprof/$(LIBTEST) $(TESTS) ifneq ($V,1) @echo " * ${CC} $@" endif - ${silent} $(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) + ${silent} $(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TEST) # build the demos from a template define DEMO_template @@ -246,12 +246,16 @@ $(1): demos/$(1).o library ifneq ($V,1) @echo " * $${CC} $$@" endif - $${silent} $$(CC) $$< $$(LIBNAME) $$(EXTRALIBS) -o $(1) + $${silent} $$(CC) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1) endef $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) all_test: test tv_gen $(DEMOS) +ifeq ($(COVERAGE),1) +all_test: LIB_PRE = -Wl,--whole-archive +all_test: LIB_POST = -Wl,--no-whole-archive +endif #This rule installs the library and the header files. This must be run #as root in order to have a high enough permission to write to the correct @@ -300,9 +304,11 @@ lcov: lcov-single: | cleancov-clean lcov-single-create lcov -#cmake the code coverage of the library +#make the code coverage of the library coverage: CFLAGS += -fprofile-arcs -ftest-coverage coverage: EXTRALIBS += -lgcov +coverage: LIB_PRE = -Wl,--whole-archive +coverage: LIB_POST = -Wl,--no-whole-archive coverage: test ./test