gitlab-ci: allow to run dEQP Vulkan with DEQP_VER
[mesa.git] / .gitlab-ci / deqp-runner.sh
1 #!/bin/bash
2
3 set -ex
4
5 DEQP_OPTIONS=(--deqp-surface-width=256 --deqp-surface-height=256)
6 DEQP_OPTIONS+=(--deqp-surface-type=pbuffer)
7 DEQP_OPTIONS+=(--deqp-gl-config-name=rgba8888d24s8ms0)
8 DEQP_OPTIONS+=(--deqp-visibility=hidden)
9
10 # It would be nice to be able to enable the watchdog, so that hangs in a test
11 # don't need to wait the full hour for the run to time out. However, some
12 # shaders end up taking long enough to compile
13 # (dEQP-GLES31.functional.ubo.random.all_per_block_buffers.20 for example)
14 # that they'll sporadically trigger the watchdog.
15 #DEQP_OPTIONS+=(--deqp-watchdog=enable)
16
17 if [ -z "$DEQP_VER" ]; then
18 echo 'DEQP_VER must be set to something like "gles2", "gles31" or "vk" for the test run'
19 exit 1
20 fi
21
22 if [ -z "$DEQP_SKIPS" ]; then
23 echo 'DEQP_SKIPS must be set to something like "deqp-default-skips.txt"'
24 exit 1
25 fi
26
27 ARTIFACTS=`pwd`/artifacts
28
29 # Set up the driver environment.
30 export LD_LIBRARY_PATH=`pwd`/install/lib/
31 export EGL_PLATFORM=surfaceless
32
33 # the runner was failing to look for libkms in /usr/local/lib for some reason
34 # I never figured out.
35 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
36
37 RESULTS=`pwd`/results
38 mkdir -p $RESULTS
39
40 # Generate test case list file.
41 if [ "$DEQP_VER" == "vk" ]; then
42 cp /deqp/mustpass/vk-master.txt /tmp/case-list.txt
43 DEQP=/deqp/external/vulkancts/modules/vulkan/deqp-vk
44 else
45 cp /deqp/mustpass/$DEQP_VER-master.txt /tmp/case-list.txt
46 DEQP=/deqp/modules/$DEQP_VER/deqp-$DEQP_VER
47 fi
48
49 # If the job is parallel, take the corresponding fraction of the caselist.
50 # Note: N~M is a gnu sed extension to match every nth line (first line is #1).
51 if [ -n "$CI_NODE_INDEX" ]; then
52 sed -ni $CI_NODE_INDEX~$CI_NODE_TOTAL"p" /tmp/case-list.txt
53 fi
54
55 if [ ! -s /tmp/case-list.txt ]; then
56 echo "Caselist generation failed"
57 exit 1
58 fi
59
60 if [ -n "$DEQP_EXPECTED_FAILS" ]; then
61 XFAIL="--xfail-list $ARTIFACTS/$DEQP_EXPECTED_FAILS"
62 fi
63
64 set +e
65
66 run_cts() {
67 deqp=$1
68 caselist=$2
69 output=$3
70 deqp-runner \
71 --deqp $deqp \
72 --output $output \
73 --caselist $caselist \
74 --exclude-list $ARTIFACTS/$DEQP_SKIPS \
75 $XFAIL \
76 --job ${DEQP_PARALLEL:-1} \
77 --allow-flakes true \
78 -- \
79 "${DEQP_OPTIONS[@]}"
80 }
81
82 report_flakes() {
83 if [ -z "$FLAKES_CHANNEL" ]; then
84 return 0
85 fi
86 flakes=$1
87 bot="$CI_RUNNER_DESCRIPTION-$CI_PIPELINE_ID"
88 channel="$FLAKES_CHANNEL"
89 (
90 echo NICK $bot
91 echo USER $bot unused unused :Gitlab CI Notifier
92 sleep 10
93 echo "JOIN $channel"
94 sleep 1
95 desc="Flakes detected in job: $CI_JOB_URL on $CI_RUNNER_DESCRIPTION"
96 if [ -n "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]; then
97 desc="$desc on branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME ($CI_MERGE_REQUEST_TITLE)"
98 fi
99 echo "PRIVMSG $channel :$desc"
100 for flake in `cat $flakes`; do
101 echo "PRIVMSG $channel :$flake"
102 done
103 echo "PRIVMSG $channel :See $CI_JOB_URL/artifacts/browse/results/"
104 echo "QUIT"
105 ) | nc irc.freenode.net 6667 > /dev/null
106
107 }
108
109 extract_xml_result() {
110 testcase=$1
111 shift 1
112 qpas=$*
113 start="#beginTestCaseResult $testcase"
114 for qpa in $qpas; do
115 while IFS= read -r line; do
116 if [ "$line" = "$start" ]; then
117 dst="$testcase.qpa"
118 echo "#beginSession" > $dst
119 echo $line >> $dst
120 while IFS= read -r line; do
121 if [ "$line" = "#endTestCaseResult" ]; then
122 echo $line >> $dst
123 echo "#endSession" >> $dst
124 /deqp/executor/testlog-to-xml $dst "$RESULTS/$testcase.xml"
125 # copy the stylesheets here so they only end up in artifacts
126 # if we have one or more result xml in artifacts
127 cp /deqp/testlog.{css,xsl} "$RESULTS/"
128 return 0
129 fi
130 echo $line >> $dst
131 done
132 return 1
133 fi
134 done < $qpa
135 done
136 }
137
138 extract_xml_results() {
139 qpas=$*
140 while IFS= read -r testcase; do
141 testcase=${testcase%,*}
142 extract_xml_result $testcase $qpas
143 done
144 }
145
146 # Generate junit results
147 generate_junit() {
148 results=$1
149 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
150 echo "<testsuites>"
151 echo "<testsuite name=\"$DEQP_VER-$CI_NODE_INDEX\">"
152 while read line; do
153 testcase=${line%,*}
154 result=${line#*,}
155 # avoid counting Skip's in the # of tests:
156 if [ "$result" = "Skip" ]; then
157 continue;
158 fi
159 echo "<testcase name=\"$testcase\">"
160 if [ "$result" != "Pass" ]; then
161 echo "<failure type=\"$result\">"
162 echo "$result: See $CI_JOB_URL/artifacts/results/$testcase.xml"
163 echo "</failure>"
164 fi
165 echo "</testcase>"
166 done < $results
167 echo "</testsuite>"
168 echo "</testsuites>"
169 }
170
171 # wrapper to supress +x to avoid spamming the log
172 quiet() {
173 set +x
174 "$@"
175 set -x
176 }
177
178 run_cts $DEQP /tmp/case-list.txt $RESULTS/cts-runner-results.txt
179 DEQP_EXITCODE=$?
180
181 quiet generate_junit $RESULTS/cts-runner-results.txt > $RESULTS/results.xml
182
183 if [ $DEQP_EXITCODE -ne 0 ]; then
184 # preserve caselist files in case of failures:
185 cp /tmp/cts_runner.*.txt $RESULTS/
186 echo "Some unexpected results found (see cts-runner-results.txt in artifacts for full results):"
187 cat $RESULTS/cts-runner-results.txt | \
188 grep -v ",Pass" | \
189 grep -v ",Skip" | \
190 grep -v ",ExpectedFail" > \
191 $RESULTS/cts-runner-unexpected-results.txt
192 head -n 50 $RESULTS/cts-runner-unexpected-results.txt
193
194 # Save the logs for up to the first 50 unexpected results:
195 head -n 50 $RESULTS/cts-runner-unexpected-results.txt | quiet extract_xml_results /tmp/*.qpa
196
197 count=`cat $RESULTS/cts-runner-unexpected-results.txt | wc -l`
198
199 # Re-run fails to detect flakes. But use a small threshold, if
200 # something was fundamentally broken, we don't want to re-run
201 # the entire caselist
202 else
203 cat $RESULTS/cts-runner-results.txt | \
204 grep ",Flake" > \
205 $RESULTS/cts-runner-flakes.txt
206
207 count=`cat $RESULTS/cts-runner-flakes.txt | wc -l`
208 if [ $count -gt 0 ]; then
209 echo "Some flakes found (see cts-runner-flakes.txt in artifacts for full results):"
210 head -n 50 $RESULTS/cts-runner-flakes.txt
211
212 # Save the logs for up to the first 50 flakes:
213 head -n 50 $RESULTS/cts-runner-flakes.txt | quiet extract_xml_results /tmp/*.qpa
214
215 # Report the flakes to IRC channel for monitoring (if configured):
216 quiet report_flakes $RESULTS/cts-runner-flakes.txt
217 else
218 # no flakes, so clean-up:
219 rm $RESULTS/cts-runner-flakes.txt
220 fi
221 fi
222
223 exit $DEQP_EXITCODE