+if [ -n "$DEQP_PARALLEL" ]; then
+ JOB="--job $DEQP_PARALLEL"
+fi
+
+run_cts() {
+ deqp=$1
+ caselist=$2
+ output=$3
+ deqp-runner \
+ --deqp $deqp \
+ --output $output \
+ --caselist $caselist \
+ --exclude-list $INSTALL/$DEQP_SKIPS \
+ $XFAIL \
+ $JOB \
+ --allow-flakes true \
+ $DEQP_RUNNER_OPTIONS \
+ -- \
+ $DEQP_OPTIONS
+}
+
+report_flakes() {
+ if [ -z "$FLAKES_CHANNEL" ]; then
+ return 0
+ fi
+ flakes=$1
+ bot="$CI_RUNNER_DESCRIPTION-$CI_PIPELINE_ID"
+ channel="$FLAKES_CHANNEL"
+ (
+ echo NICK $bot
+ echo USER $bot unused unused :Gitlab CI Notifier
+ sleep 10
+ echo "JOIN $channel"
+ sleep 1
+ desc="Flakes detected in job: $CI_JOB_URL on $CI_RUNNER_DESCRIPTION"
+ if [ -n "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]; then
+ desc="$desc on branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME ($CI_MERGE_REQUEST_TITLE)"
+ fi
+ echo "PRIVMSG $channel :$desc"
+ for flake in `cat $flakes`; do
+ echo "PRIVMSG $channel :$flake"
+ done
+ echo "PRIVMSG $channel :See $CI_JOB_URL/artifacts/browse/results/"
+ echo "QUIT"
+ ) | nc irc.freenode.net 6667 > /dev/null
+
+}
+
+extract_xml_result() {
+ testcase=$1
+ shift 1
+ qpas=$*
+ start="#beginTestCaseResult $testcase"
+ for qpa in $qpas; do
+ 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.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
+ done
+}
+
+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 "
+}
+
+check_renderer() {
+ echo "Capturing renderer info for driver sanity checks"
+ # If you're having trouble loading your driver, uncommenting this may help
+ # debug.
+ # export EGL_LOG_LEVEL=debug
+ $DEQP $DEQP_OPTIONS --deqp-case=dEQP-GLES2.info.\* --deqp-log-filename=$RESULTS/deqp-info.qpa
+ parse_renderer
+}
+
+# wrapper to supress +x to avoid spamming the log
+quiet() {
+ set +x
+ "$@"
+ set -x
+}
+
+if [ $DEQP_VER != vk ]; then
+ quiet check_renderer
+fi
+
+run_cts $DEQP /tmp/case-list.txt $RESULTS/cts-runner-results.txt