• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3set -ex
4
5INSTALL=$(realpath -s "$PWD"/install)
6MINIO_ARGS="--token-file ${CI_JOB_JWT_FILE}"
7
8RESULTS=$(realpath -s "$PWD"/results)
9mkdir -p "$RESULTS"
10
11# Set up the driver environment.
12# Modifiying here directly LD_LIBRARY_PATH may cause problems when
13# using a command wrapper. Hence, we will just set it when running the
14# command.
15export __LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$INSTALL/lib/"
16export VK_ICD_FILENAMES="$INSTALL/share/vulkan/icd.d/${VK_DRIVER}_icd.${VK_CPU:-`uname -m`}.json"
17
18# Sanity check to ensure that our environment is sufficient to make our tests
19# run against the Mesa built by CI, rather than any installed distro version.
20MESA_VERSION=$(head -1 "$INSTALL/VERSION" | sed 's/\./\\./g')
21
22print_red() {
23    RED='\033[0;31m'
24    NC='\033[0m' # No Color
25    printf "${RED}"
26    "$@"
27    printf "${NC}"
28}
29
30# wrapper to supress +x to avoid spamming the log
31quiet() {
32    set +x
33    "$@"
34    set -x
35}
36
37# Set environment for apitrace executable.
38export PATH="/apitrace/build:$PATH"
39
40# Our rootfs may not have "less", which apitrace uses during
41# apitrace dump
42export PAGER=cat
43
44SANITY_MESA_VERSION_CMD="wflinfo"
45
46HANG_DETECTION_CMD=""
47
48
49# Set up the platform windowing system.
50
51if [ "x$EGL_PLATFORM" = "xsurfaceless" ]; then
52    # Use the surfaceless EGL platform.
53    export DISPLAY=
54    export WAFFLE_PLATFORM="surfaceless_egl"
55
56    SANITY_MESA_VERSION_CMD="$SANITY_MESA_VERSION_CMD --platform surfaceless_egl --api gles2"
57
58    if [ "x$GALLIUM_DRIVER" = "xvirpipe" ]; then
59    # piglit is to use virpipe, and virgl_test_server llvmpipe
60    export GALLIUM_DRIVER="$GALLIUM_DRIVER"
61
62    LD_LIBRARY_PATH="$__LD_LIBRARY_PATH" \
63    GALLIUM_DRIVER=llvmpipe \
64    VTEST_USE_EGL_SURFACELESS=1 \
65    VTEST_USE_GLES=1 \
66    virgl_test_server >"$RESULTS"/vtest-log.txt 2>&1 &
67
68    sleep 1
69    fi
70elif [ "x$PIGLIT_PLATFORM" = "xgbm" ]; then
71    SANITY_MESA_VERSION_CMD="$SANITY_MESA_VERSION_CMD --platform gbm --api gl"
72elif [ "x$PIGLIT_PLATFORM" = "xmixed_glx_egl" ]; then
73    # It is assumed that you have already brought up your X server before
74    # calling this script.
75    SANITY_MESA_VERSION_CMD="$SANITY_MESA_VERSION_CMD --platform glx --api gl"
76else
77    SANITY_MESA_VERSION_CMD="$SANITY_MESA_VERSION_CMD --platform glx --api gl --profile core"
78    RUN_CMD_WRAPPER="xvfb-run --server-args=\"-noreset\" sh -c"
79fi
80
81# If the job is parallel at the  gitlab job level, will take the corresponding
82# fraction of the caselist.
83if [ -n "$CI_NODE_INDEX" ]; then
84    USE_CASELIST=1
85fi
86
87replay_minio_upload_images() {
88    find "$RESULTS/$__PREFIX" -type f -name "*.png" -printf "%P\n" \
89        | while read -r line; do
90
91        __TRACE="${line%-*-*}"
92        if grep -q "^$__PREFIX/$__TRACE: pass$" ".gitlab-ci/piglit/$PIGLIT_RESULTS.txt.orig"; then
93            if [ "x$CI_PROJECT_PATH" != "x$FDO_UPSTREAM_REPO" ]; then
94                continue
95            fi
96            __MINIO_PATH="$PIGLIT_REPLAY_REFERENCE_IMAGES_BASE"
97            __DESTINATION_FILE_PATH="${line##*-}"
98            if wget -q --method=HEAD "https://${__MINIO_PATH}/${__DESTINATION_FILE_PATH}" 2>/dev/null; then
99                continue
100            fi
101        else
102            __MINIO_PATH="$JOB_ARTIFACTS_BASE"
103            __DESTINATION_FILE_PATH="$__MINIO_TRACES_PREFIX/${line##*-}"
104        fi
105
106        ci-fairy s3cp $MINIO_ARGS "$RESULTS/$__PREFIX/$line" \
107            "https://${__MINIO_PATH}/${__DESTINATION_FILE_PATH}"
108    done
109}
110
111SANITY_MESA_VERSION_CMD="$SANITY_MESA_VERSION_CMD | tee /tmp/version.txt | grep \"Mesa $MESA_VERSION\(\s\|$\)\""
112
113if [ -d results ]; then
114    cd results && rm -rf ..?* .[!.]* *
115fi
116cd /piglit
117
118if [ -n "$USE_CASELIST" ]; then
119    PIGLIT_TESTS=$(printf "%s" "$PIGLIT_TESTS")
120    PIGLIT_GENTESTS="./piglit print-cmd $PIGLIT_TESTS replay --format \"{name}\" > /tmp/case-list.txt"
121    RUN_GENTESTS="export LD_LIBRARY_PATH=$__LD_LIBRARY_PATH; $PIGLIT_GENTESTS"
122
123    eval $RUN_GENTESTS
124
125    sed -ni $CI_NODE_INDEX~$CI_NODE_TOTAL"p" /tmp/case-list.txt
126
127    PIGLIT_TESTS="--test-list /tmp/case-list.txt"
128fi
129
130PIGLIT_OPTIONS=$(printf "%s" "$PIGLIT_OPTIONS")
131
132PIGLIT_TESTS=$(printf "%s" "$PIGLIT_TESTS")
133
134PIGLIT_CMD="./piglit run -l verbose --timeout 300 -j${FDO_CI_CONCURRENT:-4} $PIGLIT_OPTIONS $PIGLIT_TESTS replay "$(/usr/bin/printf "%q" "$RESULTS")
135
136RUN_CMD="export LD_LIBRARY_PATH=$__LD_LIBRARY_PATH; $SANITY_MESA_VERSION_CMD && $HANG_DETECTION_CMD $PIGLIT_CMD"
137
138if [ "$RUN_CMD_WRAPPER" ]; then
139    RUN_CMD="set +e; $RUN_CMD_WRAPPER "$(/usr/bin/printf "%q" "$RUN_CMD")"; set -e"
140fi
141
142# The replayer doesn't do any size or checksum verification for the traces in
143# the replayer db, so if we had to restart the system due to intermittent device
144# errors (or tried to cache replayer-db between runs, which would be nice to
145# have), you could get a corrupted local trace that would spuriously fail the
146# run.
147rm -rf replayer-db
148
149eval $RUN_CMD
150
151if [ $? -ne 0 ]; then
152    printf "%s\n" "Found $(cat /tmp/version.txt), expected $MESA_VERSION"
153fi
154
155ARTIFACTS_BASE_URL="https://${CI_PROJECT_ROOT_NAMESPACE}.${CI_PAGES_DOMAIN}/-/${CI_PROJECT_NAME}/-/jobs/${CI_JOB_ID}/artifacts"
156
157./piglit summary aggregate "$RESULTS" -o junit.xml
158
159PIGLIT_RESULTS="${PIGLIT_RESULTS:-replay}"
160RESULTSFILE="$RESULTS/$PIGLIT_RESULTS.txt"
161mkdir -p .gitlab-ci/piglit
162./piglit summary console "$RESULTS"/results.json.bz2 \
163    | tee ".gitlab-ci/piglit/$PIGLIT_RESULTS.txt.orig" \
164    | head -n -1 | grep -v ": pass" \
165    | sed '/^summary:/Q' \
166    > $RESULTSFILE
167
168__PREFIX="trace/$PIGLIT_REPLAY_DEVICE_NAME"
169__MINIO_PATH="$PIGLIT_REPLAY_ARTIFACTS_BASE_URL"
170__MINIO_TRACES_PREFIX="traces"
171
172if [ "x$PIGLIT_REPLAY_SUBCOMMAND" != "xprofile" ]; then
173    quiet replay_minio_upload_images
174fi
175
176
177if [ ! -s $RESULTSFILE ]; then
178    exit 0
179fi
180
181./piglit summary html --exclude-details=pass \
182"$RESULTS"/summary "$RESULTS"/results.json.bz2
183
184find "$RESULTS"/summary -type f -name "*.html" -print0 \
185        | xargs -0 sed -i 's%<img src="file://'"${RESULTS}"'.*-\([0-9a-f]*\)\.png%<img src="https://'"${JOB_ARTIFACTS_BASE}"'/traces/\1.png%g'
186find "$RESULTS"/summary -type f -name "*.html" -print0 \
187        | xargs -0 sed -i 's%<img src="file://%<img src="https://'"${PIGLIT_REPLAY_REFERENCE_IMAGES_BASE}"'/%g'
188
189quiet print_red echo "Failures in traces:"
190cat $RESULTSFILE
191quiet print_red echo "Review the image changes and get the new checksums at: ${ARTIFACTS_BASE_URL}/results/summary/problems.html"
192exit 1
193