Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions tests/main/sru-validation-check/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ execute: |
not tests.info is-reexec-in-use
/usr/bin/env SNAPD_DEBUG=1 snap list 2>&1 | MATCH "DEBUG: re-exec disabled by user"

# shellcheck disable=SC2034
SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
# shellcheck disable=SC2153
/usr/bin/env SNAPD_DEBUG=1 SNAP_REEXEC=1 snap list 2>&1 | MATCH "DEBUG: restarting into \"$SNAP_MOUNT_DIR/snapd/current/usr/bin/snap\""
/usr/bin/env SNAPD_DEBUG=1 SNAP_REEXEC=1 snap list 2>&1 | MATCH 'DEBUG: restarting into "/snap/snapd/'

# Check the snap version has the proper value expected when the snapd snap is not being used
. /etc/os-release
Expand Down
14 changes: 14 additions & 0 deletions tests/regression/lp-2161982/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
summary: Test the vsock-guest interface for confined access to /dev/vsock and AF_VSOCK sockets

details: |
LP: #2161982. Test the vsock-guest interface for confined access to /dev/vsock and AF_VSOCK sockets.

prepare: |
"$TESTSTOOLS"/snaps-state install-local vsock-guest-test

execute: |
snap connect vsock-guest-test:vsock-guest
vsock-guest-test.test

snap disconnect vsock-guest-test:vsock-guest
not vsock-guest-test.test
36 changes: 36 additions & 0 deletions tests/regression/lp-2161982/vsock-guest-test/bin/vsock-guest-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -u

failed=0

# Check access to /dev/vsock
if [[ -e /dev/vsock ]]; then
if (exec 3<>/dev/vsock) 2>/dev/null; then
echo "PASS: opened /dev/vsock successfully"
else
echo "FAIL: cannot open /dev/vsock"
failed=1
fi
else
echo "SKIP: /dev/vsock does not exist"
fi

# Check whether AF_VSOCK sockets can be created
if python3 -c '
import socket
with socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM):
pass
'; then
echo "PASS: created AF_VSOCK SOCK_STREAM socket successfully"
else
echo "FAIL: cannot create AF_VSOCK socket"
failed=1
fi

if [[ "$failed" -eq 0 ]]; then
echo "PASS: all vsock checks passed"
exit 0
else
echo "FAIL: one or more vsock checks failed"
exit 1
fi
18 changes: 18 additions & 0 deletions tests/regression/lp-2161982/vsock-guest-test/meta/snap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: vsock-guest-test
version: '0.1'
summary: Test snapd vsock-guest interface
description: |
Tests confined access to /dev/vsock and AF_VSOCK sockets.
confinement: strict
grade: devel
base: core24

apps:
test:
command: bin/vsock-guest-test
plugs:
- vsock-guest

plugs:
vsock-guest:
interface: vsock-guest
Loading