ci: Disable shader cache on vulkan CI runs.
[mesa.git] / .gitlab-ci / deqp-runner.sh
1 #!/bin/sh
2
3 set -ex
4
5 DEQP_OPTIONS="$DEQP_OPTIONS --deqp-surface-width=256 --deqp-surface-height=256"
6 DEQP_OPTIONS="$DEQP_OPTIONS --deqp-surface-type=pbuffer"
7 DEQP_OPTIONS="$DEQP_OPTIONS --deqp-gl-config-name=rgba8888d24s8ms0"
8 DEQP_OPTIONS="$DEQP_OPTIONS --deqp-visibility=hidden"
9
10 # deqp's shader cache (for vulkan) is not multiprocess safe for a common
11 # filename, see:
12 # https://gitlab.freedesktop.org/mesa/parallel-deqp-runner/-/merge_requests/13
13 DEQP_OPTIONS="$DEQP_OPTIONS --deqp-shadercache=disable"
14
15 if [ -z "$DEQP_VER" ]; then
16 echo 'DEQP_VER must be set to something like "gles2", "gles31" or "vk" for the test run'
17 exit 1
18 fi
19
20 if [ "$DEQP_VER" = "vk" ]; then
21 if [ -z "$VK_DRIVER" ]; then
22 echo 'VK_DRIVER must be to something like "radeon" or "intel" for the test run'
23 exit 1
24 fi
25 fi
26
27 if [ -z "$DEQP_SKIPS" ]; then
28 echo 'DEQP_SKIPS must be set to something like "deqp-default-skips.txt"'
29 exit 1
30 fi
31
32 INSTALL=`pwd`/install
33
34 # Set up the driver environment.
35 export LD_LIBRARY_PATH=`pwd`/install/lib/
36 export EGL_PLATFORM=surfaceless
37 export VK_ICD_FILENAMES=`pwd`/install/share/vulkan/icd.d/"$VK_DRIVER"_icd.`uname -m`.json
38
39 # the runner was failing to look for libkms in /usr/local/lib for some reason
40 # I never figured out.
41 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
42
43 RESULTS=`pwd`/results
44 mkdir -p $RESULTS
45
46 # Generate test case list file.
47 if [ "$DEQP_VER" = "vk" ]; then
48 cp /deqp/mustpass/vk-master.txt /tmp/case-list.txt
49 DEQP=/deqp/external/vulkancts/modules/vulkan/deqp-vk
50 else
51 cp /deqp/mustpass/$DEQP_VER-master.txt /tmp/case-list.txt
52 DEQP=/deqp/modules/$DEQP_VER/deqp-$DEQP_VER
53 fi
54
55 # If the job is parallel, take the corresponding fraction of the caselist.
56 # Note: N~M is a gnu sed extension to match every nth line (first line is #1).
57 if [ -n "$CI_NODE_INDEX" ]; then
58 sed -ni $CI_NODE_INDEX~$CI_NODE_TOTAL"p" /tmp/case-list.txt
59 fi
60
61 if [ -n "$DEQP_CASELIST_FILTER" ]; then
62 sed -ni "/$DEQP_CASELIST_FILTER/p" /tmp/case-list.txt
63 fi
64
65 if [ ! -s /tmp/case-list.txt ]; then
66 echo "Caselist generation failed"
67 exit 1
68 fi
69
70 if [ -n "$DEQP_EXPECTED_FAILS" ]; then
71 XFAIL="--xfail-list $INSTALL/$DEQP_EXPECTED_FAILS"
72 fi
73
74 set +e
75
76 if [ -n "$DEQP_PARALLEL" ]; then
77 JOB="--job $DEQP_PARALLEL"
78 fi
79
80 run_cts() {
81 deqp=$1
82 caselist=$2
83 output=$3
84 deqp-runner \
85 --deqp $deqp \
86 --output $output \
87 --caselist $caselist \
88 --exclude-list $INSTALL/$DEQP_SKIPS \
89 --compact-display false \
90 $XFAIL \
91 $JOB \
92 --allow-flakes true \
93 $DEQP_RUNNER_OPTIONS \
94 -- \
95 $DEQP_OPTIONS
96 }
97
98 report_flakes() {
99 if [ -z "$FLAKES_CHANNEL" ]; then
100 return 0
101 fi
102 flakes=$1
103 # The nick needs to be something unique so that multiple runners
104 # connecting at the same time don't race for one nick and get blocked.
105 # freenode has a 16-char limit on nicks (9 is the IETF standard, but
106 # various servers extend that). So, trim off the common prefixes of the
107 # runner name, and append the job ID so that software runners with more
108 # than one concurrent job (think swrast) don't collide. For freedreno,
109 # that gives us a nick as long as db410c-N-JJJJJJJJ, and it'll be a while
110 # before we make it to 9-digit jobs (we're at 7 so far).
111 runner=`echo $CI_RUNNER_DESCRIPTION | sed 's|mesa-||' | sed 's|google-freedreno-||g'`
112 bot="$runner-$CI_JOB_ID"
113 channel="$FLAKES_CHANNEL"
114 (
115 echo NICK $bot
116 echo USER $bot unused unused :Gitlab CI Notifier
117 sleep 10
118 echo "JOIN $channel"
119 sleep 1
120 desc="Flakes detected in job: $CI_JOB_URL on $CI_RUNNER_DESCRIPTION"
121 if [ -n "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]; then
122 desc="$desc on branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME ($CI_MERGE_REQUEST_TITLE)"
123 elif [ -n "$CI_COMMIT_BRANCH" ]; then
124 desc="$desc on branch $CI_COMMIT_BRANCH ($CI_COMMIT_TITLE)"
125 fi
126 echo "PRIVMSG $channel :$desc"
127 for flake in `cat $flakes`; do
128 echo "PRIVMSG $channel :$flake"
129 done
130 echo "PRIVMSG $channel :See $CI_JOB_URL/artifacts/browse/results/"
131 echo "QUIT"
132 ) | nc irc.freenode.net 6667 > /dev/null
133
134 }
135
136 extract_xml_result() {
137 testcase=$1
138 shift 1
139 qpas=$*
140 start="#beginTestCaseResult $testcase"
141
142 # Pick the first QPA mentioning our testcase
143 qpa=`grep -l "$start" $qpas | head -n 1`
144
145 # If we found one, go extract just that testcase's contents from the QPA
146 # to a new QPA, then do testlog-to-xml on that.
147 if [ -n "$qpa" ]; then
148 while IFS= read -r line; do
149 if [ "$line" = "$start" ]; then
150 dst="$testcase.qpa"
151 echo "#beginSession" > $dst
152 echo $line >> $dst
153 while IFS= read -r line; do
154 if [ "$line" = "#endTestCaseResult" ]; then
155 echo $line >> $dst
156 echo "#endSession" >> $dst
157 /deqp/executor/testlog-to-xml $dst "$RESULTS/$testcase$DEQP_RUN_SUFFIX.xml"
158 # copy the stylesheets here so they only end up in artifacts
159 # if we have one or more result xml in artifacts
160 cp /deqp/testlog.css "$RESULTS/"
161 cp /deqp/testlog.xsl "$RESULTS/"
162 return 0
163 fi
164 echo $line >> $dst
165 done
166 return 1
167 fi
168 done < $qpa
169 fi
170 }
171
172 extract_xml_results() {
173 qpas=$*
174 while IFS= read -r testcase; do
175 testcase=${testcase%,*}
176 extract_xml_result $testcase $qpas
177 done
178 }
179
180 # Generate junit results
181 generate_junit() {
182 results=$1
183 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
184 echo "<testsuites>"
185 echo "<testsuite name=\"$DEQP_VER-$CI_NODE_INDEX\">"
186 while read line; do
187 testcase=${line%,*}
188 result=${line#*,}
189 # avoid counting Skip's in the # of tests:
190 if [ "$result" = "Skip" ]; then
191 continue;
192 fi
193 echo "<testcase name=\"$testcase\">"
194 if [ "$result" != "Pass" ]; then
195 echo "<failure type=\"$result\">"
196 echo "$result: See $CI_JOB_URL/artifacts/results/$testcase.xml"
197 echo "</failure>"
198 fi
199 echo "</testcase>"
200 done < $results
201 echo "</testsuite>"
202 echo "</testsuites>"
203 }
204
205 parse_renderer() {
206 RENDERER=`grep -A1 TestCaseResult.\*info.renderer $RESULTS/deqp-info.qpa | grep '<Text' | sed 's|.*<Text>||g' | sed 's|</Text>||g'`
207 VERSION=`grep -A1 TestCaseResult.\*info.version $RESULTS/deqp-info.qpa | grep '<Text' | sed 's|.*<Text>||g' | sed 's|</Text>||g'`
208 echo "Renderer: $RENDERER"
209 echo "Version: $VERSION "
210
211 if ! echo $RENDERER | grep -q $DEQP_EXPECTED_RENDERER; then
212 echo "Expected GL_RENDERER $DEQP_EXPECTED_RENDERER"
213 exit 1
214 fi
215 }
216
217 check_renderer() {
218 echo "Capturing renderer info for GLES driver sanity checks"
219 # If you're having trouble loading your driver, uncommenting this may help
220 # debug.
221 # export EGL_LOG_LEVEL=debug
222 VERSION=`echo $DEQP_VER | tr '[a-z]' '[A-Z]'`
223 $DEQP $DEQP_OPTIONS --deqp-case=dEQP-$VERSION.info.\* --deqp-log-filename=$RESULTS/deqp-info.qpa
224 parse_renderer
225 }
226
227 check_vk_device_name() {
228 echo "Capturing device info for VK driver sanity checks"
229 $DEQP $DEQP_OPTIONS --deqp-case=dEQP-VK.info.device --deqp-log-filename=$RESULTS/deqp-info.qpa
230 DEVICENAME=`grep deviceName $RESULTS/deqp-info.qpa | sed 's|deviceName: ||g'`
231 echo "deviceName: $DEVICENAME"
232 if [ -n "$DEQP_EXPECTED_RENDERER" -a $DEVICENAME != "$DEQP_EXPECTED_RENDERER" ]; then
233 echo "Expected deviceName $DEQP_EXPECTED_RENDERER"
234 exit 1
235 fi
236 }
237
238 # wrapper to supress +x to avoid spamming the log
239 quiet() {
240 set +x
241 "$@"
242 set -x
243 }
244
245 if [ "$GALLIUM_DRIVER" = "virpipe" ]; then
246 # deqp is to use virpipe, and virgl_test_server llvmpipe
247 export GALLIUM_DRIVER="$GALLIUM_DRIVER"
248
249 GALLIUM_DRIVER=llvmpipe \
250 GALLIVM_PERF="nopt,no_filter_hacks" \
251 VTEST_USE_EGL_SURFACELESS=1 \
252 VTEST_USE_GLES=1 \
253 virgl_test_server >$RESULTS/vtest-log.txt 2>&1 &
254
255 sleep 1
256 fi
257
258 if [ $DEQP_VER = vk ]; then
259 quiet check_vk_device_name
260 else
261 quiet check_renderer
262 fi
263
264 RESULTSFILE=$RESULTS/cts-runner-results$DEQP_RUN_SUFFIX.txt
265 UNEXPECTED_RESULTSFILE=$RESULTS/cts-runner-unexpected-results$DEQP_RUN_SUFFIX.txt
266 FLAKESFILE=$RESULTS/cts-runner-flakes$DEQP_RUN_SUFFIX.txt
267
268 run_cts $DEQP /tmp/case-list.txt $RESULTSFILE
269 DEQP_EXITCODE=$?
270
271 # junit is disabled, because it overloads gitlab.freedesktop.org to parse it.
272 #quiet generate_junit $RESULTSFILE > $RESULTS/results.xml
273
274 if [ $DEQP_EXITCODE -ne 0 ]; then
275 # preserve caselist files in case of failures:
276 cp /tmp/deqp_runner.*.txt $RESULTS/
277 egrep -v ",Pass|,Skip|,ExpectedFail" $RESULTSFILE > $UNEXPECTED_RESULTSFILE
278
279 if [ -z "$DEQP_NO_SAVE_RESULTS" ]; then
280 echo "Some unexpected results found (see cts-runner-results.txt in artifacts for full results):"
281 head -n 50 $UNEXPECTED_RESULTSFILE
282
283 # Save the logs for up to the first 50 unexpected results:
284 head -n 50 $UNEXPECTED_RESULTSFILE | quiet extract_xml_results /tmp/*.qpa
285 else
286 echo "Unexpected results found:"
287 cat $UNEXPECTED_RESULTSFILE
288 fi
289
290 count=`cat $UNEXPECTED_RESULTSFILE | wc -l`
291
292 # Re-run fails to detect flakes. But use a small threshold, if
293 # something was fundamentally broken, we don't want to re-run
294 # the entire caselist
295 else
296 grep ",Flake" $RESULTSFILE > $FLAKESFILE
297
298 count=`cat $FLAKESFILE | wc -l`
299 if [ $count -gt 0 ]; then
300 echo "Some flakes found (see cts-runner-flakes.txt in artifacts for full results):"
301 head -n 50 $FLAKESFILE
302
303 if [ -z "$DEQP_NO_SAVE_RESULTS" ]; then
304 # Save the logs for up to the first 50 flakes:
305 head -n 50 $FLAKESFILE | quiet extract_xml_results /tmp/*.qpa
306 fi
307
308 # Report the flakes to IRC channel for monitoring (if configured):
309 quiet report_flakes $FLAKESFILE
310 else
311 # no flakes, so clean-up:
312 rm $FLAKESFILE
313 fi
314 fi
315
316 exit $DEQP_EXITCODE