You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ja...@apache.org on 2018/09/07 19:01:36 UTC

svn commit: r1840316 - in /apr/apr/trunk: README build/run-gcov.sh

Author: jailletc36
Date: Fri Sep  7 19:01:36 2018
New Revision: 1840316

URL: http://svn.apache.org/viewvc?rev=1840316&view=rev
Log:
Fix test coverage functionality

Modified:
    apr/apr/trunk/README
    apr/apr/trunk/build/run-gcov.sh

Modified: apr/apr/trunk/README
URL: http://svn.apache.org/viewvc/apr/apr/trunk/README?rev=1840316&r1=1840315&r2=1840316&view=diff
==============================================================================
--- apr/apr/trunk/README (original)
+++ apr/apr/trunk/README Fri Sep  7 19:01:36 2018
@@ -194,7 +194,7 @@ Generating Test Coverage information wit
 If you want to generate test coverage data, use the following steps:
 
   ./buildconf
-  CFLAGS="-fprofile-arcs -ftest-coverage" ./configure
+  CFLAGS="--coverage -fprofile-abs-path" LDFLAGS="--coverage" ./configure
   make
   cd test
   make

Modified: apr/apr/trunk/build/run-gcov.sh
URL: http://svn.apache.org/viewvc/apr/apr/trunk/build/run-gcov.sh?rev=1840316&r1=1840315&r2=1840316&view=diff
==============================================================================
--- apr/apr/trunk/build/run-gcov.sh (original)
+++ apr/apr/trunk/build/run-gcov.sh Fri Sep  7 19:01:36 2018
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 if [ ! -d coverage ]; then
     mkdir coverage
@@ -85,20 +85,48 @@ but all tests should be moving to the un
    <table border="0" width="100%" cellspacing="0">
 EOF
 
-for i in `find .. -name "*.bb" -maxdepth 1 | sort`; do
-    percent=`gcov $i -o .. | grep "%" | awk -F'%' {'print $1'}`
-    name=`echo $i | awk -F'/' {'print $2'}`
-    basename=`echo $name | awk -F'.' {'print $1'}` 
+# Remind current dir, so that we can easily navigate in directories
+pwd=`pwd`
 
+# gcno files are created at compile time and gcna files at run-time
+for i in `find ../.. -name "*.gcno" | sort`; do
+    # Skip test files
+    if [[ "$i" =~ "test" ]]; then
+        continue
+    fi
+
+    # We are only intested in gcno files in .libs directories, because it there
+    # that we'll also find some gcna files
+    if ! [[ "$i" =~ "libs" ]]; then
+        continue
+    fi
+
+    # Find the directory and base name of this gcno file
+    dir=`dirname -- "$i"`
+    basename=`basename "$i"`
+    filename="${basename%.*}"
+    
+    # Go to this directory
+    cd $dir
+
+    # Get the % of test coverage for each of this file
+    percent=`gcov $filename.gcda | grep "%" | awk -F'%' {'print $1'} | awk -F':' {'print $2'}`
+
+    # Come back to our base directory
+    cd $pwd
+
+    # Process the data we have collected
     if [ "x$percent" = "x" ]; then
         echo "<tr>" >> index.html
-        echo "<td bgcolor=#ffffff> Error generating data for $basename<br>" >> index.html
-        continue;	
+        echo "<td bgcolor=#ffffff> Error generating data for <b>$filename</b></td>" >> index.html
+        echo "</tr>" >> index.html
+        continue;
     fi
+
     intpercent=`echo "$percent/1" | bc`
-    if [ $intpercent -lt 33 ]; then
+    if [[ $intpercent -lt 33 ]]; then
         color="#ffaaaa"
-    else if [ $intpercent -lt 66 ]; then
+    else if [[ $intpercent -lt 66 ]]; then
         color="#ffff77"
         else
             color="#aaffaa"
@@ -106,8 +134,9 @@ for i in `find .. -name "*.bb" -maxdepth
     fi
 
     echo "<tr>" >> index.html
-    echo "<td bgcolor=$color><a href=\"$basename.c.gcov\">$basename</a><br>" >> index.html
-    echo "<td bgcolor=$color>$percent% tested"  >> index.html
+    echo "<td bgcolor=$color><a href=\"$dir\\$filename.c.gcov\">$filename</a></td>" >> index.html
+    echo "<td bgcolor=$color><b>$percent%</b> tested</td>"  >> index.html
+    echo "</tr>" >> index.html
 done
 
 echo "</table><p>Last generated `date`</p>" >> index.html