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 (49 lines) | stat: -rw-r--r-- 1,472 bytes parent folder | download | duplicates (4)
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
summary: Ensure that the kvm interface works.

details: |
    The kvm interface allows read/write access to kvm.

prepare: |
    "$TESTSTOOLS"/snaps-state install-local test-snapd-kvm

    "$TESTSTOOLS"/fs-state mock-file /dev/kvm

    if os.query is-fedora; then
        ausearch --checkpoint stamp -m AVC || true
    fi

restore: |
    "$TESTSTOOLS"/fs-state restore-file /dev/kvm

execute: |
    echo "The interface is not connected by default"
    snap interfaces -i kvm | MATCH '^- +test-snapd-kvm:kvm'

    echo "When the interface is connected"
    snap connect test-snapd-kvm:kvm

    echo "The module file is present"
    test -s /etc/modules-load.d/snap.test-snapd-kvm.conf

    echo "Then the snap is able to read/write on /dev/kvm"
    test-snapd-kvm.with-kvm-plug -c "cat /dev/kvm"
    test-snapd-kvm.with-kvm-plug -c "echo 'test' >> /dev/kvm"

    if [ "$(snap debug confinement)" = partial ] ; then
        exit 0
    fi

    echo "When the plug is disconnected"
    snap disconnect test-snapd-kvm:kvm

    echo "Then the snap is not able to read the kvm device"
    if test-snapd-kvm.with-kvm-plug -c "cat /dev/kvm" 2> call.error; then
        echo "Expected permission error accessing to kvm device"
        exit 1
    fi
    MATCH "Permission denied" < call.error

    if os.query is-fedora; then
        # make sure there are no selinux denials on fedora
        ausearch -i --checkpoint stamp --start checkpoint -m AVC 2>&1 | MATCH 'no matches'
    fi