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