• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# shellcheck disable=SC2035 # FIXME glob
3
4set -ex
5
6if [[ -z "$VK_DRIVER" ]]; then
7    exit 1
8fi
9
10INSTALL=$(realpath -s "$PWD"/install)
11
12RESULTS=$(realpath -s "$PWD"/results)
13
14# Set up the driver environment.
15# Modifiying here directly LD_LIBRARY_PATH may cause problems when
16# using a command wrapper. Hence, we will just set it when running the
17# command.
18export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$INSTALL/lib/:/vkd3d-proton-tests/x64/"
19
20
21# Sanity check to ensure that our environment is sufficient to make our tests
22# run against the Mesa built by CI, rather than any installed distro version.
23MESA_VERSION=$(sed 's/\./\\./g' "$INSTALL/VERSION")
24
25# Set the Vulkan driver to use.
26export VK_ICD_FILENAMES="$INSTALL/share/vulkan/icd.d/${VK_DRIVER}_icd.x86_64.json"
27
28# Set environment for Wine.
29export WINEDEBUG="-all"
30export WINEPREFIX="/vkd3d-proton-wine64"
31export WINEESYNC=1
32
33# wrapper to supress +x to avoid spamming the log
34quiet() {
35    set +x
36    "$@"
37    set -x
38}
39
40set +e
41if ! vulkaninfo | tee /tmp/version.txt | grep "\"Mesa $MESA_VERSION\(\s\|$\)\"";
42then
43    printf "%s\n" "Found $(cat /tmp/version.txt), expected $MESA_VERSION"
44fi
45set -e
46
47if [ -d "$RESULTS" ]; then
48    cd "$RESULTS" && rm -rf ..?* .[!.]* * && cd -
49else
50    mkdir "$RESULTS"
51fi
52
53quiet printf "%s\n" "Running vkd3d-proton testsuite..."
54
55set +e
56if ! /vkd3d-proton-tests/x64/bin/d3d12 > "$RESULTS/vkd3d-proton.log";
57then
58    # Check if the executable finished (ie. no segfault).
59    if ! grep "tests executed" "$RESULTS/vkd3d-proton.log" > /dev/null; then
60        error printf "%s\n" "Failed, see vkd3d-proton.log!"
61        exit 1
62    fi
63
64    # Collect all the failures
65    VKD3D_PROTON_RESULTS="${VKD3D_PROTON_RESULTS:-vkd3d-proton-results}"
66    RESULTSFILE="$RESULTS/$VKD3D_PROTON_RESULTS.txt"
67    mkdir -p .gitlab-ci/vkd3d-proton
68    grep "Test failed" "$RESULTS"/vkd3d-proton.log > "$RESULTSFILE"
69
70    # Gather the list expected failures
71    if [ -f "$INSTALL/$VKD3D_PROTON_RESULTS.txt" ]; then
72        cp "$INSTALL/$VKD3D_PROTON_RESULTS.txt" \
73           ".gitlab-ci/vkd3d-proton/$VKD3D_PROTON_RESULTS.txt.baseline"
74    else
75        touch ".gitlab-ci/vkd3d-proton/$VKD3D_PROTON_RESULTS.txt.baseline"
76    fi
77
78    # Make sure that the failures found in this run match the current expectation
79    if ! diff -q ".gitlab-ci/vkd3d-proton/$VKD3D_PROTON_RESULTS.txt.baseline" "$RESULTSFILE"; then
80        error printf "%s\n" "Changes found, see vkd3d-proton.log!"
81        quiet diff --color=always -u ".gitlab-ci/vkd3d-proton/$VKD3D_PROTON_RESULTS.txt.baseline" "$RESULTSFILE"
82        exit 1
83    fi
84fi
85
86printf "%s\n" "vkd3d-proton execution: SUCCESS"
87
88exit 0
89