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
|
summary: Ensure that the raw-usb interface works.
details: |
The raw-usb interface allows detection and grants access to all connected USB devices.
prepare: |
"$TESTSTOOLS"/snaps-state install-local test-snapd-sh
execute: |
echo "The interface is not connected by default"
snap interfaces -i raw-usb | MATCH -- '^- +test-snapd-sh:raw-usb'
echo "When the interface is connected"
snap connect test-snapd-sh:raw-usb
if ! [ -d /sys/bus/usb/devices/usb1 ]; then
echo "No usb devices registered"
exit 0
fi
echo "Then the snap is able to check for USB devices"
test-snapd-sh.with-raw-usb-plug -c "test -d /sys/bus/usb/devices/usb1"
echo "And the snap has raw access to a connected USB device"
test-snapd-sh.with-raw-usb-plug -c "dd if=/dev/bus/usb/001/001 of=/dev/null count=10"
echo "And the snap has read access to ACM USB modems and various USB devices"
for exp in 'c166:*' 'c167:*' 'b180:*' 'c180:*' 'c188:*' 'c189:*' '+usb:*'; do
file=$(find /run/udev/data/ -name "$exp" | head -1)
if [ -n "$file" ]; then
test-snapd-sh.with-raw-usb-plug -c "cat \"$file\""
fi
done
if [ "$(snap debug confinement)" = partial ] ; then
exit 0
fi
echo "When the plug is disconnected"
snap disconnect test-snapd-sh:raw-usb
echo "Then the snap is not able to check for USB devices"
if test-snapd-sh.with-raw-usb-plug -c "cat /sys/bus/usb/devices/usb1/serial" 2> call.error; then
echo "Expected permission error accessing to check for USB devices"
exit 1
fi
MATCH "Permission denied" < call.error
|