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 (66 lines) | stat: -rw-r--r-- 2,727 bytes parent folder | download | duplicates (3)
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
summary: check that the bluetooth-control interface works

details: |
    Check the bluetooth-control interface allows reading usb, class and dev under
    /sys directory. Verify the interface doesn't allow reading when it is disconnected.

# currently only enabled for the system that has bluetooth hardware (dragonboard)
systems: [ubuntu-core-16-arm-64]

prepare: |
    echo "Given a snap declaring a plug on bluetooth-control is installed"
    #shellcheck source=tests/lib/snaps.sh
    . "$TESTSLIB"/snaps.sh
    install_generic_consumer bluetooth-control

execute: |
    BTDEV="$(find /sys/devices/ -type d -name bluetooth)"

    echo "Then the plug is disconnected by default"
    #shellcheck disable=SC1117
    snap interfaces -i bluetooth-control | MATCH "^\- +generic-consumer:bluetooth-control"

    echo "When the plug is connected"
    snap connect generic-consumer:bluetooth-control

    echo "Then the snap is able to read usb"
    #shellcheck disable=SC2002
    cat /sys/bus/usb/drivers/btusb/module/version | tee version
    # the next check is disabled because of https://bugs.launchpad.net/snapd/+bug/1698412
    # [ "$(su -l -c '/snap/bin/generic-consumer.cmd cat /sys/bus/usb/drivers/btusb/module/version' test)" = "$(cat version)" ]

    echo "And the snap is able to read class"
    cat /sys/class/bluetooth/*/name | tee class
    [ "$(su -l -c '/snap/bin/generic-consumer.cmd cat /sys/class/bluetooth/*/name' test)" = "$(cat class)" ]

    echo "And the snap is able to read dev"
    cat "$BTDEV"/*/power/control | tee control
    [ "$(su -l -c '/snap/bin/generic-consumer.cmd cat '"$BTDEV"'/*/power/control' test)" = "$(cat control)" ]

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

    echo "When the plug is disconnected"
    snap disconnect generic-consumer:bluetooth-control

    echo "And the snap is not able to read usb"
    if su -l -c "/snap/bin/generic-consumer.cmd cat /sys/bus/usb/drivers/btusb/module/version" test 2> btusb.error; then
        echo "Expected error with disconnected plug didn't happen"
        exit 1
    fi
    MATCH "Permission denied" < btusb.error

    echo "And the snap is not able to read class"
    if su -l -c "/snap/bin/generic-consumer.cmd cat /sys/class/bluetooth/*/name" test 2> btclass.error; then
        echo "Expected error with disconnected plug didn't happen"
        exit 1
    fi
    MATCH "Permission denied" < btclass.error

    echo "And the snap is not able to read dev"
    if su -l -c "/snap/bin/generic-consumer.cmd cat $BTDEV/*/power/control" test 2> btdev-read.error; then
        echo "Expected error with disconnected plug didn't happen"
        exit 1
    fi
    MATCH "Permission denied" < btdev-read.error