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