mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
88 lines
3.2 KiB
YAML
88 lines
3.2 KiB
YAML
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: |
|
||
echo "Given a snap with a failing command is installed"
|
||
"$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME"
|
||
|
||
execute: |
|
||
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
|