-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5645 from sergiocazzolato/tests-interfaces-udisks2
tests: new test for udisks2 interface
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
udisksctl "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |