Files
snapd/tests/main/interfaces-raw-input/task.yaml
Zeyad Yasser 3fc2456b9c run-checks: skip high-level tests requirement for interfaces with a standalone test (#14033)
* run-checks: skip high-level tests requirement for interfaces with a standalone test

interfaces-many-{core,snap}-provided tests are doing minimal testing for
all interfaces. This became one of the slowest tests that it started to timeout.

A check is added to relax the requirement for high-level tests and
skip if a standalone test already exists for the interface which at
least connects and disconnects the interface.

The requirement can be relaxed further in the future to skip the
connect/disconnect checks allowing more tests to be skipped.

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

* run-checks: relax interface checks and error on redundant tests

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

* tests: s/interfaces-input/interfaces-raw-input

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

---------

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
2024-06-05 12:12:51 +02:00

65 lines
2.8 KiB
YAML

summary: Ensure that the raw-input interface works.
details: |
The raw-input interface allows enumerating, monitoring and reading input 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 /dev/input/mouse30
"$TESTSTOOLS"/fs-state mock-file /run/udev/data/c13:31
"$TESTSTOOLS"/fs-state mock-file /run/udev/data/c13:62
"$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 /dev/input/mouse30
"$TESTSTOOLS"/fs-state restore-file /run/udev/data/c13:31
"$TESTSTOOLS"/fs-state restore-file /run/udev/data/c13:62
"$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 raw-input | MATCH "\\- +test-snapd-sh:raw-input"
echo "When the interface is connected"
snap connect test-snapd-sh:raw-input
echo "Then the snap is able to access the device input for the old interface"
test-snapd-sh.with-input-plug -c "echo test >> /dev/input/js31"
test-snapd-sh.with-input-plug -c "echo test >> /dev/input/mouse30"
test-snapd-sh.with-input-plug -c "cat /run/udev/data/c13:31"
test-snapd-sh.with-input-plug -c "cat /run/udev/data/c13:62"
echo "Then the snap is able to access the device input for the new interface"
test-snapd-sh.with-input-plug -c "cat /run/udev/data/c13:67"
test-snapd-sh.with-input-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-input-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:raw-input
echo "Then the snap is not able to read the input device"
if test-snapd-sh.with-input-plug -c "cat /dev/input/mouse30" 2> call.error; then
echo "Expected permission error accessing to input device"
exit 1
fi
MATCH "Permission denied" < call.error