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
|
summary: Check the debug command migrate-home migrates snaps' homes
details: |
The `snap debug migrate-home` command can be used to migrate snaps'
directory to ~/Snap. This test verifies that a snap with home in
$HOME/foo is migrated to "$HOME"/Snap, and the snap's environment
variables and AppArmor rules are correct after the migration.
prepare: |
"$TESTSTOOLS"/snaps-state install-local "test-snapd-tools"
"$TESTSTOOLS"/snaps-state install-local basic
restore: |
snap unset system experimental.move-snap-home-dir
snap remove --purge basic
snap remove --purge test-snapd-tools
execute: |
echo "Check that migrate home doesn't work without setting the experimental flag"
if got=$(snap debug migrate-home test-snapd-tools 2>&1); then
echo 'Calling "snap debug migrate-home" without setting "experimental.move-snap-home-dir" should fail'
exit 1
fi
#shellcheck disable=SC2086
echo $got | MATCH 'error: cannot migrate to ~/Snap: flag "experimental.move-snap-home-dir" is not set'
echo "Check that migrate home migrates the data under SNAP_USER_DATA"
snap set system experimental.move-snap-home-dir=true
#shellcheck disable=SC2016
test-snapd-tools.cmd sh -c 'echo foo > $HOME/foo'
MATCH "foo" < "$HOME/snap/test-snapd-tools/current/foo"
not test -e "$HOME"/Snap
snap debug migrate-home test-snapd-tools basic
MATCH "foo" < "$HOME/Snap/test-snapd-tools/foo"
echo "Check that the snap's environment variables and AppArmor rules are correct"
test-snapd-tools.env | MATCH "HOME=$HOME/Snap/test-snapd-tools"
#shellcheck disable=SC2016
test-snapd-tools.cmd sh -c 'echo "bar" > $HOME/bar'
MATCH "bar" < "$HOME/Snap/test-snapd-tools/bar"
|