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