Browse Source

bring coverage results near reality

Steffen Jaeckel 9 years ago
parent
commit
bb56ef08eb
2 changed files with 26 additions and 7 deletions
  1. 16 3
      coverage.sh
  2. 10 4
      makefile

+ 16 - 3
coverage.sh

@@ -1,4 +1,12 @@
-#!/bin/bash -e
+#!/bin/bash
+
+set -e
+
+if [ "$#" != "5" ]; then
+    echo "Usage is: ${0} \"coverage\" \"<first CFLAGS>\" \"<makefile>\" \"<last CFLAGS>\" <math library to link to>"
+    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
 if [ -z "$(echo $CC | grep "gcc")" ]; then
     echo "no gcc detected, early exit success"
     echo "no gcc detected, early exit success"
@@ -8,7 +16,7 @@ fi
 # output version
 # output version
 bash printinfo.sh
 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
 if [ -a testok.txt ] && [ -f testok.txt ]; then
    echo
    echo
 else
 else
@@ -20,7 +28,12 @@ fi
 ./sizes
 ./sizes
 ./constants
 ./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
 exit 0
 
 

+ 10 - 4
makefile

@@ -231,14 +231,14 @@ timing: library testprof/$(LIBTEST) $(TIMINGS)
 ifneq ($V,1)
 ifneq ($V,1)
 	@echo "   * ${CC} $@"
 	@echo "   * ${CC} $@"
 endif
 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
 .PHONY: test
 test: library testprof/$(LIBTEST) $(TESTS)
 test: library testprof/$(LIBTEST) $(TESTS)
 ifneq ($V,1)
 ifneq ($V,1)
 	@echo "   * ${CC} $@"
 	@echo "   * ${CC} $@"
 endif
 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
 # build the demos from a template
 define DEMO_template
 define DEMO_template
@@ -246,12 +246,16 @@ $(1): demos/$(1).o library
 ifneq ($V,1)
 ifneq ($V,1)
 	@echo "   * $${CC} $$@"
 	@echo "   * $${CC} $$@"
 endif
 endif
-	$${silent} $$(CC) $$< $$(LIBNAME) $$(EXTRALIBS) -o $(1)
+	$${silent} $$(CC) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1)
 endef
 endef
 
 
 $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
 $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
 
 
 all_test: test tv_gen $(DEMOS)
 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
 #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
 #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
 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: CFLAGS += -fprofile-arcs -ftest-coverage
 coverage: EXTRALIBS += -lgcov
 coverage: EXTRALIBS += -lgcov
+coverage: LIB_PRE = -Wl,--whole-archive
+coverage: LIB_POST = -Wl,--no-whole-archive
 
 
 coverage: test
 coverage: test
 	./test
 	./test