Files
snapd/tests/main/interfaces-alsa/task.yaml
Zygmunt Bazyli Krynicki 6da6dd1472 tests: document or tweak documentation of interface tests (#13896)
* tests: fix typo: case

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-audio-playback-record

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-avahi-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-cli

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-content-circular

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-content-empty-content-attr

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-cups-control-autoconect

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-cups-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-content-mkdir-writable

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-custom-device-app-slot

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-desktop-document-portal

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-firewall-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-fuse-support

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests: fix typo: default

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-hardware-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-hardware-random-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-hardware-random-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-home

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-hooks

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-hooks-plug-with-number

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-kernel-module-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-libvirt

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-locale-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-location-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-log-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-mount-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: rewrite documentation of interfaces-mount-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-netlink-connector

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-network

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: rewrite documentation of interfaces-network-bind

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-network-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-network-manager

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat and tweak details of interfaces-network-status

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-packagekit-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-password-manager-service

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-personal-files

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: rewrite details of interfaces-polkit

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-pulseaudio

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-snapd-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-snapd-control-with-manage

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-system-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-upower-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-wayland

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document known

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document known-remote

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests: correct the summary for known-remote test

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests: fix typo: bound

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document install-local-w-metadata

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document login

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

---------

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-04-26 15:10:48 +02:00

96 lines
3.6 KiB
YAML

summary: Ensure that the alsa interface works.
details: |
The alsa interface allows connected plugs to access raw ALSA devices.
A snap which defines a alsa plug must be shown in the interfaces list.
The plug must not be autoconnected on install and, as usual, must be able to
be reconnected.
A snap declaring a plug on this interface must be able to access to raw ALSA
devices, for this test we check the low level security rules by creating
specific devices under /dev/snd, a cgroup if needed and the ALSA state dir,
exercising in each case the read or read-write permissions that must be in
place.
# Spread system for Fedora, openSUSE and AMZN2 don't seem to provide any /dev/snd entries
systems: [-fedora-*, -opensuse-*, -amazon-*, -centos-*]
prepare: |
echo "Given a snap declaring a plug on the alsa interface is installed"
#shellcheck source=tests/lib/snaps.sh
. "$TESTSLIB"/snaps.sh
install_generic_consumer alsa
restore: |
rm -f /dev/snd/mysnd-dev
execute: |
echo "When the plug is connected"
snap connect generic-consumer:alsa
if ! [ -d /dev/snd/ ]; then
echo "No sound devices available in the system"
exit 0
fi
echo "Then the snap is able to access snd devices"
mkdir -p /dev/snd
generic-consumer.cmd touch /dev/snd/mysnd-dev
echo "mysnd-dev-content" | tee /dev/snd/mysnd-dev
generic-consumer.cmd cat /dev/snd/mysnd-dev | MATCH mysnd-dev-content
generic-consumer.cmd rm /dev/snd/mysnd-dev
echo "And the snap is able to access the related udev data"
if [ ! -f /run/udev/data/c116:0 ]; then
touch /run/udev/data/c116:0
echo "myudevdata-content" | tee /run/udev/data/c116:0
generic-consumer.cmd cat /run/udev/data/c116:0 | MATCH myudevdata-content
rm /run/udev/data/c116:0
fi
# TODO: extend test to check /var/lib/alsa with plug connected when
# https://bugs.launchpad.net/snapd/+bug/1694281 is fixed
if [ "$(snap debug confinement)" = partial ] ; then
echo "Do not execute checks with disconnected plug on systems where confinement doesn't work"
exit 0
fi
echo "When the plug is disconnected"
snap disconnect generic-consumer:alsa
echo "The snap is not able to access snd devices"
if generic-consumer.cmd touch /dev/snd/mysnd-dev 2>snd-create.error; then
echo "Create snd device with disconnected plug should fail"
exit 1
fi
MATCH "Permission denied" ./snd-create.error
touch /dev/snd/mysnd-dev
echo "mysnd-content" | tee /dev/snd/mysnd-dev
if generic-consumer.cmd cat /dev/snd/mysnd-dev 2>snd-read.error; then
echo "Read snd device with disconnected plug should fail"
exit 1
fi
MATCH "Permission denied" ./snd-read.error
if generic-consumer.cmd rm /dev/snd/mysnd-dev 2>snd-del.error; then
echo "Delete snd device with disconnected plug should fail"
exit 1
fi
MATCH "Permission denied" ./snd-del.error
echo "And the snap is not able to access the related udev data"
if [ ! -f /run/udev/data/c116:0 ]; then
touch /run/udev/data/c116:0
echo "myudevdata-content" | tee /run/udev/data/c116:0
if generic-consumer.cmd cat /run/udev/data/c116:0 2>udevdata-read.error; then
echo "Read udev data file with disconnected plug should fail"
exit 1
fi
MATCH "Permission denied" ./udevdata-read.error
rm /run/udev/data/c116:0
fi
# TODO: extend test to check /var/lib/alsa with plug disconnected when
# https://bugs.launchpad.net/snapd/+bug/1694281 is fixed