File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (226 lines) | stat: -rw-r--r-- 10,193 bytes parent folder | download
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
summary: Verify that all shared libraries exposed by the host can be loaded.

details: |
    We want to ensure that all of the libraries exposed through
    /var/lib/snapd/lib/gl{,32} can be loaded with dlopen without errors.

    While not perfect, it shows the extent of the contract that snapd promises to
    upkeep - that the libraries exist and may be loaded. This test does not
    verify if the opengl interface provides permissions required to access device
    nodes, and the complex interaction of device nodes with special Nvidia
    support code in snap-confine as this would require really loading the driver
    and having matching hardware exposed to the test machine.

systems:
    - ubuntu-18.04-64
    - ubuntu-20.04-64
    - ubuntu-22.04-64
    - ubuntu-24.04-64

environment:
    # WARNING: Not all combinations of system and variant do something.
    # Some are skipped in task.sh, in ways that spread does not support natively.
    PACKAGE_VERSION/390: 390
    PACKAGE_VERSION/470: 470
    PACKAGE_VERSION/510: 510
    PACKAGE_VERSION/515: 515
    PACKAGE_VERSION/525: 525
    PACKAGE_VERSION/530: 530
    PACKAGE_VERSION/535: 535
    PACKAGE_VERSION/550: 550
    PACKAGE_VERSION/560: 560
    # All the -server versions.
    PACKAGE_SUFFIX/418_server: -server
    PACKAGE_SUFFIX/450_server: -server
    PACKAGE_SUFFIX/470_server: -server
    PACKAGE_SUFFIX/515_server: -server
    PACKAGE_SUFFIX/535_server: -server
    PACKAGE_SUFFIX/550_server: -server
    PACKAGE_VERSION/418_server: 418
    PACKAGE_VERSION/450_server: 450
    PACKAGE_VERSION/470_server: 470
    PACKAGE_VERSION/515_server: 515
    PACKAGE_VERSION/535_server: 535
    PACKAGE_VERSION/550_server: 550
    # NOTE: -open versions are excluded, as the only difference is in the kernel
    # module which we are not testing here, the userspace binary is exactly the
    # same in all the cases.

prepare: |
    # Skip some permutations of system and driver version.
    # This is done for three reasons explained below.
    declare -A skip
    skip["ubuntu-18.04-64/390"]="broken-driver"
    skip["ubuntu-18.04-64/515"]="broken-driver"
    skip["ubuntu-18.04-64/515-server"]="broken-driver"
    skip["ubuntu-18.04-64/535"]="no-driver"
    skip["ubuntu-18.04-64/535-server"]="no-driver"
    skip["ubuntu-18.04-64/550"]="no-driver"
    skip["ubuntu-18.04-64/550-server"]="no-driver"
    skip["ubuntu-18.04-64/560"]="no-driver"

    skip["ubuntu-20.04-64/390"]="broken-driver"
    skip["ubuntu-20.04-64/510"]="transitional-driver"
    skip["ubuntu-20.04-64/515"]="transitional-driver"
    skip["ubuntu-20.04-64/515-server"]="transitional-driver"
    skip["ubuntu-20.04-64/525"]="transitional-driver"
    skip["ubuntu-20.04-64/530"]="transitional-driver"
    skip["ubuntu-20.04-64/535"]="broken-packaging"

    # The i386 side of the driver is not installable due to
    # https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-535-server/+bug/2080351
    skip["ubuntu-20.04-64/535-server"]="broken-packaging"
    skip["ubuntu-20.04-64/550"]="no-driver"
    skip["ubuntu-20.04-64/550-server"]="broken-packaging"
    skip["ubuntu-20.04-64/560"]="no-driver"

    skip["ubuntu-22.04-64/390"]="broken-driver"
    skip["ubuntu-22.04-64/510"]="transitional-driver"
    skip["ubuntu-22.04-64/515"]="transitional-driver"
    skip["ubuntu-22.04-64/515-server"]="transitional-driver"
    skip["ubuntu-22.04-64/525"]="transitional-driver"
    skip["ubuntu-22.04-64/530"]="transitional-driver"
    skip["ubuntu-22.04-64/550-server"]="transitional-driver"
    skip["ubuntu-22.04-64/560"]="no-driver"

    skip["ubuntu-24.04-64/390"]="no-driver"
    skip["ubuntu-24.04-64/418-server"]="no-driver"
    skip["ubuntu-24.04-64/450-server"]="no-driver"
    skip["ubuntu-24.04-64/470"]="broken-driver"
    skip["ubuntu-24.04-64/470-server"]="broken-driver"
    skip["ubuntu-24.04-64/510"]="transitional-driver"
    skip["ubuntu-24.04-64/515"]="transitional-driver"
    skip["ubuntu-24.04-64/515-server"]="transitional-driver"
    skip["ubuntu-24.04-64/525"]="transitional-driver"
    skip["ubuntu-24.04-64/530"]="transitional-driver"
    skip["ubuntu-24.04-64/550-server"]="transitional-driver"
    skip["ubuntu-24.04-64/560"]="no-driver"

    driver_suffix="$PACKAGE_VERSION${PACKAGE_SUFFIX:-}"
    combi_key="$SPREAD_SYSTEM/$driver_suffix"

    # First, we list all the driver versions in task.yaml, even though many of them
    # are just non-existent on a given system - this is a limitation of the spread
    # variant system where variant cannot be excluded only for a given system. Skip
    # permutations that are not installable on a given system.
    if [ "$(apt-cache show nvidia-driver-"$driver_suffix" | wc -l)" -eq 0 ]; then
        echo "No driver is available, expecting: skip[\"$combi_key\"]=\"no-driver\""
        test "${skip[$combi_key]}" = "no-driver"
        exit 0
    fi

    # Second, some drivers are only transitional support packages that don't
    # actually ship any files.
    if apt-cache show nvidia-driver-"$driver_suffix" | grep -i transitional; then
        echo "Transitional driver is in use, expecting: skip[\"$combi_key\"]=\"transitional-driver\""
        test "${skip[$combi_key]}" = "transitional-driver"
        exit 0
    fi

    # Third, some combinations are really buggy.
    case "$combi_key" in
    ubuntu-18.04-64/515* | ubuntu-18.04-64/390* | ubuntu-2[02].04-64/390*)
        # This fails with:
        # + exec /snap/test-snapd-nvidia/x1/bin/dlopen-tool.64
        # /var/lib/snapd/lib/gl/libEGL_nvidia.so.0
        # ...
        # /var/lib/snapd/lib/gl/libnvidia-tls.so.390.157
        # *** stack smashing detected ***: terminated
        echo "Broken driver is in use, expecting: skip[\"$combi_key\"]=\"broken-driver\""
        test "${skip[$combi_key]}" = "broken-driver"
        exit 0
        ;;
    ubuntu-24.04-64/470*)
        # This fails with:
        # + exec /snap/test-snapd-nvidia/2/bin/dlopen-tool.64
        # /var/lib/snapd/lib/gl/libEGL_nvidia.so.0
        # ...
        # /var/lib/snapd/lib/gl/libnvidia-vulkan-producer.so: undefined symbol: wlEglInitializeSurfaceExport: No such file or directory
        echo "Broken driver is in use, expecting: skip[\"$combi_key\"]=\"broken-driver\""
        test "${skip[$combi_key]}" = "broken-driver"
        exit 0
        ;;
    esac

    # We will need to install i386 libraries. This is specifically done on an
    # amd64 system as there are cases of 32bit programs running through
    # otherwise 64bit snap, running on 64bit host.
    dpkg --add-architecture i386
    apt-get update

    # Install Nvidia userspace libraries at the designated version.
    if ! apt-get install -y \
        libnvidia-common-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}" \
        libnvidia-compute-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":amd64 \
        libnvidia-compute-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":i386 \
        libnvidia-decode-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":amd64 \
        libnvidia-decode-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":i386 \
        libnvidia-encode-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":amd64 \
        libnvidia-encode-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":i386 \
        libnvidia-fbc1-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":amd64 \
        libnvidia-fbc1-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":i386 \
        libnvidia-gl-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":amd64 \
        libnvidia-gl-"$PACKAGE_VERSION${PACKAGE_SUFFIX:-}":i386 >install.txt 2>&1; then
      echo "Broken packaging, expecting: skip[\"$combi_key\"]=\"broken-packaging\""
      test "${skip[$combi_key]}" = "broken-packaging"
      exit 0
    fi

    # At this step, we we expect this test to work, and no skip condition to exist.
    echo "Everything is good, expecting: skip[\"$combi_key\"] not to exist"
    if [[ -v "skip[$combi_key]" ]]; then
        exit 1
    fi

    # Look at the canary file libnvidia-glcore.so.* to get the exact version of
    # the driver. This file is also used by snap-confine, as a pre-condition
    # that the libraries are installed.
    DRIVER_VERSION="$(find /usr/lib/x86_64-linux-gnu/ -name 'libnvidia-glcore.so.*' | sed -e 's,.*/libnvidia-glcore\.so\.,,')"

    # Pretend we have Nvidia kernel module loaded, so that snap-confine enables
    # special logic. The actual version we pretend to have is set later, as it
    # must match installed libraries so that the right canary file is detected by
    # snap-confine.
    mkdir -p /tmp/sys-module/nvidia
    tests.cleanup defer rm -rf /tmp/sys-module
    echo "$DRIVER_VERSION" >/tmp/sys-module/nvidia/version
    # mock /sys/module we need to recreate /sys/module/apparmor
    mkdir -p /tmp/sys-module-apparmor
    tests.cleanup defer rmdir /tmp/sys-module-apparmor
    mount -o bind /sys/module/apparmor /tmp/sys-module-apparmor
    tests.cleanup defer umount /tmp/sys-module-apparmor
    mkdir -p /tmp/sys-module/apparmor

    mount -o bind /tmp/sys-module/ /sys/module
    # and recreate apparmor directory
    mount -o bind /tmp/sys-module-apparmor /sys/module/apparmor
    tests.cleanup defer umount -R /sys/module

    snap install test-snapd-nvidia

    # Indicate that this permutation of system and driver version should be tested
    tests.cleanup defer rm -f test-this-permutation
    touch test-this-permutation

restore: |
    tests.cleanup restore

debug: |
    if [ -f install.txt ]; then cat install.txt; fi
    if [ -f log-32.txt ]; then cat log-32.txt; fi
    if [ -f log-64.txt ]; then cat log-64.txt; fi

execute: |
    test -f test-this-permutation || exit 0

    test-snapd-nvidia.64 >log-64.txt
    MATCH 'dlopen /var/lib/snapd/lib/gl/libEGL_nvidia.so.*' <log-64.txt
    MATCH 'dlopen /var/lib/snapd/lib/gl/libGLESv2_nvidia.so.*' <log-64.txt
    MATCH 'dlopen /var/lib/snapd/lib/gl/libGLX_nvidia.so.*' <log-64.txt
    MATCH 'dlopen /var/lib/snapd/lib/gl/libcuda.so*' <log-64.txt

    test-snapd-nvidia.32 >log-32.txt
    MATCH 'dlopen /var/lib/snapd/lib/gl32/libEGL_nvidia.so.*' <log-32.txt
    MATCH 'dlopen /var/lib/snapd/lib/gl32/libGLESv2_nvidia.so.*' <log-32.txt
    MATCH 'dlopen /var/lib/snapd/lib/gl32/libGLX_nvidia.so.*' <log-32.txt
    MATCH 'dlopen /var/lib/snapd/lib/gl32/libcuda.so*' <log-32.txt