+extract_xml_result() {
+ testcase=$1
+ shift 1
+ qpas=$*
+ start="#beginTestCaseResult $testcase"
+
+ # Pick the first QPA mentioning our testcase
+ qpa=`grep -l "$start" $qpas | head -n 1`
+
+ # If we found one, go extract just that testcase's contents from the QPA
+ # to a new QPA, then do testlog-to-xml on that.
+ if [ -n "$qpa" ]; then
+ while IFS= read -r line; do
+ if [ "$line" = "$start" ]; then
+ dst="$testcase.qpa"
+ echo "#beginSession" > $dst
+ echo "$line" >> $dst
+ while IFS= read -r line; do
+ if [ "$line" = "#endTestCaseResult" ]; then
+ echo "$line" >> $dst
+ echo "#endSession" >> $dst
+ /deqp/executor/testlog-to-xml $dst "$RESULTS/$testcase$DEQP_RUN_SUFFIX.xml"
+ # copy the stylesheets here so they only end up in artifacts
+ # if we have one or more result xml in artifacts
+ cp /deqp/testlog.css "$RESULTS/"
+ cp /deqp/testlog.xsl "$RESULTS/"
+ return 0
+ fi
+ echo "$line" >> $dst
+ done
+ return 1
+ fi
+ done < $qpa
+ fi
+}
+
+extract_xml_results() {
+ qpas=$*
+ while IFS= read -r testcase; do
+ testcase=${testcase%,*}
+ extract_xml_result $testcase $qpas
+ done
+}
+
+# Generate junit results
+generate_junit() {
+ results=$1
+ echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ echo "<testsuites>"
+ echo "<testsuite name=\"$DEQP_VER-$CI_NODE_INDEX\">"
+ while read line; do
+ testcase=${line%,*}
+ result=${line#*,}
+ # avoid counting Skip's in the # of tests:
+ if [ "$result" = "Skip" ]; then
+ continue;
+ fi
+ echo "<testcase name=\"$testcase\">"
+ if [ "$result" != "Pass" ]; then
+ echo "<failure type=\"$result\">"
+ echo "$result: See $CI_JOB_URL/artifacts/results/$testcase.xml"
+ echo "</failure>"
+ fi
+ echo "</testcase>"
+ done < $results
+ echo "</testsuite>"
+ echo "</testsuites>"
+}
+
+parse_renderer() {
+ RENDERER=`grep -A1 TestCaseResult.\*info.renderer $RESULTS/deqp-info.qpa | grep '<Text' | sed 's|.*<Text>||g' | sed 's|</Text>||g'`
+ VERSION=`grep -A1 TestCaseResult.\*info.version $RESULTS/deqp-info.qpa | grep '<Text' | sed 's|.*<Text>||g' | sed 's|</Text>||g'`
+ echo "Renderer: $RENDERER"
+ echo "Version: $VERSION "
+
+ if ! echo $RENDERER | grep -q $DEQP_EXPECTED_RENDERER; then
+ echo "Expected GL_RENDERER $DEQP_EXPECTED_RENDERER"
+ exit 1
+ fi
+}
+
+check_renderer() {
+ echo "Capturing renderer info for GLES driver sanity checks"
+ # If you're having trouble loading your driver, uncommenting this may help
+ # debug.
+ # export EGL_LOG_LEVEL=debug
+ VERSION=`echo $DEQP_VER | tr '[a-z]' '[A-Z]'`
+ $DEQP $DEQP_OPTIONS --deqp-case=$SUITE-$VERSION.info.\* --deqp-log-filename=$RESULTS/deqp-info.qpa
+ parse_renderer
+}
+
+check_vk_device_name() {
+ echo "Capturing device info for VK driver sanity checks"
+ $DEQP $DEQP_OPTIONS --deqp-case=dEQP-VK.info.device --deqp-log-filename=$RESULTS/deqp-info.qpa
+ DEVICENAME=`grep deviceName $RESULTS/deqp-info.qpa | sed 's|deviceName: ||g'`
+ echo "deviceName: $DEVICENAME"
+ if [ -n "$DEQP_EXPECTED_RENDERER" -a $DEVICENAME != "$DEQP_EXPECTED_RENDERER" ]; then
+ echo "Expected deviceName $DEQP_EXPECTED_RENDERER"
+ exit 1
+ fi
+}
+