17ec681f3Smrg#!/bin/bash
27ec681f3Smrg
37ec681f3Smrgset -e
47ec681f3Smrgset -o xtrace
57ec681f3Smrg
67ec681f3SmrgVERSION=`head -1 install/VERSION`
77ec681f3SmrgROOTDIR=`pwd`
87ec681f3Smrg
97ec681f3Smrgif [ -d results ]; then
107ec681f3Smrg    cd results && rm -rf ..?* .[!.]* *
117ec681f3Smrgfi
127ec681f3Smrgcd /piglit
137ec681f3Smrg
147ec681f3Smrgexport OCL_ICD_VENDORS=$ROOTDIR/install/etc/OpenCL/vendors/
157ec681f3Smrg
167ec681f3Smrgset +e
177ec681f3Smrgunset DISPLAY
187ec681f3Smrgexport LD_LIBRARY_PATH=$ROOTDIR/install/lib
197ec681f3Smrgclinfo
207ec681f3Smrg
217ec681f3Smrg# If the job is parallel at the gitlab job level, will take the corresponding
227ec681f3Smrg# fraction of the caselist.
237ec681f3Smrgif [ -n "$CI_NODE_INDEX" ]; then
247ec681f3Smrg
257ec681f3Smrg    if [ "$PIGLIT_PROFILES" != "${PIGLIT_PROFILES% *}" ]; then
267ec681f3Smrg        echo "Can't parallelize piglit with multiple profiles"
277ec681f3Smrg        exit 1
287ec681f3Smrg    fi
297ec681f3Smrg    USE_CASELIST=1
307ec681f3Smrgfi
317ec681f3Smrg
327ec681f3Smrgif [ -n "$USE_CASELIST" ]; then
337ec681f3Smrg    ./piglit print-cmd $PIGLIT_TESTS $PIGLIT_PROFILES --format "{name}" > /tmp/case-list.txt
347ec681f3Smrg
357ec681f3Smrg    sed -ni $CI_NODE_INDEX~$CI_NODE_TOTAL"p" /tmp/case-list.txt
367ec681f3Smrg
377ec681f3Smrg    PIGLIT_TESTS="--test-list /tmp/case-list.txt"
387ec681f3Smrgfi
397ec681f3Smrg
407ec681f3Smrg./piglit run -c -j${FDO_CI_CONCURRENT:-4} $PIGLIT_OPTIONS $PIGLIT_TESTS $PIGLIT_PROFILES $ROOTDIR/results
417ec681f3SmrgretVal=$?
427ec681f3Smrgif [ $retVal -ne 0 ]; then
437ec681f3Smrg    echo "Found $(cat /tmp/version.txt), expected $VERSION"
447ec681f3Smrgfi
457ec681f3Smrgset -e
467ec681f3Smrg
477ec681f3SmrgPIGLIT_RESULTS=${PIGLIT_RESULTS:-$PIGLIT_PROFILES}
487ec681f3Smrgmkdir -p .gitlab-ci/piglit
497ec681f3Smrg./piglit summary console $ROOTDIR/results \
507ec681f3Smrg  | tee ".gitlab-ci/piglit/$PIGLIT_RESULTS.txt.orig" \
517ec681f3Smrg  | head -n -1 \
527ec681f3Smrg  | grep -v ": pass" \
537ec681f3Smrg  | sed '/^summary:/Q' \
547ec681f3Smrg  > .gitlab-ci/piglit/$PIGLIT_RESULTS.txt
557ec681f3Smrg
567ec681f3Smrgif [ -n "$USE_CASELIST" ]; then
577ec681f3Smrg    # Just filter the expected results based on the tests that were actually
587ec681f3Smrg    # executed, and switch to the version with no summary
597ec681f3Smrg    cat .gitlab-ci/piglit/$PIGLIT_RESULTS.txt.orig | sed '/^summary:/Q' | rev \
607ec681f3Smrg         | cut -f2- -d: | rev | sed "s/$/:/g" > /tmp/executed.txt
617ec681f3Smrg    grep -F -f /tmp/executed.txt $ROOTDIR/install/$PIGLIT_RESULTS.txt \
627ec681f3Smrg         > .gitlab-ci/piglit/$PIGLIT_RESULTS.txt.baseline || true
637ec681f3Smrgelse
647ec681f3Smrg    cp $ROOTDIR/install/$PIGLIT_RESULTS.txt .gitlab-ci/piglit/$PIGLIT_RESULTS.txt.baseline
657ec681f3Smrgfi
667ec681f3Smrg
677ec681f3Smrgif diff -q .gitlab-ci/piglit/$PIGLIT_RESULTS.txt{.baseline,}; then
687ec681f3Smrg    exit 0
697ec681f3Smrgfi
707ec681f3Smrg
717ec681f3Smrg./piglit summary html --exclude-details=pass $ROOTDIR/results/summary $ROOTDIR/results
727ec681f3Smrg
737ec681f3Smrgecho Unexpected change in results:
747ec681f3Smrgdiff -u .gitlab-ci/piglit/$PIGLIT_RESULTS.txt{.baseline,}
757ec681f3Smrgexit 1
76