1#!/bin/bash
2
3set -e
4set -o xtrace
5
6VERSION=`head -1 install/VERSION`
7ROOTDIR=`pwd`
8
9if [ -d results ]; then
10    cd results && rm -rf ..?* .[!.]* *
11fi
12cd /piglit
13
14export OCL_ICD_VENDORS=$ROOTDIR/install/etc/OpenCL/vendors/
15
16set +e
17unset DISPLAY
18export LD_LIBRARY_PATH=$ROOTDIR/install/lib
19clinfo
20
21# If the job is parallel at the gitlab job level, will take the corresponding
22# fraction of the caselist.
23if [ -n "$CI_NODE_INDEX" ]; then
24
25    if [ "$PIGLIT_PROFILES" != "${PIGLIT_PROFILES% *}" ]; then
26        echo "Can't parallelize piglit with multiple profiles"
27        exit 1
28    fi
29    USE_CASELIST=1
30fi
31
32if [ -n "$USE_CASELIST" ]; then
33    ./piglit print-cmd $PIGLIT_TESTS $PIGLIT_PROFILES --format "{name}" > /tmp/case-list.txt
34
35    sed -ni $CI_NODE_INDEX~$CI_NODE_TOTAL"p" /tmp/case-list.txt
36
37    PIGLIT_TESTS="--test-list /tmp/case-list.txt"
38fi
39
40./piglit run -c -j${FDO_CI_CONCURRENT:-4} $PIGLIT_OPTIONS $PIGLIT_TESTS $PIGLIT_PROFILES $ROOTDIR/results
41retVal=$?
42if [ $retVal -ne 0 ]; then
43    echo "Found $(cat /tmp/version.txt), expected $VERSION"
44fi
45set -e
46
47PIGLIT_RESULTS=${PIGLIT_RESULTS:-$PIGLIT_PROFILES}
48mkdir -p .gitlab-ci/piglit
49./piglit summary console $ROOTDIR/results \
50  | tee ".gitlab-ci/piglit/$PIGLIT_RESULTS.txt.orig" \
51  | head -n -1 \
52  | grep -v ": pass" \
53  | sed '/^summary:/Q' \
54  > .gitlab-ci/piglit/$PIGLIT_RESULTS.txt
55
56if [ -n "$USE_CASELIST" ]; then
57    # Just filter the expected results based on the tests that were actually
58    # executed, and switch to the version with no summary
59    cat .gitlab-ci/piglit/$PIGLIT_RESULTS.txt.orig | sed '/^summary:/Q' | rev \
60         | cut -f2- -d: | rev | sed "s/$/:/g" > /tmp/executed.txt
61    grep -F -f /tmp/executed.txt $ROOTDIR/install/$PIGLIT_RESULTS.txt \
62         > .gitlab-ci/piglit/$PIGLIT_RESULTS.txt.baseline || true
63else
64    cp $ROOTDIR/install/$PIGLIT_RESULTS.txt .gitlab-ci/piglit/$PIGLIT_RESULTS.txt.baseline
65fi
66
67if diff -q .gitlab-ci/piglit/$PIGLIT_RESULTS.txt{.baseline,}; then
68    exit 0
69fi
70
71./piglit summary html --exclude-details=pass $ROOTDIR/results/summary $ROOTDIR/results
72
73echo Unexpected change in results:
74diff -u .gitlab-ci/piglit/$PIGLIT_RESULTS.txt{.baseline,}
75exit 1
76