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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
summary: Check for cli errors installing snaps
details: |
Check error messages and exit codes returned by various failing snap
commands (e.g., unauthenticated installs, unknown snap names, etc).
systems: [-ubuntu-core-*]
environment:
SNAP_NAME: test-snapd-tools
# Ensure that running purely from the deb (without re-exec) works
# correctly
SNAP_REEXEC/noreexec: 0
SNAP_REEXEC/withreexec: 1
prepare: |
if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-from-archive; then
tests.exec skip-test "No need to test when the snapd pkg is from the repository and reexec is disabled" && exit 0
fi
echo "Given a snap with a failing command is installed"
"$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME"
execute: |
tests.exec is-skipped && exit 0
echo "Install unexisting snap prints error"
if snap install unexisting.canonical; then
echo "Installing unexisting snap should fail"
exit 1
fi
echo "Install without snap name shows error"
if snap install; then
echo "Installing without snap name should fail"
exit 1
fi
echo "Install points to sudo when not authenticated"
if su - -c "snap install $SNAP_NAME" test 2>install.output; then
echo "Unauthenticated install should fail"
exit 1
fi
MATCH "try with sudo" < install.output
echo "Calling a failing command from a snap should fail"
if test-snapd-tools.fail; then
echo "Failing snap commands should keep failing after installed"
exit 1
fi
echo "Install a snap that is already installed shows a message"
echo "but does "exit 0" (LP: #1622782)"
snap install "$SNAP_NAME" 2> stderr.out
MATCH "snap \"$SNAP_NAME\" is already installed" < stderr.out
echo "Install ubuntu-core"
if snap install ubuntu-core 2> stderr.out; then
echo "Installing ubuntu-core should fail"
exit 1
fi
MATCH 'cannot install "ubuntu-core", please use "core" instead' < stderr.out
echo "Install a snap that is only available in the edge channel"
if snap install test-snapd-just-edge 2>stderr.out; then
echo "Installing test-snapd-just-edge should fail but did not"
exit 1
fi
MATCH 'error: snap "test-snapd-just-edge" is not available on stable but' < stderr.out
MATCH "snap install --edge test-snapd-just-edge" < stderr.out
echo "Install a snap not available for the given architecture"
if os.query is-pc-amd64; then
if snap install pi2-kernel 2>stderr.out; then
echo "Installing pi2-kernel should fail on amd64 systems but did not"
exit 1
fi
MATCH 'error: snap "pi2-kernel" is not available on stable for this architecture' < stderr.out
fi
echo "Install a snap with suspicious characters in its name"
if snap install atom ––classic 2>stderr.out; then
echo "snap install atom ––classic should have failed but did not"
exit 1
fi
MATCH 'characters that look like dashes but are not' < stderr.out
if "$TESTSTOOLS"/snaps-state is-confinement-supported classic; then
echo "Installing a strict snap in classic works but --classic is ignored"
snap install --classic test-snapd-busybox-static 2>stderr.out
#shellcheck disable=SC2002
cat stderr.out | tr '\n' ' ' | tr -s ' ' | MATCH 'Warning: flag --classic ignored for strictly confined snap test-snapd-busybox-static'
fi
|