aboutsummaryrefslogtreecommitdiffstats
path: root/.gitlab-ci/deqp-runner.sh
blob: b651570cf1cb7f2b793bbe766a13887e3c611bbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash

set -ex

DEQP_OPTIONS=(--deqp-surface-width=256 --deqp-surface-height=256)
DEQP_OPTIONS+=(--deqp-surface-type=pbuffer)
DEQP_OPTIONS+=(--deqp-gl-config-name=rgba8888d24s8ms0)
DEQP_OPTIONS+=(--deqp-visibility=hidden)

# It would be nice to be able to enable the watchdog, so that hangs in a test
# don't need to wait the full hour for the run to time out.  However, some
# shaders end up taking long enough to compile
# (dEQP-GLES31.functional.ubo.random.all_per_block_buffers.20 for example)
# that they'll sporadically trigger the watchdog.
#DEQP_OPTIONS+=(--deqp-watchdog=enable)

if [ -z "$DEQP_VER" ]; then
   echo 'DEQP_VER must be set to something like "gles2" or "gles31" for the test run'
   exit 1
fi

if [ -z "$DEQP_SKIPS" ]; then
   echo 'DEQP_SKIPS must be set to something like "deqp-default-skips.txt"'
   exit 1
fi

ARTIFACTS=`pwd`/artifacts

# Set up the driver environment.
export LD_LIBRARY_PATH=`pwd`/install/lib/
export EGL_PLATFORM=surfaceless

# the runner was failing to look for libkms in /usr/local/lib for some reason
# I never figured out.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

RESULTS=`pwd`/results
mkdir -p $RESULTS

# Generate test case list file
cp /deqp/mustpass/$DEQP_VER-master.txt /tmp/case-list.txt

# If the job is parallel, take the corresponding fraction of the caselist.
# Note: N~M is a gnu sed extension to match every nth line (first line is #1).
if [ -n "$CI_NODE_INDEX" ]; then
   sed -ni $CI_NODE_INDEX~$CI_NODE_TOTAL"p" /tmp/case-list.txt
fi

if [ ! -s /tmp/case-list.txt ]; then
    echo "Caselist generation failed"
    exit 1
fi

if [ -n "$DEQP_EXPECTED_FAILS" ]; then
    XFAIL="--xfail-list $ARTIFACTS/$DEQP_EXPECTED_FAILS"
fi

set +e

run_cts() {
    caselist=$1
    output=$2
    deqp-runner \
        --deqp /deqp/modules/$DEQP_VER/deqp-$DEQP_VER \
        --output $output \
        --caselist $caselist \
        --exclude-list $ARTIFACTS/$DEQP_SKIPS \
        $XFAIL \
        --job ${DEQP_PARALLEL:-1} \
	--allow-flakes true \
        -- \
        "${DEQP_OPTIONS[@]}"
}

report_flakes() {
    if [ -z "$FLAKES_CHANNEL" ]; then
        return 0
    fi
    flakes=$1
    bot="$CI_RUNNER_DESCRIPTION-$CI_PIPELINE_ID"
    channel="$FLAKES_CHANNEL"
    (
    echo NICK $bot
    echo USER $bot unused unused :Gitlab CI Notifier
    sleep 10
    echo "JOIN $channel"
    sleep 1
    desc="Flakes detected in job: $CI_JOB_URL on $CI_RUNNER_DESCRIPTION"
    if [ -n "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" ]; then
        desc="$desc on branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME ($CI_MERGE_REQUEST_TITLE)"
    fi
    echo "PRIVMSG $channel :$desc"
    for flake in `cat $flakes`; do
        echo "PRIVMSG $channel :$flake"
    done
    echo "PRIVMSG $channel :See $CI_JOB_URL/artifacts/browse/results/"
    echo "QUIT"
    ) | nc irc.freenode.net 6667 > /dev/null

}

# wrapper to supress +x to avoid spamming the log
quiet() {
    set +x
    "$@"
    set -x
}

run_cts /tmp/case-list.txt $RESULTS/cts-runner-results.txt
DEQP_EXITCODE=$?

if [ $DEQP_EXITCODE -ne 0 ]; then
    # preserve caselist files in case of failures:
    cp /tmp/cts_runner.*.txt $RESULTS/
    echo "Some unexpected results found (see cts-runner-results.txt in artifacts for full results):"
    cat $RESULTS/cts-runner-results.txt | \
        grep -v ",Pass" | \
        grep -v ",Skip" | \
        grep -v ",ExpectedFail" > \
        $RESULTS/cts-runner-unexpected-results.txt
    head -n 50 $RESULTS/cts-runner-unexpected-results.txt

    count=`cat $RESULTS/cts-runner-unexpected-results.txt | wc -l`

    # Re-run fails to detect flakes.  But use a small threshold, if
    # something was fundamentally broken, we don't want to re-run
    # the entire caselist
else
    cat $RESULTS/cts-runner-results.txt | \
        grep ",Flake" > \
        $RESULTS/cts-runner-flakes.txt

    count=`cat $RESULTS/cts-runner-flakes.txt | wc -l`
    if [ $count -gt 0 ]; then
        echo "Some flakes found (see cts-runner-flakes.txt in artifacts for full results):"
        head -n 50 $RESULTS/cts-runner-flakes.txt

        # Save the logs for up to the first 50 flakes:
        head -n 50 $RESULTS/cts-runner-flakes.txt | quiet extract_xml_results /tmp/*.qpa

        # Report the flakes to IRC channel for monitoring (if configured):
        quiet report_flakes $RESULTS/cts-runner-flakes.txt
    else
        # no flakes, so clean-up:
        rm $RESULTS/cts-runner-flakes.txt
    fi
fi

exit $DEQP_EXITCODE