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