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 (78 lines) | stat: -rw-r--r-- 3,290 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
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
summary: Ensure that the broadcom-asic-control interface works.

details: |
    The broadcom-asic-control interface allow access to broadcom asic kernel module.

# We need to run the broadcom-asic-control test very early. The reason is
# that this test will modprobe linux-*-bde which will try to allocate a
# huge page. One the system ran for a while no chunk of memory like this
# will be not be available and the kernel will oops with:
#   "modprobe: page allocation failure: order:7, mode:0xxxx"
priority: 200

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

    "$TESTSTOOLS"/fs-state mock-file /dev/linux-user-bde
    "$TESTSTOOLS"/fs-state mock-file /dev/linux-kernel-bde
    "$TESTSTOOLS"/fs-state mock-file /dev/linux-bcm-knet

    "$TESTSTOOLS"/fs-state mock-file /run/udev/data/+pci:0test

restore: |
    "$TESTSTOOLS"/fs-state restore-file /dev/linux-user-bde
    "$TESTSTOOLS"/fs-state restore-file /dev/linux-kernel-bde
    "$TESTSTOOLS"/fs-state restore-file /dev/linux-bcm-knet

    "$TESTSTOOLS"/fs-state restore-file "/run/udev/data/+pci:0test"

execute: |
    echo "When the interface is connected"
    snap connect test-snapd-sh:broadcom-asic-control

    echo "Then the snap is able to read the system modules directories"
    for module in "linux_bcm_knet" "linux_kernel_bde" "linux_user_bde"; do
        if [ -d /sys/module/$module ]; then
            test-snapd-sh.with-broadcom-asic-control-plug -c "ls /sys/module/$module"
        fi
    done

    echo "Then the snap is able to read/write the system modules devices"
    for device in "linux-bcm-knet" "linux-kernel-bde" "linux-user-bde"; do
        test-snapd-sh.with-broadcom-asic-control-plug -c "cat /dev/$device"
        test-snapd-sh.with-broadcom-asic-control-plug -c "echo test >> /dev/$device"
    done

    echo "Then the snap is able to read pci devices info"
    if [ -d "/sys/devices/pci0000:00/" ]; then
        config="$(find /sys/devices/pci0000:00/ -name config -type f | head -n1)"
        vendor="$(find /sys/devices/pci0000:00/ -name vendor -type f | head -n1)"
        device="$(find /sys/devices/pci0000:00/ -name device -type f | head -n1)"
        subsystem_vendor="$(find /sys/devices/pci0000:00/ -name subsystem_vendor -type f | head -n1)"
        subsystem_device="$(find /sys/devices/pci0000:00/ -name subsystem_device -type f | head -n1)"

        for file in "$config" "$vendor" "$device" "$subsystem_vendor" "$subsystem_device"; do
            if [ -n "$file" ]; then
                test-snapd-sh.with-broadcom-asic-control-plug -c "cat $file"
            fi
        done
    fi

    if [ -d /sys/bus/pci/devices ]; then
        test-snapd-sh.with-broadcom-asic-control-plug -c "ls /sys/bus/pci/devices/"
    fi
    test-snapd-sh.with-broadcom-asic-control-plug -c "cat /run/udev/data/+pci:0test"

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

    echo "When the plug is disconnected"
    snap disconnect test-snapd-sh:broadcom-asic-control

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