File: filterGcov.sh

package info (click to toggle)
cpputest 4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,688 kB
  • sloc: cpp: 31,212; sh: 4,978; ansic: 1,360; makefile: 775; ruby: 676; xml: 8; sed: 1
file content (63 lines) | stat: -rwxr-xr-x 1,567 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
INPUT_FILE=$1
TEMP_FILE1=${INPUT_FILE}1.tmp
TEMP_FILE2=${INPUT_FILE}2.tmp
TEMP_FILE3=${INPUT_FILE}3.tmp
ERROR_FILE=$2
OUTPUT_FILE=$3
HTML_OUTPUT_FILE=$3.html
TEST_RESULTS=$4

flattenGcovOutput() {
while read line1
do
  read line2
  echo $line2 " " $line1 
  read junk
  read junk
done < ${INPUT_FILE}
}

getRidOfCruft() {
sed '-e s/^Lines.*://g' \
    '-e s/^[0-9]\./  &/g' \
    '-e s/^[0-9][0-9]\./ &/g' \
    '-e s/of.*File/ /g' \
    "-e s/'//g" \
    '-e s/^.*\/usr\/.*$//g' \
    '-e s/^.*\.$//g' 
}

flattenPaths() {
sed \
    -e 's/\/[^/][^/]*\/[^/][^/]*\/\.\.\/\.\.\//\//g' \
    -e 's/\/[^/][^/]*\/[^/][^/]*\/\.\.\/\.\.\//\//g' \
    -e 's/\/[^/][^/]*\/[^/][^/]*\/\.\.\/\.\.\//\//g' \
    -e 's/\/[^/][^/]*\/\.\.\//\//g'
}

getFileNameRootFromErrorFile() {
sed '-e s/gc..:cannot open .* file//g' ${ERROR_FILE}
}

writeEachNoTestCoverageFile() {
while read line
do
  echo "  0.00%  " ${line}
done 
}

createHtmlOutput() {
    echo "<table border="2" cellspacing="5" cellpadding="5">"
    echo "<tr><th>Coverage</th><th>File</th></tr>"
    sed "-e s/.*%   /<tr><td>&<\/td><td>/" \
        "-e s/[a-zA-Z0-9_]*\.[ch][a-z]*/<a href='file:\.\/&.gcov'>&<\/a><\/td><\/tr>/" 
    echo "</table>"
    sed "-e s/.*/&<br>/g" < ${TEST_RESULTS}
}

flattenGcovOutput | getRidOfCruft | flattenPaths  > ${TEMP_FILE1}
getFileNameRootFromErrorFile | writeEachNoTestCoverageFile | flattenPaths > ${TEMP_FILE2}
cat ${TEMP_FILE1}  ${TEMP_FILE2} | sort | uniq > ${OUTPUT_FILE}
createHtmlOutput < ${OUTPUT_FILE} > ${HTML_OUTPUT_FILE}
rm -f ${TEMP_FILE1} ${TEMP_FILE2}