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 48 49
|
summary: Ensure that the kvm interface works.
details: |
The kvm interface allows read/write access to kvm.
prepare: |
"$TESTSTOOLS"/snaps-state install-local test-snapd-kvm
"$TESTSTOOLS"/fs-state mock-file /dev/kvm
if os.query is-fedora; then
ausearch --checkpoint stamp -m AVC || true
fi
restore: |
"$TESTSTOOLS"/fs-state restore-file /dev/kvm
execute: |
echo "The interface is not connected by default"
snap interfaces -i kvm | MATCH '^- +test-snapd-kvm:kvm'
echo "When the interface is connected"
snap connect test-snapd-kvm:kvm
echo "The module file is present"
test -s /etc/modules-load.d/snap.test-snapd-kvm.conf
echo "Then the snap is able to read/write on /dev/kvm"
test-snapd-kvm.with-kvm-plug -c "cat /dev/kvm"
test-snapd-kvm.with-kvm-plug -c "echo 'test' >> /dev/kvm"
if [ "$(snap debug confinement)" = partial ] ; then
exit 0
fi
echo "When the plug is disconnected"
snap disconnect test-snapd-kvm:kvm
echo "Then the snap is not able to read the kvm device"
if test-snapd-kvm.with-kvm-plug -c "cat /dev/kvm" 2> call.error; then
echo "Expected permission error accessing to kvm device"
exit 1
fi
MATCH "Permission denied" < call.error
if os.query is-fedora; then
# make sure there are no selinux denials on fedora
ausearch -i --checkpoint stamp --start checkpoint -m AVC 2>&1 | MATCH 'no matches'
fi
|