parsegtestreport.sh (1241B)
1 #! /bin/sh 2 # 3 # parse the gtest results file this replaces a sed script which produced 4 # the identical output. This new script is now independent of new unknown 5 # labels being introduced in future revisions of gtests. 6 7 #this function extracts the appropriate value from 8 # <testcase label="value1" label2="value2" label3="value3" /> 9 # which value is selected from the label , which is specified 10 # as the 2nd parameter. The line to parse is the first parameter. 11 getvalue() 12 { 13 pattern1='*'${2}'="' 14 pattern2='"*' 15 front=${1#${pattern1}} 16 if [[ "${front}" != "${1}" ]]; then 17 val=${front%%${pattern2}} 18 # as we output the result, restore any quotes that may have 19 # been in the original test names. 20 echo ${val//"/\"} 21 fi 22 } 23 24 parse() 25 { 26 while read line 27 do 28 if [[ "${line}" =~ "<testcase " ]]; then 29 name=$(getvalue "${line}" "name") 30 value=$(getvalue "${line}" "value_param") 31 stat=$(getvalue "${line}" "status") 32 class=$(getvalue "${line}" "classname") 33 echo "${stat} '${class}: $(echo ${name} ${value})'" 34 fi 35 done 36 } 37 38 # if no arguments, just take standard in, if arguments, take the args as 39 # files and cat them together to parse 40 if [ $# -eq 0 ]; then 41 parse 42 else 43 cat "$@" | parse 44 fi