File: task.yaml

package info (click to toggle)
snapd 2.71-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 79,536 kB
  • sloc: ansic: 16,114; sh: 16,105; python: 9,941; makefile: 1,890; exp: 190; awk: 40; xml: 22
file content (58 lines) | stat: -rw-r--r-- 2,499 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
summary: Ensure that the joystick interface works.

details: |
    The joystick interface allows reading and writing to joystick devices.

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

    # Create device files which are going to be used so simulate a real device and input data
    # In case the device already exists, it is going to be backed up
    # Devices used following documentation:
    # the https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/devices.txt#L408
    "$TESTSTOOLS"/fs-state mock-file /dev/input/js31
    "$TESTSTOOLS"/fs-state mock-file /run/udev/data/c13:31
    "$TESTSTOOLS"/fs-state mock-file /run/udev/data/c13:67
    "$TESTSTOOLS"/fs-state mock-file /dev/input/event67

restore: |
    # Delete the created device files and restore backed up files
    "$TESTSTOOLS"/fs-state restore-file /dev/input/js31
    "$TESTSTOOLS"/fs-state restore-file /run/udev/data/c13:31
    "$TESTSTOOLS"/fs-state restore-file /run/udev/data/c13:67
    "$TESTSTOOLS"/fs-state restore-file /dev/input/event67

execute: |
    echo "The interface is not connected by default"
    snap interfaces -i joystick | MATCH "\\- +test-snapd-sh:joystick"

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

    echo "Then the snap is able to access the device input for the old interface"
    test-snapd-sh.with-joystick-plug -c "echo test >> /dev/input/js31"
    test-snapd-sh.with-joystick-plug -c "cat /run/udev/data/c13:31"

    echo "Then the snap is able to access the device input for the new interface"
    test-snapd-sh.with-joystick-plug -c "cat /run/udev/data/c13:67"
    test-snapd-sh.with-joystick-plug -c "echo test >> /dev/input/event67"

    echo "Then the snap is able to read the supported event reports for the input device"
    capabilities="$(find /sys/devices/ -type d -name capabilities | grep -E "/sys/devices/.*/input[0-9].*/capabilities" | head -n1)"
    if [ -n "$capabilities" ]; then
        test-snapd-sh.with-joystick-plug -c "ls $capabilities"
    fi

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

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

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