Skip to content

Commit 1d01e0e

Browse files
committed
Update script to generate coverage report:
- Read $1 as the path to a APR Site wc - Generate a partial file, included by the index.html file - Use CSS classes from r1928438 * build/run-gcov.sh As above git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1928439 13f79535-47bb-0310-9956-ffa450edef68
1 parent c75d7ea commit 1d01e0e

1 file changed

Lines changed: 29 additions & 121 deletions

File tree

build/run-gcov.sh

Lines changed: 29 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,24 @@
11
#!/bin/bash
22

3-
if [ ! -d coverage ]; then
4-
mkdir coverage
3+
if [ -n "$1" ]; then
4+
P=$1/docs/coverage/
5+
else
6+
P=./coverage/
57
fi
6-
cd coverage
78

8-
# It would be really nice to find a better way to do this than copying the
9-
# HTML into this script. But, I am being lazy right now.
10-
cat > index.html << EOF
11-
<!-- This is a generated file, do not edit -->
12-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
13-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
14-
<html>
15-
<head>
16-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
17-
<meta name="author" content="APR Developers" /><meta name="email" content="dev@apr.apache.org" />
18-
<title>Test Coverage</title>
19-
</head>
20-
<body bgcolor="#ffffff" text="#000000" link="#525D76">
21-
<p><a href="/"><img src="./images/apr_logo_wide.png" alt="The Apache Portable Runtime Project" border="0"/></a></p>
22-
<table border="0" width="100%" cellspacing="4">
23-
<tr>
24-
<!-- LEFT SIDE NAVIGATION -->
25-
<td valign="top" nowrap="nowrap">
26-
<a href="http://apachecon.com/"
27-
><img src="http://www.apache.org/images/ac2003-150.gif" height="86"
28-
width="150" border="0" alt="ApacheCon" /></a>
29-
<p><b>Get Involved</b></p>
30-
<menu compact="compact">
31-
<li><a href="/anoncvs.txt">CVS</a></li>
32-
<li><a href="/mailing-lists.html">Mailing Lists</a></li>
33-
<li><a href="http://cvs.apache.org/snapshots/apr/">Snapshots</a></li>
34-
<li><a href="/compiling_win32.html">Build on Win32</a></li>
35-
<li><a href="/compiling_unix.html">Build on Unix</a></li>
36-
</menu>
37-
<p><b>Download!</b></p>
38-
<menu compact="compact">
39-
<li><a href="http://www.apache.org/dyn/closer.cgi/apr/">from a mirror</a></li>
40-
</menu>
41-
<p><b>Docs</b></p>
42-
<menu compact="compact">
43-
<li><a href="/docs/apr/">APR</a></li>
44-
<li><a href="/docs/apr-util/">APR-util</a></li>
45-
<li>APR-iconv</li>
46-
</menu>
47-
<p><b>Guidelines</b></p>
48-
<menu compact="compact">
49-
<li><a href="/guidelines.html">Project Guidelines</a></li>
50-
<li><a href="/patches.html">Contributing</a></li>
51-
<li><a href="/versioning.html">Version Numbers</a></li>
52-
</menu>
53-
<p><b><a href="/info/">Miscellaneous</a></b></p>
54-
<menu compact="compact">
55-
<li><a href="http://www.apache.org/LICENSE.txt">License</a></li>
56-
<li><a href="/projects.html">Projects using APR</a></li>
57-
</menu>
58-
</td>
59-
<!-- RIGHT SIDE INFORMATION -->
60-
<td align="left" valign="top">
61-
<table border="0" cellspacing="0" cellpadding="2" width="100%">
62-
<tr><td bgcolor="#525D76">
63-
<font color="#ffffff" face="arial,helvetica,sanserif">
64-
<strong>APR Test Coverage</strong>
65-
</font>
66-
</td></tr>
67-
<tr><td>
68-
<blockquote>
69-
<p>This should give us some idea of how well our tests actually stress our
70-
code. To generate this data, do the following:</p>
71-
<menu compact="compact">
72-
<li>./buildconf</li>
73-
<li>CFLAGS="-fprofile-arcs -ftest-coverage ./configure</li>
74-
<li>make</li>
75-
<li>cd test</li>
76-
<li>make</li>
77-
<li>./testall</li>
78-
<li>cd ..</li>
79-
<li>make gcov</li>
80-
</menu>
81-
<p>Note that this will only generate test coverage data for the testall script,
82-
but all tests should be moving to the unified framework, so this is correct.</p>
83-
</blockquote>
9+
if [ ! -d $P ]; then
10+
mkdir $P
11+
fi
12+
F=$P/coverage.part.html
8413

85-
<table border="0" width="100%" cellspacing="0">
14+
# Generate the coverage.part.html file that is included in the actual
15+
# webpage by SSI.
16+
cat > $F << EOF
17+
<table border="0" width="100%" cellspacing="0">
8618
EOF
8719

88-
# Remind current dir, so that we can easily navigate in directories
89-
pwd=`pwd`
90-
9120
# gcno files are created at compile time and gcna files at run-time
92-
for i in `find ../.. -name "*.gcno" | sort`; do
21+
for i in `find . -name "*.gcno" | sort`; do
9322
# Skip test files
9423
if [[ "$i" =~ "test" ]]; then
9524
continue
@@ -101,59 +30,38 @@ for i in `find ../.. -name "*.gcno" | sort`; do
10130
continue
10231
fi
10332

33+
echo $i
10434
# Find the directory and base name of this gcno file
105-
dir=`dirname -- "$i"`
10635
basename=`basename "$i"`
107-
filename="${basename%.*}"
108-
109-
# Go to this directory
110-
cd $dir
36+
filename="${i%.*}"
11137

11238
# Get the % of test coverage for each of this file
113-
percent=`gcov $filename.gcda | grep "%" | awk -F'%' {'print $1'} | awk -F':' {'print $2'}`
114-
115-
# Come back to our base directory
116-
cd $pwd
39+
percent=`gcov $filename.gcda | grep "%" | head -1 | awk -F'%' {'print $1'} | awk -F':' {'print $2'}`
40+
cp ${basename%.*}.c.gcov $P
11741

11842
# Process the data we have collected
11943
if [ "x$percent" = "x" ]; then
120-
echo "<tr>" >> index.html
121-
echo "<td bgcolor=#ffffff> Error generating data for <b>$filename</b></td>" >> index.html
122-
echo "</tr>" >> index.html
44+
echo "<tr class=\"covError\">" >> $F
45+
echo "<td> Error generating data for <b>$basename</b></td>" >> $F
46+
echo -n "</tr>" >> $F
12347
continue;
12448
fi
12549

12650
intpercent=`echo "$percent/1" | bc`
12751
if [[ $intpercent -lt 33 ]]; then
128-
color="#ffaaaa"
52+
class="covLT33"
12953
else if [[ $intpercent -lt 66 ]]; then
130-
color="#ffff77"
54+
class="covLT66"
13155
else
132-
color="#aaffaa"
56+
class="covGE66"
13357
fi
13458
fi
13559

136-
echo "<tr>" >> index.html
137-
echo "<td bgcolor=$color><a href=\"$dir\\$filename.c.gcov\">$filename</a></td>" >> index.html
138-
echo "<td bgcolor=$color><b>$percent%</b> tested</td>" >> index.html
139-
echo "</tr>" >> index.html
60+
echo "<tr class=\"$class\">" >> $F
61+
echo "<td><a href=\"${basename%.*}.c.gcov\">$basename</a></td>" >> $F
62+
echo "<td>$percent% tested</td>" >> $F
63+
echo -n "</tr>" >> $F
14064
done
14165

142-
echo "</table><p>Last generated `date`</p>" >> index.html
143-
144-
cat >> index.html << EOF
145-
</td></tr>
146-
</table>
147-
<!-- FOOTER -->
148-
<tr><td colspan="2"><hr noshade="noshade" size="1"/></td></tr>
149-
<tr><td colspan="2" align="center">
150-
<font size="-1">
151-
<em>Copyright &#169; 1999-2004, The Apache Software Foundation</em>
152-
</font>
153-
</td>
154-
</tr>
155-
</table>
156-
</body>
157-
</html>
158-
159-
EOF
66+
echo -e "\n</table>\n<p>Last generated `date`</p>" >> $F
67+
echo "Coverage updated, see $P"

0 commit comments

Comments
 (0)