summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/common/init.sh66
-rw-r--r--tests/common/parsegtestreport.sed6
-rw-r--r--tests/common/parsegtestreport.sh44
-rwxr-xr-xtests/gtests/gtests.sh12
-rwxr-xr-xtests/ssl_gtests/ssl_gtests.sh52
5 files changed, 117 insertions, 63 deletions
diff --git a/tests/common/init.sh b/tests/common/init.sh
index 658023d83..8c10bdd2a 100644
--- a/tests/common/init.sh
+++ b/tests/common/init.sh
@@ -253,6 +253,72 @@ if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
HTML_UNKNOWN='</TD><TD>Unknown</TD><TR>'
TABLE_ARGS=
+ gtest_parse_report_helper()
+ {
+ # Check XML reports for normal test runs and failures.
+ local successes=$(gtest_parse_report_xpath "//testcase[@status='run'][count(*)=0]" "$@" )
+ local failures=$(gtest_parse_report_xpath "//failure/.." "$@" )
+
+ # Print all tests that succeeded.
+ while read result name; do
+ html_passed_ignore_core "$name"
+ done <<< "$successes"
+
+ # Print failing tests.
+ if [ -n "$failures" ]; then
+ printf "\nFAILURES:\n=========\n"
+
+ while read result name; do
+ html_failed_ignore_core "$name"
+ done <<< "$failures"
+
+ printf "\n"
+ fi
+ }
+
+ # This legacy report parser can't actually detect failures. It always relied
+ # on the binary's exit code. Print the tests we ran to keep the old behavior.
+ gtest_parse_report_legacy()
+ {
+ while read result name && [ -n "$name" ]; do
+ if [ "$result" = "notrun" ]; then
+ echo "$name" SKIPPED
+ elif [ "$result" = "run" ]; then
+ html_passed_ignore_core "$name"
+ else
+ html_failed_ignore_core "$name"
+ fi
+ done <<< "$(sed -f "${COMMON}/parsegtestreport.sed" "$@" )"
+ # here's how we would use bash if it wasn't so slow
+ # done <<< "$(sh "${COMMON}/parsegtestreport.sh" "$@" )"
+ }
+
+ gtest_parse_report_xpath()
+ {
+ # Query the XML report with the given XPath pattern.
+ xpath="$1"
+ shift
+ xmllint --xpath "${xpath}" "$@" 2>/dev/null | \
+ # Insert newlines to help sed.
+ sed $'s/<testcase/\\\n<testcase/g' | \
+ # Use sed to parse the report.
+ sed -f "${COMMON}/parsegtestreport.sed"
+ # here's how we would use bash if it wasn't so slow
+ #sh "${COMMON}/parsegtestreport.sh"
+ }
+
+ gtest_parse_report()
+ {
+ if type xmllint &>/dev/null; then
+ echo "DEBUG: Using xmllint to parse GTest XML report(s)"
+ gtest_parse_report_helper "$@"
+ else
+ echo "DEBUG: Falling back to legacy XML report parsing using only sed"
+ gtest_parse_report_legacy "$@"
+ fi
+ }
+
+
#directory name init
SCRIPTNAME=init.sh
diff --git a/tests/common/parsegtestreport.sed b/tests/common/parsegtestreport.sed
index 11bd1d6af..4b6226248 100644
--- a/tests/common/parsegtestreport.sed
+++ b/tests/common/parsegtestreport.sed
@@ -1,8 +1,12 @@
/\<testcase/{
- s/^.* name="\([^"]*\)" value_param="\([^"]*\)" status="\([^"]*\)" time="[^"]*" classname="\([^"]*\)".*$/\3 '\4: \1 \2'/
+ s/^.* name="\([^"]*\)" value_param="\([^"]*\)" status="\([^"]*\)" time="[^"]*" classname="\([^"]*\).*$/\3 '\4: \1 \2'/
t end
s/^.* name="\([^"]*\)" status="\([^"]*\)" time="[^"]*" classname="\([^"]*\)".*$/\2 '\3: \1'/
t end
+ s/^.* name="\([^"]*\)" value_param="\([^"]*\)" status="\([^"]*\)" result="[^"]*" time="[^"]*" timestamp="[^"]*" classname="\([^"]*\)".*$/\3 '\4: \1 \2'/
+ t end
+ s/^.* name="\([^"]*\)" status="\([^"]*\)" result="[^"]*" time="[^"]*" timestamp="[^"]*" classname="\([^"]*\)".*$/\2 '\3: \1'/
+ t end
}
d
: end
diff --git a/tests/common/parsegtestreport.sh b/tests/common/parsegtestreport.sh
new file mode 100644
index 000000000..f0a879a42
--- /dev/null
+++ b/tests/common/parsegtestreport.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+#
+# parse the gtest results file this replaces a sed script which produced
+# the identical output. This new script is now independent of new unknown
+# labels being introduced in future revisions of gtests.
+
+#this function extracts the appropriate value from
+# <testcase label="value1" label2="value2" label3="value3" />
+# which value is selected from the label , which is specified
+# as the 2nd parameter. The line to parse is the first parameter.
+getvalue()
+{
+ pattern1='*'${2}'="'
+ pattern2='"*'
+ front=${1#${pattern1}}
+ if [[ "${front}" != "${1}" ]]; then
+ val=${front%%${pattern2}}
+ # as we output the result, restore any quotes that may have
+ # been in the original test names.
+ echo ${val//&quot;/\"}
+ fi
+}
+
+parse()
+{
+ while read line
+ do
+ if [[ "${line}" =~ "<testcase " ]]; then
+ name=$(getvalue "${line}" "name")
+ value=$(getvalue "${line}" "value_param")
+ stat=$(getvalue "${line}" "status")
+ class=$(getvalue "${line}" "classname")
+ echo "${stat} '${class}: $(echo ${name} ${value})'"
+ fi
+ done
+}
+
+# if no arguments, just take standard in, if arguments, take the args as
+# files and cat them together to parse
+if [ $# -eq 0 ]; then
+ parse
+else
+ cat "$@" | parse
+fi
diff --git a/tests/gtests/gtests.sh b/tests/gtests/gtests.sh
index 4005a16a6..8c6047736 100755
--- a/tests/gtests/gtests.sh
+++ b/tests/gtests/gtests.sh
@@ -86,18 +86,8 @@ gtest_start()
fi
echo "test output dir: ${GTESTREPORT}"
- echo "executing sed to parse the xml report"
- sed -f "${COMMON}/parsegtestreport.sed" "$GTESTREPORT" > "$PARSED_REPORT"
echo "processing the parsed report"
- cat "$PARSED_REPORT" | while read result name; do
- if [ "$result" = "notrun" ]; then
- echo "$name" SKIPPED
- elif [ "$result" = "run" ]; then
- html_passed_ignore_core "$name"
- else
- html_failed_ignore_core "$name"
- fi
- done
+ gtest_parse_report ${GTESTREPORT}
popd
done
}
diff --git a/tests/ssl_gtests/ssl_gtests.sh b/tests/ssl_gtests/ssl_gtests.sh
index 1783ef436..d2e8c7a4f 100755
--- a/tests/ssl_gtests/ssl_gtests.sh
+++ b/tests/ssl_gtests/ssl_gtests.sh
@@ -133,13 +133,7 @@ ssl_gtest_start()
html_msg $? 0 "ssl_gtests ran successfully"
# Parse XML report(s).
- if type xmllint &>/dev/null; then
- echo "DEBUG: Using xmllint to parse GTest XML report(s)"
- parse_report
- else
- echo "DEBUG: Falling back to legacy XML report parsing using only sed"
- parse_report_legacy
- fi
+ gtest_parse_report "${SSLGTESTREPORT}".*
}
# Helper function used when 'parallel' isn't available.
@@ -148,50 +142,6 @@ parallel_fallback()
eval "${@//\{\}/0}"
}
-parse_report()
-{
- # Check XML reports for normal test runs and failures.
- local successes=$(parse_report_xpath "//testcase[@status='run'][count(*)=0]")
- local failures=$(parse_report_xpath "//failure/..")
-
- # Print all tests that succeeded.
- while read result name; do
- html_passed_ignore_core "$name"
- done <<< "$successes"
-
- # Print failing tests.
- if [ -n "$failures" ]; then
- printf "\nFAILURES:\n=========\n"
-
- while read result name; do
- html_failed_ignore_core "$name"
- done <<< "$failures"
-
- printf "\n"
- fi
-}
-
-parse_report_xpath()
-{
- # Query the XML report with the given XPath pattern.
- xmllint --xpath "$1" "${SSLGTESTREPORT}".* 2>/dev/null | \
- # Insert newlines to help sed.
- sed $'s/<testcase/\\\n<testcase/g' | \
- # Use sed to parse the report.
- sed -f "${COMMON}/parsegtestreport.sed"
-}
-
-# This legacy report parser can't actually detect failures. It always relied
-# on the binary's exit code. Print the tests we ran to keep the old behavior.
-parse_report_legacy()
-{
- while read result name && [ -n "$name" ]; do
- if [ "$result" = "run" ]; then
- html_passed_ignore_core "$name"
- fi
- done <<< "$(sed -f "${COMMON}/parsegtestreport.sed" "${SSLGTESTREPORT}".*)"
-}
-
ssl_gtest_cleanup()
{
cd ${QADIR}