summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorChristophe Jaillet <jailletc36@apache.org>2018-09-07 19:01:36 +0000
committerChristophe Jaillet <jailletc36@apache.org>2018-09-07 19:01:36 +0000
commitd8ac046b21b2993d40d49ef6955f559491058608 (patch)
treea79a49bf9e12b7245f2a97bf9242b9c47f4696a1 /build
parentb372e142adb3ca2f67f432b549c2b5af141ead9d (diff)
downloadapr-d8ac046b21b2993d40d49ef6955f559491058608.tar.gz
Fix test coverage functionality
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1840316 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'build')
-rwxr-xr-xbuild/run-gcov.sh51
1 files changed, 40 insertions, 11 deletions
diff --git a/build/run-gcov.sh b/build/run-gcov.sh
index 98f911fc8..d0e932d4f 100755
--- a/build/run-gcov.sh
+++ b/build/run-gcov.sh
@@ -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 unified framework, so this is correct.</p>
<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 1 | sort`; do
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