change coverage tool from gcov to gcovr

Sun, 29 Dec 2024 15:24:20 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 29 Dec 2024 15:24:20 +0100
changeset 1064
f3b04cd60776
parent 1063
e453e717876e
child 1065
6eb7b54975ee

change coverage tool from gcov to gcovr

configure file | annotate | diff | comparison | revisions
docs/Makefile file | annotate | diff | comparison | revisions
make/project.xml file | annotate | diff | comparison | revisions
src/Makefile file | annotate | diff | comparison | revisions
--- a/configure	Sat Dec 28 17:32:36 2024 +0100
+++ b/configure	Sun Dec 29 15:24:20 2024 +0100
@@ -156,7 +156,7 @@
 # custom variables
 if true \
       ; then
-    src_dir=`pwd`
+    root_dir=`pwd`
     DOXYGEN=`command -v doxygen`
     PANDOC=`command -v pandoc`
 fi
@@ -310,6 +310,11 @@
         if notistoolchain "gcc"; then
             break
         fi
+        if command -v gcovr > /dev/null ; then
+            :
+        else
+            break
+        fi
         TEMP_CFLAGS="$TEMP_CFLAGS \${COVERAGE_CFLAGS}"
         TEMP_LDFLAGS="$TEMP_LDFLAGS \${COVERAGE_LDFLAGS}"
         print_check_msg "$dep_checked_coverage" "yes\n"
@@ -523,10 +528,10 @@
 LIBVERSION_MAJOR=5
 
 # build directory structure !! do not change or override !!
-src_dir=${src_dir}
-build_dir=${src_dir}/build
-docs_dir=${src_dir}/build/docs
-dist_dir=${src_dir}/dist
+root_dir=${root_dir}
+build_dir=${root_dir}/build
+docs_dir=${root_dir}/build/docs
+dist_dir=${root_dir}/dist
 __EOF__
         break
     done
--- a/docs/Makefile	Sat Dec 28 17:32:36 2024 +0100
+++ b/docs/Makefile	Sun Dec 29 15:24:20 2024 +0100
@@ -40,7 +40,7 @@
 	$(COPYALL) $< "$@/.."
 
 $(docs_dir)/web/api: FORCE
-	cd $(src_dir); $(DOXYGEN)
+	cd $(root_dir); $(DOXYGEN)
 
 $(docs_dir)/web:
 	$(MKDIR) $@
--- a/make/project.xml	Sat Dec 28 17:32:36 2024 +0100
+++ b/make/project.xml	Sun Dec 29 15:24:20 2024 +0100
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="0.3" xmlns="http://unixwork.de/uwproj">
     <config>
-        <var name="src_dir" exec="true">pwd</var>
+        <var name="root_dir" exec="true">pwd</var>
         <var name="DOXYGEN" exec="true">command -v doxygen</var>
         <var name="PANDOC" exec="true">command -v pandoc</var>
     </config>
@@ -14,10 +14,10 @@
             LIBVERSION_MAJOR=5
 
             # build directory structure !! do not change or override !!
-            src_dir=${src_dir}
-            build_dir=${src_dir}/build
-            docs_dir=${src_dir}/build/docs
-            dist_dir=${src_dir}/dist
+            root_dir=${root_dir}
+            build_dir=${root_dir}/build
+            docs_dir=${root_dir}/build/docs
+            dist_dir=${root_dir}/dist
         </make>
     </dependency>
     
@@ -83,6 +83,7 @@
     <dependency name="coverage" toolchain="gcc">
         <cflags>\${COVERAGE_CFLAGS}</cflags>
         <ldflags>\${COVERAGE_LDFLAGS}</ldflags>
+        <test>command -v gcovr</test>
     </dependency>
 
     <dependency name="no_coverage">
--- a/src/Makefile	Sat Dec 28 17:32:36 2024 +0100
+++ b/src/Makefile	Sun Dec 29 15:24:20 2024 +0100
@@ -29,23 +29,19 @@
 
 OBJ_EXT=.o
 OBJ=$(SRC:%.c=$(build_dir)/%$(OBJ_EXT))
-GCOV=$(SRC:%.c=%.c.gcov)
 
 static: $(build_dir)/libucx_static$(STLIB_EXT)
 
 shared: $(build_dir)/libucx$(SHLIB_EXT)
 
-check-coverage: $(GCOV)
-	mv *.gcov "$(build_dir)"
+check-coverage: $(SRC:%.c=$(build_dir)/%.gcda)
+	gcovr --html-details $(build_dir)/coverage.html \
+		  --object-directory $(build_dir) \
+		  --root $(root_dir)/src \
+		  --exclude-directories $(build_dir)/tests \
+		  $(build_dir)
 
-%.c.gcov: %.c $(build_dir)/%.gcno
-	@tabs 22
-	@gcov -Ho "$(build_dir)" $< | grep -A1 'File' | grep -v '\--' \
-		| sed 's/File /  /' | sed 's/Lines executed:/\t/' | tr -d '\n'"'" \
-		| sed -E 's/(of [0-9]+)/\1\n/g'
-	@tabs -8
-
-$(build_dir)/%.gcno:
+$(build_dir)/%.gcda:
 	test -f "$@"
 
 $(build_dir)/libucx_static$(STLIB_EXT): $(OBJ)
@@ -60,7 +56,7 @@
 	$(RMFILE) $(libdir)/libucx$(SHLIB_EXT)
 	$(COPYFILE) $(build_dir)/libucx_static$(STLIB_EXT) $(libdir)/libucx_static$(STLIB_EXT)
 	$(COPYFILE) $(build_dir)/libucx$(SHLIB_EXT) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION)
-	$(COPYALL) $(src_dir)/src/cx $(includedir)
+	$(COPYALL) $(root_dir)/src/cx $(includedir)
 	$(SYMLINK) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR)
 	$(SYMLINK) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR) $(libdir)/libucx$(SHLIB_EXT)
 

mercurial