mesa: remove redundant _mesa_prim::is_indexed
[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 ARTIFACTS=`pwd`/artifacts
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 $ARTIFACTS/$DEQP_EXPECTED_FAILS"
70 fi
71
72 set +e
73
74 run_cts() {
75 deqp=$1
76 caselist=$2
77 output=$3
78 deqp-runner \
79 --deqp $deqp \
80 --output $output \
81 --caselist $caselist \
82 --exclude-list $ARTIFACTS/$DEQP_SKIPS \
83 $XFAIL \
84 --job ${DEQP_PARALLEL:-1} \
85 --allow-flakes true \
86 $DEQP_RUNNER_OPTIONS \
87 -- \
88 $DEQP_OPTIONS
89 }
90
91 report_flakes() {
92 if [ -z "$FLAKES_CHANNEL" ]; then
93 return 0
94 fi
95 flakes=$1
96 bot="$CI_RUNNER_DESCRIPTION-$CI_PIPELINE_ID"
97 channel="$FLAKES_CHANNEL"
98 (
99 echo NICK $bot
100 echo USER $bot unused unused :Gitlab CI Notifier
101 sleep 10
102 echo "JOIN $channel"
103 sleep 1
104 desc="Flakes detected in job: $CI_JOB_URL on $CI_RUNNER_DESCRIPTION"
105 if [ -n "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]; then
106 desc="$desc on branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME ($CI_MERGE_REQUEST_TITLE)"
107 fi
108 echo "PRIVMSG $channel :$desc"
109 for flake in `cat $flakes`; do
110 echo "PRIVMSG $channel :$flake"
111 done
112 echo "PRIVMSG $channel :See $CI_JOB_URL/artifacts/browse/results/"
113 echo "QUIT"
114 ) | nc irc.freenode.net 6667 > /dev/null
115
116 }
117
118 extract_xml_result() {
119 testcase=$1
120 shift 1
121 qpas=$*
122 start="#beginTestCaseResult $testcase"
123 for qpa in $qpas; do
124 while IFS= read -r line; do
125 if [ "$line" = "$start" ]; then
126 dst="$testcase.qpa"
127 echo "#beginSession" > $dst
128 echo $line >> $dst
129 while IFS= read -r line; do
130 if [ "$line" = "#endTestCaseResult" ]; then
131 echo $line >> $dst
132 echo "#endSession" >> $dst
133 /deqp/executor/testlog-to-xml $dst "$RESULTS/$testcase.xml"
134 # copy the stylesheets here so they only end up in artifacts
135 # if we have one or more result xml in artifacts
136 cp /deqp/testlog.css "$RESULTS/"
137 cp /deqp/testlog.xsl "$RESULTS/"
138 return 0
139 fi
140 echo $line >> $dst
141 done
142 return 1
143 fi
144 done < $qpa
145 done
146 }
147
148 extract_xml_results() {
149 qpas=$*
150 while IFS= read -r testcase; do
151 testcase=${testcase%,*}
152 extract_xml_result $testcase $qpas
153 done
154 }
155
156 # Generate junit results
157 generate_junit() {
158 results=$1
159 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
160 echo "<testsuites>"
161 echo "<testsuite name=\"$DEQP_VER-$CI_NODE_INDEX\">"
162 while read line; do
163 testcase=${line%,*}
164 result=${line#*,}
165 # avoid counting Skip's in the # of tests:
166 if [ "$result" = "Skip" ]; then
167 continue;
168 fi
169 echo "<testcase name=\"$testcase\">"
170 if [ "$result" != "Pass" ]; then
171 echo "<failure type=\"$result\">"
172 echo "$result: See $CI_JOB_URL/artifacts/results/$testcase.xml"
173 echo "</failure>"
174 fi
175 echo "</testcase>"
176 done < $results
177 echo "</testsuite>"
178 echo "</testsuites>"
179 }
180
181 # wrapper to supress +x to avoid spamming the log
182 quiet() {
183 set +x
184 "$@"
185 set -x
186 }
187
188 run_cts $DEQP /tmp/case-list.txt $RESULTS/cts-runner-results.txt
189 DEQP_EXITCODE=$?
190
191 # junit is disabled, because it overloads gitlab.freedesktop.org to parse it.
192 #quiet generate_junit $RESULTS/cts-runner-results.txt > $RESULTS/results.xml
193
194 if [ $DEQP_EXITCODE -ne 0 ]; then
195 # preserve caselist files in case of failures:
196 cp /tmp/deqp_runner.*.txt $RESULTS/
197 cat $RESULTS/cts-runner-results.txt | \
198 grep -v ",Pass" | \
199 grep -v ",Skip" | \
200 grep -v ",ExpectedFail" > \
201 $RESULTS/cts-runner-unexpected-results.txt
202
203 if [ -z "$DEQP_NO_SAVE_RESULTS" ]; then
204 echo "Some unexpected results found (see cts-runner-results.txt in artifacts for full results):"
205 head -n 50 $RESULTS/cts-runner-unexpected-results.txt
206
207 # Save the logs for up to the first 50 unexpected results:
208 head -n 50 $RESULTS/cts-runner-unexpected-results.txt | quiet extract_xml_results /tmp/*.qpa
209 else
210 echo "Unexpected results found:"
211 cat $RESULTS/cts-runner-unexpected-results.txt
212 fi
213
214 count=`cat $RESULTS/cts-runner-unexpected-results.txt | wc -l`
215
216 # Re-run fails to detect flakes. But use a small threshold, if
217 # something was fundamentally broken, we don't want to re-run
218 # the entire caselist
219 else
220 cat $RESULTS/cts-runner-results.txt | \
221 grep ",Flake" > \
222 $RESULTS/cts-runner-flakes.txt
223
224 count=`cat $RESULTS/cts-runner-flakes.txt | wc -l`
225 if [ $count -gt 0 ]; then
226 echo "Some flakes found (see cts-runner-flakes.txt in artifacts for full results):"
227 head -n 50 $RESULTS/cts-runner-flakes.txt
228
229 if [ -z "$DEQP_NO_SAVE_RESULTS" ]; then
230 # Save the logs for up to the first 50 flakes:
231 head -n 50 $RESULTS/cts-runner-flakes.txt | quiet extract_xml_results /tmp/*.qpa
232 fi
233
234 # Report the flakes to IRC channel for monitoring (if configured):
235 quiet report_flakes $RESULTS/cts-runner-flakes.txt
236 else
237 # no flakes, so clean-up:
238 rm $RESULTS/cts-runner-flakes.txt
239 fi
240 fi
241
242 exit $DEQP_EXITCODE