Skip to content

Commit

Permalink
Merge pull request #5645 from sergiocazzolato/tests-interfaces-udisks2
Browse files Browse the repository at this point in the history
tests: new test for udisks2 interface
  • Loading branch information
mvo5 committed Aug 16, 2018
2 parents 24844ed + 30b6081 commit 1b00bb2
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/lib/pkgdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ pkg_dependencies_ubuntu_generic(){
pkg-config
python3-docutils
udev
udisks2
upower
uuid-runtime
"
Expand Down Expand Up @@ -586,6 +587,7 @@ pkg_dependencies_fedora(){
python3-yaml
redhat-lsb-core
rpm-build
udisks2
xdg-user-dirs
"
}
Expand All @@ -607,6 +609,7 @@ pkg_dependencies_amazon(){
xdg-user-dirs
grub2-tools
nc
udisks2
"
}

Expand All @@ -625,6 +628,7 @@ pkg_dependencies_opensuse(){
python3-yaml
netcat-openbsd
osc
udisks2
uuidd
xdg-utils
xdg-user-dirs
Expand Down Expand Up @@ -654,6 +658,7 @@ pkg_dependencies_arch(){
squashfs-tools
shellcheck
strace
udisks2
xdg-user-dirs
xfsprogs
"
Expand Down
17 changes: 17 additions & 0 deletions tests/lib/snaps/test-snapd-udisks2/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: test-snapd-udisks2
version: 1.0
summary: Basic udisks2 snap
description: A basic snap which allow operating as or interacting with the UDisks2 service
grade: stable
confinement: strict

apps:
udisksctl:
command: udisksctl
plugs: [udisks2]

parts:
copy:
plugin: dump
source: .
stage-packages: [udisks2]
3 changes: 3 additions & 0 deletions tests/lib/snaps/test-snapd-udisks2/udisksctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

udisksctl "$@"
59 changes: 59 additions & 0 deletions tests/main/interfaces-udisks2/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
summary: Ensure that the udisks2 interface works.

details: |
The udisks2 interface allows operating as or interacting with the UDisks2 service
# Interfaces not defined for ubuntu core systems
systems: [-ubuntu-core-*]

prepare: |
snap install test-snapd-udisks2
environment:
FS_PATH: "$(pwd)/dev0-fake0"
MMCBLK_PATH: /dev/mmcblk-fake0

restore: |
rm -f call.error
losetup -d "$MMCBLK_PATH" || true
rm -f "$MMCBLK_PATH" "$FS_PATH"
execute: |
echo "The interface is not connected by default"
snap interfaces -i udisks2 | MATCH -- "- +test-snapd-udisks2:udisks2"
echo "When the interface is connected"
snap connect test-snapd-udisks2:udisks2
echo "Check it is possible to see the udisks2 stauts"
test-snapd-udisks2.udisksctl status | MATCH "MODEL"
echo "Check it is possible to dump all the udisks objects info"
test-snapd-udisks2.udisksctl dump | MATCH "org.freedesktop.UDisks2.Manager"
echo "Check we can mount/unmount a block device using the snap"
# create a 10M filesystem in pwd
dd if=/dev/zero of="$FS_PATH" bs=1M count=10
mkfs.ext4 -F "$FS_PATH"
# create the loopback block device
mknod "$MMCBLK_PATH" b 7 200
losetup "$MMCBLK_PATH" "$FS_PATH"
device="$(losetup -j "$FS_PATH" | cut -d: -f1)"
test-snapd-udisks2.udisksctl mount -b "$device" -t ext4 | MATCH "Mounted /dev/"
test-snapd-udisks2.udisksctl unmount -b "$device" | MATCH "Unmounted /dev/"
if [ "$(snap debug confinement)" = partial ] ; then
exit 0
fi
echo "When the plug is disconnected"
snap disconnect test-snapd-udisks2:udisks2
echo "Then the snap is not able to check udisks2 status"
if test-snapd-udisks2.udisksctl status 2> call.error; then
echo "Expected permission error calling udisksctl status with disconnected plug"
exit 1
fi
MATCH "Permission denied" < call.error

0 comments on commit 1b00bb2

Please sign in to comment.