1#!/bin/sh
2
3set -ex
4
5if [ -z "$GPU_VERSION" ]; then
6   echo 'GPU_VERSION must be set to something like "llvmpipe" or "freedreno-a630" (the name used in .gitlab-ci/gpu-version-*.txt)'
7   exit 1
8fi
9
10INSTALL=`pwd`/install
11
12# Set up the driver environment.
13export LD_LIBRARY_PATH=`pwd`/install/lib/
14export EGL_PLATFORM=surfaceless
15export VK_ICD_FILENAMES=`pwd`/install/share/vulkan/icd.d/"$VK_DRIVER"_icd.${VK_CPU:-`uname -m`}.json
16
17RESULTS=`pwd`/${DEQP_RESULTS_DIR:-results}
18mkdir -p $RESULTS
19
20HANG_DETECTION_CMD=""
21
22if [ -z "$DEQP_SUITE" ]; then
23    if [ -z "$DEQP_VER" ]; then
24        echo 'DEQP_SUITE must be set to the name of your deqp-gpu_version.toml, or DEQP_VER must be set to something like "gles2", "gles31-khr" or "vk" for the test run'
25        exit 1
26    fi
27
28    DEQP_WIDTH=${DEQP_WIDTH:-256}
29    DEQP_HEIGHT=${DEQP_HEIGHT:-256}
30    DEQP_CONFIG=${DEQP_CONFIG:-rgba8888d24s8ms0}
31    DEQP_VARIANT=${DEQP_VARIANT:-master}
32
33    DEQP_OPTIONS="$DEQP_OPTIONS --deqp-surface-width=$DEQP_WIDTH --deqp-surface-height=$DEQP_HEIGHT"
34    DEQP_OPTIONS="$DEQP_OPTIONS --deqp-surface-type=${DEQP_SURFACE_TYPE:-pbuffer}"
35    DEQP_OPTIONS="$DEQP_OPTIONS --deqp-gl-config-name=$DEQP_CONFIG"
36    DEQP_OPTIONS="$DEQP_OPTIONS --deqp-visibility=hidden"
37
38    if [ "$DEQP_VER" = "vk" -a -z "$VK_DRIVER" ]; then
39        echo 'VK_DRIVER must be to something like "radeon" or "intel" for the test run'
40        exit 1
41    fi
42
43    # Generate test case list file.
44    if [ "$DEQP_VER" = "vk" ]; then
45       MUSTPASS=/deqp/mustpass/vk-$DEQP_VARIANT.txt
46       DEQP=/deqp/external/vulkancts/modules/vulkan/deqp-vk
47       HANG_DETECTION_CMD="/parallel-deqp-runner/build/bin/hang-detection"
48    elif [ "$DEQP_VER" = "gles2" -o "$DEQP_VER" = "gles3" -o "$DEQP_VER" = "gles31" -o "$DEQP_VER" = "egl" ]; then
49       MUSTPASS=/deqp/mustpass/$DEQP_VER-$DEQP_VARIANT.txt
50       DEQP=/deqp/modules/$DEQP_VER/deqp-$DEQP_VER
51    elif [ "$DEQP_VER" = "gles2-khr" -o "$DEQP_VER" = "gles3-khr" -o "$DEQP_VER" = "gles31-khr" -o "$DEQP_VER" = "gles32-khr" ]; then
52       MUSTPASS=/deqp/mustpass/$DEQP_VER-$DEQP_VARIANT.txt
53       DEQP=/deqp/external/openglcts/modules/glcts
54    else
55       MUSTPASS=/deqp/mustpass/$DEQP_VER-$DEQP_VARIANT.txt
56       DEQP=/deqp/external/openglcts/modules/glcts
57    fi
58
59    cp $MUSTPASS /tmp/case-list.txt
60
61    # If the caselist is too long to run in a reasonable amount of time, let the job
62    # specify what fraction (1/n) of the caselist we should run.  Note: N~M is a gnu
63    # sed extension to match every nth line (first line is #1).
64    if [ -n "$DEQP_FRACTION" ]; then
65       sed -ni 1~$DEQP_FRACTION"p" /tmp/case-list.txt
66    fi
67
68    # If the job is parallel at the gitab job level, take the corresponding fraction
69    # of the caselist.
70    if [ -n "$CI_NODE_INDEX" ]; then
71       sed -ni $CI_NODE_INDEX~$CI_NODE_TOTAL"p" /tmp/case-list.txt
72    fi
73
74    if [ -n "$DEQP_CASELIST_FILTER" ]; then
75        sed -ni "/$DEQP_CASELIST_FILTER/p" /tmp/case-list.txt
76    fi
77
78    if [ -n "$DEQP_CASELIST_INV_FILTER" ]; then
79        sed -ni "/$DEQP_CASELIST_INV_FILTER/!p" /tmp/case-list.txt
80    fi
81
82    if [ ! -s /tmp/case-list.txt ]; then
83        echo "Caselist generation failed"
84        exit 1
85    fi
86fi
87
88if [ -e "$INSTALL/$GPU_VERSION-fails.txt" ]; then
89    DEQP_RUNNER_OPTIONS="$DEQP_RUNNER_OPTIONS --baseline $INSTALL/$GPU_VERSION-fails.txt"
90fi
91
92# Default to an empty known flakes file if it doesn't exist.
93touch $INSTALL/$GPU_VERSION-flakes.txt
94
95
96if [ -n "$VK_DRIVER" ] && [ -e "$INSTALL/$VK_DRIVER-skips.txt" ]; then
97    DEQP_SKIPS="$DEQP_SKIPS $INSTALL/$VK_DRIVER-skips.txt"
98fi
99
100if [ -n "$GALLIUM_DRIVER" ] && [ -e "$INSTALL/$GALLIUM_DRIVER-skips.txt" ]; then
101    DEQP_SKIPS="$DEQP_SKIPS $INSTALL/$GALLIUM_DRIVER-skips.txt"
102fi
103
104if [ -n "$DRIVER_NAME" ] && [ -e "$INSTALL/$DRIVER_NAME-skips.txt" ]; then
105    DEQP_SKIPS="$DEQP_SKIPS $INSTALL/$DRIVER_NAME-skips.txt"
106fi
107
108if [ -e "$INSTALL/$GPU_VERSION-skips.txt" ]; then
109    DEQP_SKIPS="$DEQP_SKIPS $INSTALL/$GPU_VERSION-skips.txt"
110fi
111
112set +e
113
114report_load() {
115    echo "System load: $(cut -d' ' -f1-3 < /proc/loadavg)"
116    echo "# of CPU cores: $(cat /proc/cpuinfo | grep processor | wc -l)"
117}
118
119# wrapper to supress +x to avoid spamming the log
120quiet() {
121    set +x
122    "$@"
123    set -x
124}
125
126if [ "$GALLIUM_DRIVER" = "virpipe" ]; then
127    # deqp is to use virpipe, and virgl_test_server llvmpipe
128    export GALLIUM_DRIVER="$GALLIUM_DRIVER"
129
130    VTEST_ARGS="--use-egl-surfaceless"
131    if [ "$VIRGL_HOST_API" = "GLES" ]; then
132        VTEST_ARGS="$VTEST_ARGS --use-gles"
133    fi
134
135    GALLIUM_DRIVER=llvmpipe \
136    GALLIVM_PERF="nopt" \
137    virgl_test_server $VTEST_ARGS >$RESULTS/vtest-log.txt 2>&1 &
138
139    sleep 1
140fi
141
142if [ -z "$DEQP_SUITE" ]; then
143    if [ -n "$DEQP_EXPECTED_RENDERER" ]; then
144        export DEQP_RUNNER_OPTIONS="$DEQP_RUNNER_OPTIONS --renderer-check "$DEQP_EXPECTED_RENDERER""
145    fi
146    if [ $DEQP_VER != vk -a $DEQP_VER != egl ]; then
147        export DEQP_RUNNER_OPTIONS="$DEQP_RUNNER_OPTIONS --version-check `cat $INSTALL/VERSION | sed 's/[() ]/./g'`"
148    fi
149
150    deqp-runner \
151        run \
152        --deqp $DEQP \
153        --output $RESULTS \
154        --caselist /tmp/case-list.txt \
155        --skips $INSTALL/all-skips.txt $DEQP_SKIPS \
156        --flakes $INSTALL/$GPU_VERSION-flakes.txt \
157        --testlog-to-xml /deqp/executor/testlog-to-xml \
158        --jobs ${FDO_CI_CONCURRENT:-4} \
159	$DEQP_RUNNER_OPTIONS \
160        -- \
161        $DEQP_OPTIONS
162else
163    deqp-runner \
164        suite \
165        --suite $INSTALL/deqp-$DEQP_SUITE.toml \
166        --output $RESULTS \
167        --skips $INSTALL/all-skips.txt $DEQP_SKIPS \
168        --flakes $INSTALL/$GPU_VERSION-flakes.txt \
169        --testlog-to-xml /deqp/executor/testlog-to-xml \
170        --fraction-start $CI_NODE_INDEX \
171        --fraction $CI_NODE_TOTAL \
172        --jobs ${FDO_CI_CONCURRENT:-4} \
173	$DEQP_RUNNER_OPTIONS
174fi
175
176DEQP_EXITCODE=$?
177
178quiet report_load
179
180# Remove all but the first 50 individual XML files uploaded as artifacts, to
181# save fd.o space when you break everything.
182find $RESULTS -name \*.xml | \
183    sort -n |
184    sed -n '1,+49!p' | \
185    xargs rm -f
186
187# If any QPA XMLs are there, then include the XSL/CSS in our artifacts.
188find $RESULTS -name \*.xml \
189    -exec cp /deqp/testlog.css /deqp/testlog.xsl "$RESULTS/" ";" \
190    -quit
191
192deqp-runner junit \
193   --testsuite dEQP \
194   --results $RESULTS/failures.csv \
195   --output $RESULTS/junit.xml \
196   --limit 50 \
197   --template "See https://$CI_PROJECT_ROOT_NAMESPACE.pages.freedesktop.org/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/results/{{testcase}}.xml"
198
199# Report the flakes to the IRC channel for monitoring (if configured):
200if [ -n "$FLAKES_CHANNEL" ]; then
201  python3 $INSTALL/report-flakes.py \
202         --host irc.oftc.net \
203         --port 6667 \
204         --results $RESULTS/results.csv \
205         --known-flakes $INSTALL/$GPU_VERSION-flakes.txt \
206         --channel "$FLAKES_CHANNEL" \
207         --runner "$CI_RUNNER_DESCRIPTION" \
208         --job "$CI_JOB_ID" \
209         --url "$CI_JOB_URL" \
210         --branch "${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-$CI_COMMIT_BRANCH}" \
211         --branch-title "${CI_MERGE_REQUEST_TITLE:-$CI_COMMIT_TITLE}"
212fi
213
214exit $DEQP_EXITCODE
215