test

Committer:
peyo
Date:
Wed Apr 12 14:07:09 2017 +0200
Revision:
0:cd5404401c2f
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
peyo 0:cd5404401c2f 1 #!/bin/bash
peyo 0:cd5404401c2f 2 INPUT_FILE=$1
peyo 0:cd5404401c2f 3 TEMP_FILE1=${INPUT_FILE}1.tmp
peyo 0:cd5404401c2f 4 TEMP_FILE2=${INPUT_FILE}2.tmp
peyo 0:cd5404401c2f 5 TEMP_FILE3=${INPUT_FILE}3.tmp
peyo 0:cd5404401c2f 6 ERROR_FILE=$2
peyo 0:cd5404401c2f 7 OUTPUT_FILE=$3
peyo 0:cd5404401c2f 8 HTML_OUTPUT_FILE=$3.html
peyo 0:cd5404401c2f 9 TEST_RESULTS=$4
peyo 0:cd5404401c2f 10
peyo 0:cd5404401c2f 11 flattenGcovOutput() {
peyo 0:cd5404401c2f 12 while read line1
peyo 0:cd5404401c2f 13 do
peyo 0:cd5404401c2f 14 read line2
peyo 0:cd5404401c2f 15 echo $line2 " " $line1
peyo 0:cd5404401c2f 16 read junk
peyo 0:cd5404401c2f 17 read junk
peyo 0:cd5404401c2f 18 done < ${INPUT_FILE}
peyo 0:cd5404401c2f 19 }
peyo 0:cd5404401c2f 20
peyo 0:cd5404401c2f 21 getRidOfCruft() {
peyo 0:cd5404401c2f 22 sed '-e s/^Lines.*://g' \
peyo 0:cd5404401c2f 23 '-e s/^[0-9]\./ &/g' \
peyo 0:cd5404401c2f 24 '-e s/^[0-9][0-9]\./ &/g' \
peyo 0:cd5404401c2f 25 '-e s/of.*File/ /g' \
peyo 0:cd5404401c2f 26 "-e s/'//g" \
peyo 0:cd5404401c2f 27 '-e s/^.*\/usr\/.*$//g' \
peyo 0:cd5404401c2f 28 '-e s/^.*\.$//g'
peyo 0:cd5404401c2f 29 }
peyo 0:cd5404401c2f 30
peyo 0:cd5404401c2f 31 flattenPaths() {
peyo 0:cd5404401c2f 32 sed \
peyo 0:cd5404401c2f 33 -e 's/\/[^/][^/]*\/[^/][^/]*\/\.\.\/\.\.\//\//g' \
peyo 0:cd5404401c2f 34 -e 's/\/[^/][^/]*\/[^/][^/]*\/\.\.\/\.\.\//\//g' \
peyo 0:cd5404401c2f 35 -e 's/\/[^/][^/]*\/[^/][^/]*\/\.\.\/\.\.\//\//g' \
peyo 0:cd5404401c2f 36 -e 's/\/[^/][^/]*\/\.\.\//\//g'
peyo 0:cd5404401c2f 37 }
peyo 0:cd5404401c2f 38
peyo 0:cd5404401c2f 39 getFileNameRootFromErrorFile() {
peyo 0:cd5404401c2f 40 sed '-e s/gc..:cannot open .* file//g' ${ERROR_FILE}
peyo 0:cd5404401c2f 41 }
peyo 0:cd5404401c2f 42
peyo 0:cd5404401c2f 43 writeEachNoTestCoverageFile() {
peyo 0:cd5404401c2f 44 while read line
peyo 0:cd5404401c2f 45 do
peyo 0:cd5404401c2f 46 echo " 0.00% " ${line}
peyo 0:cd5404401c2f 47 done
peyo 0:cd5404401c2f 48 }
peyo 0:cd5404401c2f 49
peyo 0:cd5404401c2f 50 createHtmlOutput() {
peyo 0:cd5404401c2f 51 echo "<table border="2" cellspacing="5" cellpadding="5">"
peyo 0:cd5404401c2f 52 echo "<tr><th>Coverage</th><th>File</th></tr>"
peyo 0:cd5404401c2f 53 sed "-e s/.*% /<tr><td>&<\/td><td>/" \
peyo 0:cd5404401c2f 54 "-e s/[a-zA-Z0-9_]*\.[ch][a-z]*/<a href='file:\.\/&.gcov'>&<\/a><\/td><\/tr>/"
peyo 0:cd5404401c2f 55 echo "</table>"
peyo 0:cd5404401c2f 56 sed "-e s/.*/&<br>/g" < ${TEST_RESULTS}
peyo 0:cd5404401c2f 57 }
peyo 0:cd5404401c2f 58
peyo 0:cd5404401c2f 59 flattenGcovOutput | getRidOfCruft | flattenPaths > ${TEMP_FILE1}
peyo 0:cd5404401c2f 60 getFileNameRootFromErrorFile | writeEachNoTestCoverageFile | flattenPaths > ${TEMP_FILE2}
peyo 0:cd5404401c2f 61 cat ${TEMP_FILE1} ${TEMP_FILE2} | sort | uniq > ${OUTPUT_FILE}
peyo 0:cd5404401c2f 62 createHtmlOutput < ${OUTPUT_FILE} > ${HTML_OUTPUT_FILE}
peyo 0:cd5404401c2f 63 rm -f ${TEMP_FILE1} ${TEMP_FILE2}