drm-shim: Let the driver choose to overwrite the first render node.
[mesa.git] / .gitlab-ci / deqp-runner.sh
1 #!/bin/sh
2
3 set -ex
4
5 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 [ ! -s /tmp/case-list.txt ]; then
64 echo "Caselist generation failed"
65 exit 1
66 fi
67
68 if [ -n "$DEQP_EXPECTED_FAILS" ]; then
69 XFAIL="--xfail-list $INSTALL/$DEQP_EXPECTED_FAILS"
70 fi
71
72 set +e
73
74 if [ -n "$DEQP_PARALLEL" ]; then
75 JOB="--job $DEQP_PARALLEL"
76 fi
77
78 run_cts() {
79 deqp=$1
80 caselist=$2
81 output=$3
82 deqp-runner \
83 --deqp $deqp \
84 --output $output \
85 --caselist $caselist \
86 --exclude-list $INSTALL/$DEQP_SKIPS \
87 $XFAIL \
88 $JOB \
89 --allow-flakes true \
90 $DEQP_RUNNER_OPTIONS \
91 -- \
92 $DEQP_OPTIONS
93 }
94
95 report_flakes() {
96 if [ -z "$FLAKES_CHANNEL" ]; then
97 return 0
98 fi
99 flakes=$1
100 bot="$CI_RUNNER_DESCRIPTION-$CI_PIPELINE_ID"
101 channel="$FLAKES_CHANNEL"
102 (
103 echo NICK $bot
104 echo USER $bot unused unused :Gitlab CI Notifier
105 sleep 10
106 echo "JOIN $channel"
107 sleep 1
108 desc="Flakes detected in job: $CI_JOB_URL on $CI_RUNNER_DESCRIPTION"
109 if [ -n "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]; then
110 desc="$desc on branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME ($CI_MERGE_REQUEST_TITLE)"
111 fi
112 echo "PRIVMSG $channel :$desc"
113 for flake in `cat $flakes`; do
114 echo "PRIVMSG $channel :$flake"
115 done
116 echo "PRIVMSG $channel :See $CI_JOB_URL/artifacts/browse/results/"
117 echo "QUIT"
118 ) | nc irc.freenode.net 6667 > /dev/null
119
120 }
121
122 extract_xml_result() {
123 testcase=$1
124 shift 1
125 qpas=$*
126 start="#beginTestCaseResult $testcase"
127 for qpa in $qpas; do
128 while IFS= read -r line; do
129 if [ "$line" = "$start" ]; then
130 dst="$testcase.qpa"
131 echo "#beginSession" > $dst
132 echo $line >> $dst
133 while IFS= read -r line; do
134 if [ "$line" = "#endTestCaseResult" ]; then
135 echo $line >> $dst
136 echo "#endSession" >> $dst
137 /deqp/executor/testlog-to-xml $dst "$RESULTS/$testcase.xml"
138 # copy the stylesheets here so they only end up in artifacts
139 # if we have one or more result xml in artifacts
140 cp /deqp/testlog.css "$RESULTS/"
141 cp /deqp/testlog.xsl "$RESULTS/"
142 return 0
143 fi
144 echo $line >> $dst
145 done
146 return 1
147 fi
148 done < $qpa
149 done
150 }
151
152 extract_xml_results() {
153 qpas=$*
154 while IFS= read -r testcase; do
155 testcase=${testcase%,*}
156 extract_xml_result $testcase $qpas
157 done
158 }
159
160 # Generate junit results
161 generate_junit() {
162 results=$1
163 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
164 echo "<testsuites>"
165 echo "<testsuite name=\"$DEQP_VER-$CI_NODE_INDEX\">"
166 while read line; do
167 testcase=${line%,*}
168 result=${line#*,}
169 # avoid counting Skip's in the # of tests:
170 if [ "$result" = "Skip" ]; then
171 continue;
172 fi
173 echo "<testcase name=\"$testcase\">"
174 if [ "$result" != "Pass" ]; then
175 echo "<failure type=\"$result\">"
176 echo "$result: See $CI_JOB_URL/artifacts/results/$testcase.xml"
177 echo "</failure>"
178 fi
179 echo "</testcase>"
180 done < $results
181 echo "</testsuite>"
182 echo "</testsuites>"
183 }
184
185 parse_renderer() {
186 RENDERER=`grep -A1 TestCaseResult.\*info.renderer $RESULTS/deqp-info.qpa | grep '<Text' | sed 's|.*<Text>||g' | sed 's|</Text>||g'`
187 VERSION=`grep -A1 TestCaseResult.\*info.version $RESULTS/deqp-info.qpa | grep '<Text' | sed 's|.*<Text>||g' | sed 's|</Text>||g'`
188 echo "Renderer: $RENDERER"
189 echo "Version: $VERSION "
190 }
191
192 check_renderer() {
193 echo "Capturing renderer info for driver sanity checks"
194 # If you're having trouble loading your driver, uncommenting this may help
195 # debug.
196 # export EGL_LOG_LEVEL=debug
197 VERSION=`echo $DEQP_VER | tr '[a-z]' '[A-Z]'`
198 $DEQP $DEQP_OPTIONS --deqp-case=dEQP-$VERSION.info.\* --deqp-log-filename=$RESULTS/deqp-info.qpa
199 parse_renderer
200 }
201
202 # wrapper to supress +x to avoid spamming the log
203 quiet() {
204 set +x
205 "$@"
206 set -x
207 }
208
209 if [ "$GALLIUM_DRIVER" = "virpipe" ]; then
210 # deqp is to use virpipe, and virgl_test_server llvmpipe
211 export GALLIUM_DRIVER="$GALLIUM_DRIVER"
212
213 GALLIUM_DRIVER=llvmpipe \
214 GALLIVM_PERF="nopt,no_filter_hacks" \
215 VTEST_USE_EGL_SURFACELESS=1 \
216 VTEST_USE_GLES=1 \
217 virgl_test_server >$RESULTS/vtest-log.txt 2>&1 &
218
219 sleep 1
220 fi
221
222 if [ $DEQP_VER != vk ]; then
223 quiet check_renderer
224 fi
225
226 run_cts $DEQP /tmp/case-list.txt $RESULTS/cts-runner-results.txt
227 DEQP_EXITCODE=$?
228
229 # junit is disabled, because it overloads gitlab.freedesktop.org to parse it.
230 #quiet generate_junit $RESULTS/cts-runner-results.txt > $RESULTS/results.xml
231
232 if [ $DEQP_EXITCODE -ne 0 ]; then
233 # preserve caselist files in case of failures:
234 cp /tmp/deqp_runner.*.txt $RESULTS/
235 cat $RESULTS/cts-runner-results.txt | \
236 grep -v ",Pass" | \
237 grep -v ",Skip" | \
238 grep -v ",ExpectedFail" > \
239 $RESULTS/cts-runner-unexpected-results.txt
240
241 if [ -z "$DEQP_NO_SAVE_RESULTS" ]; then
242 echo "Some unexpected results found (see cts-runner-results.txt in artifacts for full results):"
243 head -n 50 $RESULTS/cts-runner-unexpected-results.txt
244
245 # Save the logs for up to the first 50 unexpected results:
246 head -n 50 $RESULTS/cts-runner-unexpected-results.txt | quiet extract_xml_results /tmp/*.qpa
247 else
248 echo "Unexpected results found:"
249 cat $RESULTS/cts-runner-unexpected-results.txt
250 fi
251
252 count=`cat $RESULTS/cts-runner-unexpected-results.txt | wc -l`
253
254 # Re-run fails to detect flakes. But use a small threshold, if
255 # something was fundamentally broken, we don't want to re-run
256 # the entire caselist
257 else
258 cat $RESULTS/cts-runner-results.txt | \
259 grep ",Flake" > \
260 $RESULTS/cts-runner-flakes.txt
261
262 count=`cat $RESULTS/cts-runner-flakes.txt | wc -l`
263 if [ $count -gt 0 ]; then
264 echo "Some flakes found (see cts-runner-flakes.txt in artifacts for full results):"
265 head -n 50 $RESULTS/cts-runner-flakes.txt
266
267 if [ -z "$DEQP_NO_SAVE_RESULTS" ]; then
268 # Save the logs for up to the first 50 flakes:
269 head -n 50 $RESULTS/cts-runner-flakes.txt | quiet extract_xml_results /tmp/*.qpa
270 fi
271
272 # Report the flakes to IRC channel for monitoring (if configured):
273 quiet report_flakes $RESULTS/cts-runner-flakes.txt
274 else
275 # no flakes, so clean-up:
276 rm $RESULTS/cts-runner-flakes.txt
277 fi
278 fi
279
280 exit $DEQP_EXITCODE