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
|
summary: Checks for snap exit codes
details: |
Snap command return different exit codes on error.
This test verifies the exit codes in the following scenarios:
1. snap command with unknown command return exit code 64
2. snap command with unknown flag return exit code 64
3. snap command with broken mksquashfs returns exit code 20
systems: [ubuntu-1*, ubuntu-2*]
execute: |
echo "snap command with unknown command return exit code 64"
set +e
snap unknown-command
RET=$?
set -e
test "$RET" -eq 64
echo "snap command with unknown flag return exit code 64"
set +e
snap pack --unknown-option
RET=$?
set -e
test "$RET" -eq 64
echo "snap command with broken mksquashfs returns exit code 20"
command_found=0
for b in /usr/bin/mksquashfs /snap/core/current/usr/bin/mksquashfs /snap/snapd/current/usr/bin/mksquashfs; do
if [ -f "$b" ]; then
command_found=$((command_found + 1))
mount -o bind /bin/false "$b"
tests.cleanup defer umount "$b"
fi
done
# make sure we found at least two of the commands
if (( command_found < 2 )); then
echo "should have mocked at least 2 commands"
exit 1
fi
set +e
snap pack "$TESTSLIB/snaps/test-snapd-sh"
RET=$?
set -e
test "$RET" -eq 20
|