diff options
| author | Michael Vogt <mvo@ubuntu.com> | 2016-09-20 09:06:29 +0200 |
|---|---|---|
| committer | Michael Vogt <mvo@ubuntu.com> | 2016-09-20 09:10:18 +0200 |
| commit | faabeef37f77c2d85025ab901067bb1b4ebe296d (patch) | |
| tree | 5f530f442b5e3e95e3e618815a9d5b6a6f6f24f1 /tests | |
| parent | 953e7732c6545419636f95c77d2e3fb6d9f5f8df (diff) | |
| parent | 86d128fd04c1b40a805f88d24c8bda39ff28848c (diff) | |
Merge remote-tracking branch 'upstream/master' into feature/use-in-tree-snap-exec
Diffstat (limited to 'tests')
39 files changed, 624 insertions, 154 deletions
diff --git a/tests/lib/assertions/developer1.account-key b/tests/lib/assertions/developer1.account-key index 57c256344d..302d42629a 100644 --- a/tests/lib/assertions/developer1.account-key +++ b/tests/lib/assertions/developer1.account-key @@ -2,8 +2,8 @@ type: account-key authority-id: testrootorg public-key-sha3-384: EAD4DbLxK_kn0gzNCXOs3kd6DeMU3f-L6BEsSEuJGBqCORR0gXkdDxMbOm11mRFu account-id: developer1 +name: default since: 2016-08-19T15:49:45+02:00 -timestamp: 2016-08-11T18:46:02+02:00 body-length: 717 sign-key-sha3-384: XCIC_Wvj9_hiAt0b10sDon74oGr3a6xGODkMZqrj63ZzNYUD5N87-ojjPoeN7f1Y @@ -18,13 +18,13 @@ Yy04Sf9LI148vJMsYenonkoWejWdMi8iCUTeaZydHJEUBU/RbNFLjCWa6NIUe9bfZgLiOOZkps54 +/AL078ri/tGjo/5UGvezSmwrEoWJyqrJt2M69N2oVDLJcHeo2bUYPtFC2Kfb2je58JrJ+llifdg rAsxbnHXiXyVimUAEQEAAQ== -AcLBUgQAAQoABgUCV7cOeQAAFqUQAE90GSklMLMqwudOcx2Za0xVHoNdmcE4yMI4gMdtzMM+I0EY -rosU5XtObDSWog+7u1ojExWAEm01KwP4QGYJunHPYOKWb/72hS1u/xj3e3EUx04cwQw/MfhS+C5i -D1FPtHe/ikaFBiM5grHhGFbcPWCZhzzSsDCEVsy59UnS4AR4I0ADFvLGJUgSRr+FIf8EYatGAxib -u8gWHBnxhfgZ/Z7CWDEyZkFmPGoJ7NsJBxXpJ3w/LPvEvFpT03zdn3abIDvXEq0zpwoPper2+xUD -RDvJYrNswxs7nWsZKIwLazTw470US5nEYyQ9JoVXilWUXXY1HukILIyzB0kMV1ncPo4ru982K0rf -0JPHV8qpOBn5vZyH/ZZMl9KarlQbkG+bYhFmugD83f7quF/AwFUe/oeMtj7BiDwEV5BxENoFu8SR -wbuKUswCaWNGhwnJ8l4pNBg5mnkleLVUtOCVVxsWP84lvAGlj9zeQB8G17GbzdAf5SiSkWNq4tMV -b1UIoWjYvPb4+GPgo5zaqXWaGeiU2onU1UCRNE3UxIHim8u88mWAtxV8PvKqRkQC9ecJLQtI0nD4 -ubwvQeWP793+3nU47um7Dfs7CFD9aLjsgvshGSaBW90GQpK2WNL9hR5aMCzuL8uXXaKpvRKMGM1X -hlym2K7K9yVpIumDPAYV8rmF9hD3 +AcLBXAQAAQoABgUCV9AFCQAKCRDdoJRfvd5vjf8OD/4nfa6dj+39OyxfBJYXCUgFj2qCPYUm66j+ +bwNY6YD96ZP4QKx4+Vhqrmu2RWhUISqHhJH/SPKxfil9nocWE16knSgE4HFUnb2omMBIq+wU1ThV +JFvxdWXt9KFMKBlYeKr1BOoXuPJlQGf8PnsTM1oCqrzAyfGAbSFmsVrqzf8ujyQf551f5RovdSLX +dqEZX1tYiyoIY9FJNGL5A74Q8CC9V1yJEPtEcQDEovoa368fD2S3rvyBYtaHnQ3tkrvZgZCPe0lJ +4FwtljgGuAALAQPcZOepJRnNP60/eeYJGZPlQwwjD7akxy/FrDIjbqW/HRxHcroyKHGnMSD+DX5D +GPSxClb1ChI+RqyNZJzubIh11lnLmidYsonNjTYZRmMDPn/iIo2Goso8hYKoF8ztJeD42otdLrMN +omV7qZvf2bHZ5ADUPsK468CNOPnjQYL0AC5D01C+QxrkPfK8aJQiK0/rYcgCouSetzJHl0JrC0Fv +6IfwpPxXz0/KHqDwsC20yGhmyCS8RjqzTX1pkn/hPeHD7qNJBP+4oXfyGdaEu+vsiAWIkgasv3Um +pePncPNiBxTBHJEyYeRK6w5uy2M9iUe/QLT/1cHEYgsQDDr2mSV8rdpV9pn5JcyfiCL0nhIMPbTU +DcIT7mkb48ulFZpKyVYubC5yDPGfaK621eRS5UfO1Q== diff --git a/tests/lib/assertions/testrootorg-store.account-key b/tests/lib/assertions/testrootorg-store.account-key index f3b0827f60..d04be39745 100644 --- a/tests/lib/assertions/testrootorg-store.account-key +++ b/tests/lib/assertions/testrootorg-store.account-key @@ -2,6 +2,7 @@ type: account-key authority-id: testrootorg public-key-sha3-384: XCIC_Wvj9_hiAt0b10sDon74oGr3a6xGODkMZqrj63ZzNYUD5N87-ojjPoeN7f1Y account-id: testrootorg +name: test-store since: 2016-08-11T18:42:22+02:00 body-length: 717 sign-key-sha3-384: hIedp1AvrWlcDI4uS_qjoFLzjKl5enu4G2FYJpgB3Pj-tUzGlTQBxMBsBmi-tnJR @@ -17,13 +18,13 @@ iAIwA4DpGMmFJ26maqVzJuiLvicri2FR/sJaSA24N8HbGne3gSS7WrSQS+jKe3IZPVy64NCoGvrW o/HvTeqsIfihKPEpXm8QVtjNhtkVn3RdIUgOaNWyAfnZ4dW1TVIATe+OHDw2TNyImTjE0x75nL6B 1/Rrn+9VP9Swhv8AEQEAAQ== -AcLBUgQAAQoABgUCV6yq7gAAhaYQAMIVYhta2uUvm5PXApdXmZFWr+iZYfkAZW8PEMOsuYVHbDoH -oA7dpO0EwZXl/mCgGjNNc4nUmqQLBiIwwrcnmcYSRl2Xz+u+ssou4YMueXOD2tHo1N2J39SKpS72 -VqQsnF77Qylgdp2j7Q9lJrU0qHz0M195OJXNSppfdHYeWptfsO02cApPobU9s6KT5VggVg1ushNM -1u97A+uvoClfJ53PPafC0kr1+vwFVPj+mko4gc7sIB42xwz+YeR47CgSaT8i8K1u5ouaHCNxe61+ -siQxAdIOv+hOAWAOMoOWZjxh5K7J9A1Dc18EMyggf716IUCBtkvDKfwcXFcoic1X6EVPO5kNhlh7 -aLFS8UVsBPaZKnJm3ZFudhYQUmZt22ntslgGrq9+NBeh9i6nswUPKdj2idHkyQsjnYgYyTpEH/xh -sBqkqkedPkUtn+tP5dS4TP/L3Xq/q2tQbA4+gNVbZXIo8g8wfpsP8+sIOnEV5UcoxaO3oI3YUJrN -oFGmC7No802XKG1ZNHhBtMSaan0pafWrBrHn+axT9Jbl/1B73TYg3zQWOpDuSpH3SU+gXJ/eukUb -LvC8UWZM9YEhu/ZINSvSDQzvobV/NVrHWEJBXxrc3CwseFDgQq+Yz/CFGud79z2mS8lNHKSqQdFK -3Bd0HG1HheYcX0nGIva0KIG0Sgf/ +AcLBXAQAAQoABgUCV866kwAKCRBMcZp594FxpHWHD/9AaZXqyT/Zsmq/VzmAMpd9JvCH4PHQKtAP +bXfP2Dnpa2wk2wuzQuSWunR8NDRyVh/aNVeTEZ9dFm/B8LR+U2O4rsHmFSeicmsTmo9u/HouRdEU +zeSc6cbAxMPpfNSjr5J+URLjGRT6oX5fEBmRPx/OC9pEIScMx7uKmTKEnuyMzLRNN/6HiGWKrFCo +nJdKkwRXrkCHyXWAOv1GumT7NDuyFcjAqt/UdHliTZkDBImKOsBmBVXMUjg7HCSS2uq/5WjStJ+B +JHQ4GSsXBvVINs6BncNWcvV6mCQ73D57MzGhqo997Zb4tSrn7UNGWK7GLCzV3e/pFlG7pw6HbgnQ ++rxU2Oj/TPVw0tcnUiRl2ttKpm+nua0Cl+MD+Gx0KXLAVp0ZGOQ9yGyP9AePFzcOR8SlRIgxi0EI +iJkSeYilqoKo3AJhnICRiqvAca2TGJoiJUryEgZ8jbTOElfaF2p+y0xvXGlWbKZm1gzGyvFM5fV5 +hJTlp/am+2uVn6U8wPACir4PrbuXYo7L4MIXww2OEO0ruBIaLARbc5IutSWmw6AEYQUxtsa9bdHV +Zin7LGbEj6lZm8GycWQwh4B6Vnt6dJRIyPc/9G7uM8Ds/2Wa7+yAxhiPqm8DwlbOYh1npw4X4TLD +IMGnTv5N3zllI+Xz4rqJzNTzEbvOIcrqWxCedQe79A== diff --git a/tests/lib/fakestore/refresh/refresh.go b/tests/lib/fakestore/refresh/refresh.go index e571d0a46a..ce7d15cbba 100644 --- a/tests/lib/fakestore/refresh/refresh.go +++ b/tests/lib/fakestore/refresh/refresh.go @@ -30,6 +30,7 @@ import ( "github.com/snapcore/snapd/asserts" "github.com/snapcore/snapd/asserts/assertstest" + "github.com/snapcore/snapd/asserts/snapasserts" "github.com/snapcore/snapd/asserts/sysdb" "github.com/snapcore/snapd/asserts/systestkeys" "github.com/snapcore/snapd/dirs" @@ -85,7 +86,7 @@ func writeAssert(a asserts.Assertion, targetDir string) error { return ioutil.WriteFile(filepath.Join(targetDir, "asserts", fn), asserts.Encode(a), 0644) } -func makeFakeRefreshForSnap(snap, targetDir string, db *asserts.Database, f *asserts.Fetcher) error { +func makeFakeRefreshForSnap(snap, targetDir string, db *asserts.Database, f asserts.Fetcher) error { // make a fake update snap in /var/tmp (which is not a tempfs) fakeUpdateDir, err := ioutil.TempDir("/var/tmp", "snap-build-") if err != nil { @@ -198,11 +199,8 @@ func buildSnap(snapDir, targetDir string) (*info, error) { return &info{digest: newDigest, size: size}, nil } -func copySnapAsserts(info *info, f *asserts.Fetcher) error { - return f.Fetch(&asserts.Ref{ - Type: asserts.SnapRevisionType, - PrimaryKey: []string{info.digest}, - }) +func copySnapAsserts(info *info, f asserts.Fetcher) error { + return snapasserts.FetchSnapAssertions(f, info.digest) } func makeNewSnapRevision(orig, new *info, targetDir string, db *asserts.Database) error { diff --git a/tests/lib/fakestore/store/store.go b/tests/lib/fakestore/store/store.go index 7109633ed7..a92c5335be 100644 --- a/tests/lib/fakestore/store/store.go +++ b/tests/lib/fakestore/store/store.go @@ -164,7 +164,7 @@ var errInfo = errors.New("cannot get info") func snapEssentialInfo(w http.ResponseWriter, fn, snapID string, bs asserts.Backstore) (*essentialInfo, error) { snapFile, err := snap.Open(fn) if err != nil { - http.Error(w, fmt.Sprintf("can not read: %v: %v", fn, err), http.StatusBadRequest) + http.Error(w, fmt.Sprintf("cannot read: %v: %v", fn, err), http.StatusBadRequest) return nil, errInfo } @@ -282,7 +282,7 @@ func (s *Store) detailsEndpoint(w http.ResponseWriter, req *http.Request) { // should look nice out, err := json.MarshalIndent(details, "", " ") if err != nil { - http.Error(w, fmt.Sprintf("can't marshal: %v: %v", details, err), http.StatusBadRequest) + http.Error(w, fmt.Sprintf("cannot marshal: %v: %v", details, err), http.StatusBadRequest) return } w.Write(out) @@ -343,7 +343,7 @@ func (s *Store) bulkEndpoint(w http.ResponseWriter, req *http.Request) { decoder := json.NewDecoder(req.Body) if err := decoder.Decode(&pkgs); err != nil { - http.Error(w, fmt.Sprintf("can't decode request body: %v", err), http.StatusBadRequest) + http.Error(w, fmt.Sprintf("cannot decode request body: %v", err), http.StatusBadRequest) return } diff --git a/tests/lib/fakestore/store/store_test.go b/tests/lib/fakestore/store/store_test.go index d452766305..327fc79d48 100644 --- a/tests/lib/fakestore/store/store_test.go +++ b/tests/lib/fakestore/store/store_test.go @@ -1,5 +1,4 @@ // -*- Mode: Go; indent-tabs-mode: t -*- -// +build !excludeintegration /* * Copyright (C) 2014-2015 Canonical Ltd diff --git a/tests/lib/gadget.sh b/tests/lib/gadget.sh new file mode 100644 index 0000000000..6e8a0b04d5 --- /dev/null +++ b/tests/lib/gadget.sh @@ -0,0 +1,4 @@ +#!/bin/sh +get_gadget_name(){ + snap list | grep '^pc \|^pi2 \|^pi3 \|^dragonboard ' | head -n 1 | cut -d ' ' -f 1 +} diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index 7814db9425..7cdff1708a 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -9,7 +9,7 @@ update_core_snap_with_snap_exec_snapctl() { # First of all, unmount the core core="$(realpath /snap/ubuntu-core/current)" - snap="$(mount | grep "$core" | awk '{print $1}')" + snap="$(mount | grep " $core" | awk '{print $1}')" umount "$core" # Now unpack the core, inject the new snap-exec and snapctl into it, and @@ -47,6 +47,14 @@ prepare_classic() { snap install --candidate ubuntu-core snap list | grep core + echo "Ensure that the grub-editenv list output is empty on classic" + output=$(grub-editenv list) + if [ -n "$output" ]; then + echo "Expected empty grub environment, got:" + echo "$output" + exit 1 + fi + systemctl stop snapd.service snapd.socket update_core_snap_with_snap_exec_snapctl @@ -70,15 +78,11 @@ setup_reflash_magic() { # install the stuff we need apt install -y kpartx busybox-static apt install -y ${SPREAD_PATH}/../snapd_*.deb - + snap install --edge ubuntu-core - # install special u-d-f - apt install -y bzr git - export GOPATH=/tmp/go - mkdir -p $GOPATH/src/launchpad.net/ - ln -s $GOPATH/src/launchpad.net/~mvo/goget-ubuntu-touch/minimal-first-boot/ $GOPATH/src/launchpad.net/goget-ubuntu-touch - go get -insecure -u launchpad.net/~mvo/goget-ubuntu-touch/minimal-first-boot/ubuntu-device-flash + # install ubuntu-image + snap install --devmode --edge ubuntu-image # needs to be under /home because ubuntu-device-flash # uses snap-confine and that will hide parts of the hostfs @@ -103,7 +107,7 @@ setup_reflash_magic() { if [ -e /.spread.yaml ]; then cp -av /.spread.yaml $UNPACKD fi - + # we need the test user in the image chroot $UNPACKD adduser --quiet --no-create-home --disabled-password --gecos '' test @@ -114,7 +118,7 @@ setup_reflash_magic() { # the image # unpack our freshly build snapd into the new core snap dpkg-deb -x ${SPREAD_PATH}/../snapd_*.deb $UNPACKD - + # build new core snap for the image snapbuild $UNPACKD $IMAGE_HOME @@ -145,14 +149,21 @@ EOF # FIXME: how to test store updated of ubuntu-core with sideloaded snap? IMAGE=all-snap-amd64.img - /tmp/go/bin/ubuntu-device-flash core 16 $IMAGE_HOME/pc.model --channel edge --install snapweb --install $IMAGE_HOME/ubuntu-core_*.snap --output $IMAGE_HOME/$IMAGE + + # ensure that ubuntu-image is using our test-build of snapd with the + # test keys and not the bundled version of usr/bin/snap from the snap. + # Note that we can not put it into /usr/bin as '/usr' is different + # when the snap uses confinement. + cp /usr/bin/snap $IMAGE_HOME + export UBUNTU_IMAGE_SNAP_CMD=$IMAGE_HOME/snap + /snap/bin/ubuntu-image -w $IMAGE_HOME $IMAGE_HOME/pc.model --channel edge --extra-snaps $IMAGE_HOME/ubuntu-core_*.snap --output $IMAGE_HOME/$IMAGE # mount fresh image and add all our SPREAD_PROJECT data kpartx -avs $IMAGE_HOME/$IMAGE # FIXME: hardcoded mapper location, parse from kpartx - mount /dev/mapper/loop1p3 /mnt + mount /dev/mapper/loop2p3 /mnt mkdir -p /mnt/user-data/ - cp -avr /home/gopath /mnt/user-data/ + cp -ar /home/gopath /mnt/user-data/ # create test user home dir mkdir -p /mnt/user-data/test @@ -178,10 +189,10 @@ EOF [Unit] StartLimitInterval=0 EOF - + umount /mnt kpartx -d $IMAGE_HOME/$IMAGE - + # the reflash magic # FIXME: ideally in initrd, but this is good enough for now cat > $IMAGE_HOME/reflash.sh << EOF @@ -227,7 +238,9 @@ prepare_all_snap() { fi echo "Ensure fundamental snaps are still present" - for name in pc pc-kernel ubuntu-core; do + . $TESTSLIB/gadget.sh + gadget_name=$(get_gadget_name) + for name in $gadget_name ${gadget_name}-kernel ubuntu-core; do if ! snap list | grep $name; then echo "Not all fundamental snaps are available, all-snap image not valid" echo "Currently installed snaps" @@ -237,6 +250,12 @@ prepare_all_snap() { done echo "Kernel has a store revision" - snap list|grep ^pc-kernel|grep -E " [0-9]+\s+canonical" -} + snap list|grep ^${gadget_name}-kernel|grep -E " [0-9]+\s+canonical" + # Snapshot the fresh state + if [ ! -f $SPREAD_PATH/snapd-state.tar.gz ]; then + systemctl stop snapd.service snapd.socket + tar czf $SPREAD_PATH/snapd-state.tar.gz /var/lib/snapd + systemctl start snapd.socket + fi +} diff --git a/tests/lib/reset.sh b/tests/lib/reset.sh index 4761f5a4f1..ef34eb500f 100755 --- a/tests/lib/reset.sh +++ b/tests/lib/reset.sh @@ -13,9 +13,9 @@ reset_classic() { ls -lR /snap/* /var/snap/* exit 1 fi - + rm -f /tmp/ubuntu-core* - + if [ "$1" = "--reuse-core" ]; then $(cd / && tar xzf $SPREAD_PATH/snapd-state.tar.gz) mounts="$(systemctl list-unit-files | grep '^snap[-.].*\.mount' | cut -f1 -d ' ')" @@ -32,12 +32,21 @@ reset_classic() { } reset_all_snap() { + # remove all leftover snaps + . $TESTSLIB/gadget.sh + gadget_name=$(get_gadget_name) for snap in $(ls /snap); do - if [ "$snap" = "bin" ] || [ "$snap" = "pc" ] || [ "$snap" = "pc-kernel" ] || [ "$snap" = "ubuntu-core" ]; then + if [ "$snap" = "bin" ] || [ "$snap" = "$gadget_name" ] || [ "$snap" = "${gadget_name}-kernel" ] || [ "$snap" = "ubuntu-core" ]; then continue fi snap remove $snap done + + # ensure we have the same state as initially + systemctl stop snapd.service snapd.socket + $(cd / && tar xzf $SPREAD_PATH/snapd-state.tar.gz) + rm -rf /root/.snap + systemctl start snapd.service snapd.socket } if [ "$SPREAD_SYSTEM" = "ubuntu-core-16-64" ]; then diff --git a/tests/lib/snaps/failing-config-hooks/meta/hooks/apply-config b/tests/lib/snaps/failing-config-hooks/meta/hooks/apply-config new file mode 100755 index 0000000000..6303e3be58 --- /dev/null +++ b/tests/lib/snaps/failing-config-hooks/meta/hooks/apply-config @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "apply-config hook" +exit 1 diff --git a/tests/lib/snaps/failing-config-hooks/meta/hooks/check-config b/tests/lib/snaps/failing-config-hooks/meta/hooks/check-config new file mode 100755 index 0000000000..c2fb93a811 --- /dev/null +++ b/tests/lib/snaps/failing-config-hooks/meta/hooks/check-config @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "check-config hook" +exit 1 diff --git a/tests/lib/snaps/failing-config-hooks/meta/icon.png b/tests/lib/snaps/failing-config-hooks/meta/icon.png Binary files differnew file mode 100644 index 0000000000..1ec92f1241 --- /dev/null +++ b/tests/lib/snaps/failing-config-hooks/meta/icon.png diff --git a/tests/lib/snaps/failing-config-hooks/meta/snap.yaml b/tests/lib/snaps/failing-config-hooks/meta/snap.yaml new file mode 100644 index 0000000000..92c118799f --- /dev/null +++ b/tests/lib/snaps/failing-config-hooks/meta/snap.yaml @@ -0,0 +1,2 @@ +name: failing-config-hooks +version: 1.0 diff --git a/tests/lib/snaps/locale-control-consumer/bin/get b/tests/lib/snaps/locale-control-consumer/bin/get index d82fdad948..ee4c740c66 100755 --- a/tests/lib/snaps/locale-control-consumer/bin/get +++ b/tests/lib/snaps/locale-control-consumer/bin/get @@ -4,11 +4,11 @@ import subprocess import sys def run(key): + prefix = key+'=' with open('/etc/default/locale') as input_data: for line in input_data: - if key in line: - parts=line.split('=') - print(parts[1].replace('"', ''), end='') + if line.startswith(prefix): + print(line[len(prefix):].strip().strip('"'), end='') if __name__ == '__main__': sys.exit(run(sys.argv[1])) diff --git a/tests/lib/snaps/test-snapd-upower-observe-consumer/snapcraft.yaml b/tests/lib/snaps/test-snapd-upower-observe-consumer/snapcraft.yaml new file mode 100644 index 0000000000..61db7f2837 --- /dev/null +++ b/tests/lib/snaps/test-snapd-upower-observe-consumer/snapcraft.yaml @@ -0,0 +1,14 @@ +name: test-snapd-upower-observe-consumer +version: 1.0 +summary: Basic upower-observe consumer snap +description: A basic snap declaring a plug on upower-observe + +apps: + upower: + command: upower + plugs: [upower-observe] + +parts: + upower: + plugin: nil + stage-packages: [upower] diff --git a/tests/lib/store.sh b/tests/lib/store.sh index 500281d3ce..54200ca4cb 100644 --- a/tests/lib/store.sh +++ b/tests/lib/store.sh @@ -52,8 +52,6 @@ setup_store(){ local store_type=$1 local top_dir=$2 if [ "$store_type" = "fake" ]; then - setup_fake_store $top_dir - elif [ "$store_type" = "fake-w-assert-fallback" ]; then setup_fake_store $top_dir -assert-fallback else if [ "$store_type" = "staging" ]; then diff --git a/tests/main/ack/developer1.account b/tests/main/ack/developer1.account deleted file mode 100644 index 65e9c49180..0000000000 --- a/tests/main/ack/developer1.account +++ /dev/null @@ -1,19 +0,0 @@ -type: account -authority-id: testrootorg -account-id: developer1 -display-name: Developer 1 -timestamp: 2016-08-11T18:46:02+02:00 -username: developer1 -validation: unproven -sign-key-sha3-384: XCIC_Wvj9_hiAt0b10sDon74oGr3a6xGODkMZqrj63ZzNYUD5N87-ojjPoeN7f1Y - -AcLBUgQAAQoABgUCV6yrygAAf0IQAFhUje+lWt6c2bmjUg17vo3tdowkpNYvXLma0ajCphULCmGg -3qtS8sVCJa1rFXOeKr3whFc/iheFbZJyQh2lsIQsRE0Z587uxFLbs5ua0FU0yzU7va03PdfBIK9o -BEC8uXdCx3yFlijnDibC3D6daqB/PkUUM+WT5ypvp4b4l/IY6Vf0s2p5IzYCToBcXzdXOuL6e8t8 -d2kC2q1P5WX+fK20UjSeGHSanR6sfr4Tw+FNgv/MtmaBAkhAbIHMKTOZaKd7sEjT0QLJVYRdWlTp -dSpaJRqzTE2v7Ql7RjJtFO8+QKnjzNGMbRYj9yX9meBBeT+iDTqH4UrvyRBOmLlKVAkt8mXqjwWj -IfuA+ISWb8Qc/aah/DO6wONt7oAD6AkXXrCFtinHyQCutD5/XB63eCeSJAfvxD2Nbx9xEWjwu4nE -6D6a5URpU4Kzo05jk/OnCnjMHYgW/grn9wRt4yXAXWkENQfcAYH6ZZV4VTJqA+2fAO7q9v5WryA4 -z1WcX7073ORAFCviiUFEoX/3eUfsyom5AF45OKxs8bm8jfRemnfUjRrPbpV+auBZ+DG7NDKFAOVv -zKKivSNac125adAcC3Xg1783eUMpDStylIOxziVYDB0e6nR4ekiccnvLv5GpiEOG0ZGa4sUYI6+V -hWeNg9t8ydjCleMJcHt5WrgcBQuw diff --git a/tests/main/ack/task.yaml b/tests/main/ack/task.yaml index e4fc41af1b..b655ae3b26 100644 --- a/tests/main/ack/task.yaml +++ b/tests/main/ack/task.yaml @@ -11,14 +11,14 @@ prepare: | systemctl start snapd.socket snapd.service execute: | echo "Ack when missing matching key fails" - ! snap ack developer1.account + ! snap ack cp $TESTSLIB/assertions/developer1.account echo "Ack the test store key" - snap ack testrootorg-store.account-key + snap ack $TESTSLIB/assertions/testrootorg-store.account-key snap known account-key public-key-sha3-384=XCIC_Wvj9_hiAt0b10sDon74oGr3a6xGODkMZqrj63ZzNYUD5N87-ojjPoeN7f1Y | grep "^sign-key-sha3-384: hIedp1AvrWlcDI4uS_qjoFLzjKl5enu4G2FYJpgB3Pj-tUzGlTQBxMBsBmi-tnJR$" echo "Ack a developer account signed by that" - snap ack developer1.account + snap ack $TESTSLIB/assertions/developer1.account snap known account account-id=developer1|grep "^username: developer1$" diff --git a/tests/main/ack/testrootorg-store.account-key b/tests/main/ack/testrootorg-store.account-key deleted file mode 100644 index f3b0827f60..0000000000 --- a/tests/main/ack/testrootorg-store.account-key +++ /dev/null @@ -1,29 +0,0 @@ -type: account-key -authority-id: testrootorg -public-key-sha3-384: XCIC_Wvj9_hiAt0b10sDon74oGr3a6xGODkMZqrj63ZzNYUD5N87-ojjPoeN7f1Y -account-id: testrootorg -since: 2016-08-11T18:42:22+02:00 -body-length: 717 -sign-key-sha3-384: hIedp1AvrWlcDI4uS_qjoFLzjKl5enu4G2FYJpgB3Pj-tUzGlTQBxMBsBmi-tnJR - -AcbBTQRWhcGAARAAmJqmZvsS58INTs+UQ+jfo836vBS5tkU/hk7c0huZe3So2gc9kaJvjkjhZ6g0 -0/kGoidw3i2WkdMEp+JtvU9Ztfeu/Nn/OqkSc3Ap1KAmqL4OllPVII8H69w2zqvmo+PcqH0SvHAV -EoOC2ToXP0wEHnAZsbVu56AKrwpHDppPEIvaS6glrsEX1AXpOeMHZLVRtfsBB6dlLXuula1UrSAL -RFCEjXtqXqOto5Vo9C8p63lLBy19ifz4OriWAGBqZvFdItmo8VIPXSDdgMMHBlu2MSNJHVfo66yp -buos5Qs6PlVARACLJgzgplI5sDbzXtVx5O9Q8YJjz4NfU0WOWYPWvmANXDeMNixWoWvuixYvsXaG -x6mdD7Hh/gi8prkQmZ7gxW1MEOV9JThAqYjjs2ayGVD73EI2sKYxVwEg3iJToQ/cEz3O2U1HdmYj -QfRDJiX3GEPBXXttDrbPM42SHElouldmJ+PkJDLdkGmA85xYUoEKHdEFIkjFStQcyO5CkyNZN7SH -iAIwA4DpGMmFJ26maqVzJuiLvicri2FR/sJaSA24N8HbGne3gSS7WrSQS+jKe3IZPVy64NCoGvrW -o/HvTeqsIfihKPEpXm8QVtjNhtkVn3RdIUgOaNWyAfnZ4dW1TVIATe+OHDw2TNyImTjE0x75nL6B -1/Rrn+9VP9Swhv8AEQEAAQ== - -AcLBUgQAAQoABgUCV6yq7gAAhaYQAMIVYhta2uUvm5PXApdXmZFWr+iZYfkAZW8PEMOsuYVHbDoH -oA7dpO0EwZXl/mCgGjNNc4nUmqQLBiIwwrcnmcYSRl2Xz+u+ssou4YMueXOD2tHo1N2J39SKpS72 -VqQsnF77Qylgdp2j7Q9lJrU0qHz0M195OJXNSppfdHYeWptfsO02cApPobU9s6KT5VggVg1ushNM -1u97A+uvoClfJ53PPafC0kr1+vwFVPj+mko4gc7sIB42xwz+YeR47CgSaT8i8K1u5ouaHCNxe61+ -siQxAdIOv+hOAWAOMoOWZjxh5K7J9A1Dc18EMyggf716IUCBtkvDKfwcXFcoic1X6EVPO5kNhlh7 -aLFS8UVsBPaZKnJm3ZFudhYQUmZt22ntslgGrq9+NBeh9i6nswUPKdj2idHkyQsjnYgYyTpEH/xh -sBqkqkedPkUtn+tP5dS4TP/L3Xq/q2tQbA4+gNVbZXIo8g8wfpsP8+sIOnEV5UcoxaO3oI3YUJrN -oFGmC7No802XKG1ZNHhBtMSaan0pafWrBrHn+axT9Jbl/1B73TYg3zQWOpDuSpH3SU+gXJ/eukUb -LvC8UWZM9YEhu/ZINSvSDQzvobV/NVrHWEJBXxrc3CwseFDgQq+Yz/CFGud79z2mS8lNHKSqQdFK -3Bd0HG1HheYcX0nGIva0KIG0Sgf/ diff --git a/tests/main/create-key/successful_default.exp b/tests/main/create-key/successful_default.exp index 2e5b9ae2af..9f4e01ab9a 100644 --- a/tests/main/create-key/successful_default.exp +++ b/tests/main/create-key/successful_default.exp @@ -28,10 +28,11 @@ if {[lindex $status 3] != 0} { spawn snap export-key --account=developer default -expect "Enter passphrase: " -send "pass\n" - +# fun! +# gpg1 asks for a passphrase on the terminal no matter what +# gpg2 gets the passphrase via our fake pinentry expect { + "Enter passphrase: " {send "pass\n"; exp_continue} "account-id: developer" {} timeout { exit 1 } eof { exit 1 } diff --git a/tests/main/create-key/successful_non_default.exp b/tests/main/create-key/successful_non_default.exp index 5c7f815760..452f335a12 100644 --- a/tests/main/create-key/successful_non_default.exp +++ b/tests/main/create-key/successful_non_default.exp @@ -28,10 +28,11 @@ if {[lindex $status 3] != 0} { spawn snap export-key --account=developer another -expect "Enter passphrase: " -send "pass\n" - +# fun! +# gpg1 asks for a passphrase on the terminal no matter what +# gpg2 gets the passphrase via our fake pinentry expect { + "Enter passphrase: " {send "pass\n"; exp_continue} "account-id: developer" {} timeout { exit 1 } eof { exit 1 } diff --git a/tests/main/create-key/task.yaml b/tests/main/create-key/task.yaml index b596af5b09..a7975f6fa0 100644 --- a/tests/main/create-key/task.yaml +++ b/tests/main/create-key/task.yaml @@ -5,6 +5,33 @@ systems: [-ubuntu-core-16-64] restore: | rm -rf $HOME/.snap/gnupg +prepare: | + echo "setup fake gpg pinentry environment" + cat > /tmp/pinentry-fake <<'EOF' + #!/bin/sh + set -e + echo "OK Pleased to meet you" + while true; do + read line + case $line in + GETPIN) + echo "D pass" + echo "OK" + ;; + BYE) + exit 0 + ;; + *) + echo "OK I'm not very smart" + ;; + esac + done + EOF + chmod +x /tmp/pinentry-fake + mkdir -p /root/.snap/gnupg/ + chmod 0700 /root/.snap/gnupg/ + echo pinentry-program /tmp/pinentry-fake > /root/.snap/gnupg/gpg-agent.conf + execute: | echo "Checking passphrase mismatch error" expect -f passphrase_mismatch.exp diff --git a/tests/main/install-sideload/task.yaml b/tests/main/install-sideload/task.yaml index 052267d49a..f8b4881d49 100644 --- a/tests/main/install-sideload/task.yaml +++ b/tests/main/install-sideload/task.yaml @@ -18,6 +18,10 @@ execute: | .*" snap install --dangerous ./basic_1.0_all.snap | grep -Pzq "$expected" + echo "Sideloaded snap with (deprecated) --force-dangerous option" + snap remove basic + snap install --force-dangerous ./basic_1.0_all.snap | grep -Pzq "$expected" + echo "Sideloaded snap executes commands" snap install --dangerous ./test-snapd-tools_1.0_all.snap test-snapd-tools.success diff --git a/tests/main/interfaces-locale-control/task.yaml b/tests/main/interfaces-locale-control/task.yaml index e0542bf516..95a6e43e48 100644 --- a/tests/main/interfaces-locale-control/task.yaml +++ b/tests/main/interfaces-locale-control/task.yaml @@ -16,7 +16,11 @@ prepare: | echo "Given a snap declaring a plug on the locale-control interface is installed" snapbuild $TESTSLIB/snaps/locale-control-consumer . snap install --dangerous locale-control-consumer_1.0_all.snap - cp /etc/default/locale locale.back + mv /etc/default/locale locale.back + cat > /etc/default/locale <<EOF + LANG="$LANG" + LANGUAGE="$LANGUAGE" + EOF restore: | rm -f locale-control-consumer_1.0_all.snap locale-read.error locale-write.error diff --git a/tests/main/interfaces-upower-observe/task.yaml b/tests/main/interfaces-upower-observe/task.yaml new file mode 100644 index 0000000000..6e3a763cde --- /dev/null +++ b/tests/main/interfaces-upower-observe/task.yaml @@ -0,0 +1,54 @@ +summary: Ensure that the upower-observe interface works. + +systems: [-ubuntu-core-16-64] + +summary: | + The upower-observe interface allows a snap to query UPower for power devices, history + and statistics. + + A snap which defines the upower-observe plug must be shown in the interfaces list. + The plug must be autoconnected on install and, as usual, must be able to be reconnected. + + The test uses a snap wrapping the upower command line utility, and checks that it can query + it without error while the plug is connected. + +prepare: | + echo "Given a snap declaring a plug on the upower-observe interface is installed" + snap install --edge test-snapd-upower-observe-consumer + + apt install -y upower + +restore: | + rm -f upower.error + apt remove -y upower + apt autoremove -y + +execute: | + CONNECTED_PATTERN=":upower-observe +test-snapd-upower-observe-consumer" + DISCONNECTED_PATTERN="(?s).*?\n- +test-snapd-upower-observe-consumer:upower-observe" + + echo "Then it is connected by default" + snap interfaces | grep -Pzq "$CONNECTED_PATTERN" + + echo "===================================" + + echo "When the plug is disconnected" + snap disconnect test-snapd-upower-observe-consumer:upower-observe ubuntu-core:upower-observe + snap interfaces | grep -Pzq "$DISCONNECTED_PATTERN" + + echo "Then the snap is not able to dump info about the upower devices" + if su -l -c "test-snapd-upower-observe-consumer.upower --dump 2>${PWD}/upower.error" test; then + echo "Expected permission error accessing upower info with disconnected plug" + exit 1 + fi + grep -q "Permission denied" upower.error + + echo "===================================" + + echo "When the plug is connected" + snap connect test-snapd-upower-observe-consumer:upower-observe ubuntu-core:upower-observe + snap interfaces | grep -Pzq "$CONNECTED_PATTERN" + + echo "Then the snap is able to dump info about the upower devices" + expected="(?s)Device: +/org/freedesktop/UPower/devices/DisplayDevice.*Daemon:.*" + su -l -c 'test-snapd-upower-observe-consumer.upower --dump' test | grep -Pqz "$expected" diff --git a/tests/main/login/missing_email_error.exp b/tests/main/login/missing_email_error.exp index 8470b39d95..4bd1e1ff2e 100644 --- a/tests/main/login/missing_email_error.exp +++ b/tests/main/login/missing_email_error.exp @@ -1,7 +1,7 @@ spawn snap login expect { - "required argument `email` was not provided" { + "required argument `<email>` was not provided" { exit 0 } default { exit 1 diff --git a/tests/main/op-remove-retry/task.yaml b/tests/main/op-remove-retry/task.yaml index df1cb4945c..1c85e17451 100644 --- a/tests/main/op-remove-retry/task.yaml +++ b/tests/main/op-remove-retry/task.yaml @@ -8,7 +8,7 @@ execute: | wait_for_service(){ local service_name=$1 local state=$2 - while ! systemctl show -p ActiveState $service_name | grep -q "ActiveState=$state"; do sleep 1; done + while ! systemctl show -p ActiveState $service_name | grep -q "ActiveState=$state"; do systemctl status $service_name || true; sleep 1; done } wait_for_remove_state(){ local state=$1 @@ -41,4 +41,4 @@ execute: | # cleanup umount blocker systemctl stop unmount-blocker - wait_for_service unmount-blocker inactive + diff --git a/tests/main/prepare-image-grub/task.yaml b/tests/main/prepare-image-grub/task.yaml index 39817ae074..6dce94a255 100644 --- a/tests/main/prepare-image-grub/task.yaml +++ b/tests/main/prepare-image-grub/task.yaml @@ -1,5 +1,6 @@ summary: Check that prepare-image works for grub-systems systems: [-ubuntu-core-16-64] +backends: [-autopkgtest] # TODO: use the real stores with proper assertions fully as well once possible environment: ROOT: /tmp/root @@ -10,7 +11,7 @@ environment: UBUNTU_IMAGE_SKIP_COPY_UNVERIFIED_SNAPS: 1 prepare: | . $TESTSLIB/store.sh - setup_store fake-w-assert-fallback $STORE_DIR + setup_store fake $STORE_DIR restore: | . $TESTSLIB/store.sh teardown_store fake $STORE_DIR diff --git a/tests/main/refresh-devmode/task.yaml b/tests/main/refresh-devmode/task.yaml index 9f782a5c6b..bcac9db3d2 100644 --- a/tests/main/refresh-devmode/task.yaml +++ b/tests/main/refresh-devmode/task.yaml @@ -1,5 +1,5 @@ summary: Check that the refresh command works. - +systems: [-ubuntu-core-16-64] details: | These tests exercise the refresh command using different store backends. The concrete store to be used is controlled with the STORE_TYPE environment @@ -14,7 +14,7 @@ environment: SNAP_VERSION_PATTERN: \d+\.\d+\+fake1 BLOB_DIR: $(pwd)/fake-store-blobdir STORE_TYPE/fake: fake - STORE_TYPE/staging: staging +# STORE_TYPE/staging: staging STORE_TYPE/production: production prepare: | diff --git a/tests/main/refresh/task.yaml b/tests/main/refresh/task.yaml index 1f887643ed..3e929ba8b5 100644 --- a/tests/main/refresh/task.yaml +++ b/tests/main/refresh/task.yaml @@ -1,5 +1,5 @@ summary: Check that the refresh command works. - +systems: [-ubuntu-core-16-64] details: | These tests exercise the refresh command using different store backends. The concrete store to be used is controlled with the STORE_TYPE environment @@ -14,7 +14,7 @@ environment: SNAP_VERSION_PATTERN: \d+\.\d+\+fake1 BLOB_DIR: $(pwd)/fake-store-blobdir STORE_TYPE/fake: fake - STORE_TYPE/staging: staging +# STORE_TYPE/staging: staging STORE_TYPE/production: production prepare: | diff --git a/tests/main/revert-devmode/task.yaml b/tests/main/revert-devmode/task.yaml new file mode 100644 index 0000000000..3f0c6a79fc --- /dev/null +++ b/tests/main/revert-devmode/task.yaml @@ -0,0 +1,52 @@ +summary: Check that revert of a snap in devmode restores devmode +systems: [-ubuntu-core-16-64] +environment: + STORE_TYPE/fake: fake +# STORE_TYPE/staging: staging + STORE_TYPE/production: production + BLOB_DIR: $(pwd)/fake-store-blobdir + +prepare: | + if [ "$STORE_TYPE" = "fake" ]; then + echo "Given a snap is installed" + snap install --devmode test-snapd-tools + fi + + . $TESTSLIB/store.sh + setup_store $STORE_TYPE $BLOB_DIR + + if [ "$STORE_TYPE" = "fake" ]; then + echo "And a new version of that snap put in the controlled store" + fakestore -dir $BLOB_DIR -make-refreshable test-snapd-tools + fi + +restore: | + . $TESTSLIB/store.sh + teardown_store $STORE_TYPE $BLOB_DIR + +execute: | + echo "When a refresh is made" + snap refresh --devmode --edge test-snapd-tools + + echo "Then the new version is installed" + snap list | grep -Pq "test-snapd-tools +\d+\.\d+\+fake1" + LATEST=$(readlink /snap/test-snapd-tools/current) + + echo "When a revert is made without --devmode flag" + snap revert test-snapd-tools + + echo "Then the old version is active" + snap list | grep -Pq "test-snapd-tools +\d+\.\d+ " + + echo "And the snap runs confined" + snap list|grep test-snapd-tools|grep -q "-" + + echo "When the latest revision is installed again" + snap remove --revision=$LATEST test-snapd-tools + snap refresh --devmode --edge test-snapd-tools + + echo "And revert is made with --devmode flag" + snap revert --devmode test-snapd-tools + + echo "Then snap uses devmode" + snap list|grep test-snapd-tools|grep -q devmode diff --git a/tests/main/revert/task.yaml b/tests/main/revert/task.yaml index 9ecced842e..f11ba6a04b 100644 --- a/tests/main/revert/task.yaml +++ b/tests/main/revert/task.yaml @@ -1,8 +1,8 @@ summary: Check that revert works. - +systems: [-ubuntu-core-16-64] environment: STORE_TYPE/fake: fake - STORE_TYPE/staging: staging +# STORE_TYPE/staging: staging STORE_TYPE/production: production BLOB_DIR: $(pwd)/fake-store-blobdir @@ -41,6 +41,9 @@ execute: | ls /snap/test-snapd-tools | grep -q current ls /var/snap/test-snapd-tools | grep -q current + echo "And the snap runs confined" + snap list|grep test-snapd-tools|grep -q "-" + echo "And a new revert fails" if snap revert test-snapd-tools; then echo "A revert on an already reverted snap should fail" diff --git a/tests/main/searching/task.yaml b/tests/main/searching/task.yaml index c29ad02dad..c7ec9ccda3 100644 --- a/tests/main/searching/task.yaml +++ b/tests/main/searching/task.yaml @@ -2,7 +2,7 @@ summary: Check snap search execute: | echo "Try to list all snaps" - ( snap find 2>&1 || echo FAILED ) | grep -Pzq "(?ms)empty query.*FAILED" + ( snap find 2>&1 || echo FAILED ) | grep -Pzq "(?ms)you need to specify a query.*FAILED" echo "Exact matches" for snapName in test-snapd-tools xkcd-webserver diff --git a/tests/main/snap-download/task.yaml b/tests/main/snap-download/task.yaml index 4f12db396b..147cc88a6b 100644 --- a/tests/main/snap-download/task.yaml +++ b/tests/main/snap-download/task.yaml @@ -2,14 +2,24 @@ summary: Check that snap download works restore: | rm -f *.snap execute: | + verify_asserts() { + fn="$1" + grep "type: account-key" "$fn" + grep "type: snap-declaration" "$fn" + grep "type: snap-revision" "$fn" + } echo "Snap download can download snaps" snap download hello-world ls hello-world_*.snap + verify_asserts hello-world_*.snap.assertions echo "Snap download understand --edge" snap download --edge test-snapd-tools ls test-snapd-tools_*.snap + verify_asserts test-snapd-tools_*.snap.assertions echo "Snap download downloads devmode snaps" snap download --beta classic ls classic_*.snap + verify_asserts classic_*.snap.assertions + diff --git a/tests/main/snap-run-hook/task.yaml b/tests/main/snap-run-hook/task.yaml index 9b372a5702..5934bc58cc 100644 --- a/tests/main/snap-run-hook/task.yaml +++ b/tests/main/snap-run-hook/task.yaml @@ -2,6 +2,14 @@ summary: Check that `snap run` can actually run hooks systems: [-ubuntu-core-16-64] +prepare: | + echo "Build test hooks package" + snapbuild $TESTSLIB/snaps/basic-hooks . + snap install --dangerous basic-hooks_1.0_all.snap + +restore: | + rm basic-hooks_1.0_all.snap + execute: | # Note that `snap run` doesn't exit non-zero if the hook is missing, so we # check the output instead. diff --git a/tests/main/snap-set/task.yaml b/tests/main/snap-set/task.yaml new file mode 100644 index 0000000000..bf34085bd3 --- /dev/null +++ b/tests/main/snap-set/task.yaml @@ -0,0 +1,74 @@ +summary: Check that `snap set` runs apply-config hook. + +prepare: | + echo "Build basic test package (without hooks)" + snapbuild $TESTSLIB/snaps/basic . + snap install --dangerous basic_1.0_all.snap + + echo "Build basic hooks package" + snapbuild $TESTSLIB/snaps/basic-hooks . + snap install --dangerous basic-hooks_1.0_all.snap + + echo "Build failing hooks package" + snapbuild $TESTSLIB/snaps/failing-config-hooks . + snap install --dangerous failing-config-hooks_1.0_all.snap + + # We want to use the in-tree snap-exec, not the one in the core snap. To + # accomplish that, we'll just unpack the core we just grabbed, shove the new + # snap-exec in there, and repack it. + + # First of all, unmount the core + systemctl stop snapd.service + core="$(realpath /snap/ubuntu-core/current)" + snap="$(mount | grep " $core" | awk '{print $1}')" + umount "$core" + + # Now unpack the core, inject the new snap-exec into it, and repack it. + unsquashfs "$snap" + cp /usr/lib/snapd/snap-exec squashfs-root/usr/lib/snapd/ + mv "$snap" "${snap}.orig" + mksquashfs squashfs-root "$snap" -comp xz + rm -rf squashfs-root + + # Now mount the new core snap + mount "$snap" "$core" + systemctl start snapd.service + + # Make sure we're running with the correct snap-exec + if ! cmp /usr/lib/snapd/snap-exec ${core}/usr/lib/snapd/snap-exec; then + echo "snap-exec in tree and snap-exec in core snap are unexpectedly not the same" + exit 1 + fi + +restore: | + rm basic_1.0_all.snap + rm basic-hooks_1.0_all.snap + rm failing-config-hooks_1.0_all.snap + + # Unmount the modified core snap, and put the old one back in place + systemctl stop snapd.service + core="$(realpath /snap/ubuntu-core/current)" + snap="$(mount | grep " $core" | awk '{print $1}')" + umount "$core" + mv "${snap}.orig" "$snap" + mount "$snap" "$core" + systemctl start snapd.service + +execute: | + echo "Test that snap set executes successfully without apply-config hook" + if ! snap set basic foo=bar; then + echo "Expected snap set to succeed, even when apply-config hook is missing" + exit 1 + fi + + echo "Test that snap set executes successfully with apply-config hook" + if ! snap set basic-hooks foo=bar; then + echo "Expected snap set to succeed when apply-config hook exits successfully" + exit 1 + fi + + echo "Test that snap set fails when apply-config hook fails" + if snap set failing-config-hooks foo=bar; then + echo "Expected snap set to fail when apply-config hook fails" + exit 1 + fi diff --git a/tests/main/snapctl/task.yaml b/tests/main/snapctl/task.yaml index f95d07d817..835c56c89d 100644 --- a/tests/main/snapctl/task.yaml +++ b/tests/main/snapctl/task.yaml @@ -1,23 +1,9 @@ summary: Check that `snapctl` can be run from within hooks -systems: [-ubuntu-core-16-64] - prepare: | snapbuild $TESTSLIB/snaps/snapctl-hooks . snap install --dangerous snapctl-hooks_1.0_all.snap -restore: | - rm snapctl-hooks_1.0_all.snap - - # Unmount the modified core snap, and put the old one back in place - systemctl stop snapd.service - core="$(realpath /snap/ubuntu-core/current)" - snap="$(mount | grep "$core" | awk '{print $1}')" - umount "$core" - mv "${snap}.orig" "$snap" - mount "$snap" "$core" - systemctl start snapd.service - execute: | echo "Run the hook that calls snapctl" @@ -37,12 +23,13 @@ execute: | echo "Verify that the snapd API is only available via the snapd socket" - if ! curl -s --unix-socket /run/snapd.socket http:/v2/snaps | grep status-code\":\s*200; then + if ! printf "GET /v2/snaps HTTP/1.0\r\n\r\n" | nc -U -q 1 /run/snapd.socket | grep "200 OK"; then echo "Expected snapd API to be available on the snapd socket" + echo "Got: $(curl -s --unix-socket /run/snapd.socket http:/v2/snaps)" exit 1 fi - if ! curl -s --unix-socket /run/snapd-snap.socket http:/v2/snaps | grep status-code\":\s*401; then + if ! printf "GET /v2/snaps HTTP/1.0\r\n\r\n" | nc -U -q 1 /run/snapd-snap.socket | grep "401 Unauthorized"; then echo "Expected snapd API to be unauthorized on the snap socket" exit 1 fi diff --git a/tests/main/ubuntu-core-update-rollback-stresstest/task.yaml b/tests/main/ubuntu-core-update-rollback-stresstest/task.yaml index 916e5d70d0..4d7acc2d69 100644 --- a/tests/main/ubuntu-core-update-rollback-stresstest/task.yaml +++ b/tests/main/ubuntu-core-update-rollback-stresstest/task.yaml @@ -6,18 +6,31 @@ execute: | wait_boot_ok() { echo "Waiting for boot-ok to finish" while ! systemctl status snapd.boot-ok|grep SUCCESS; do + # debug output + systemctl status snapd.boot-ok || true sleep 1 done } check_boot() { + # debug output + grub-editenv list grub-editenv list | grep "snap_core=ubuntu-core_$(cat nextBoot).snap" } store_next_boot() { snap list|grep ubuntu-core|tr -s " "|cut -f3 -d' ' > nextBoot + # debug output + snap list + echo "nextBoot:" + cat nextBoot } echo "Install/revert a couple of times and see if stuff breaks" if [ "$SPREAD_REBOOT" = "0" ]; then snap list|grep ubuntu-core|tr -s " "|cut -f3 -d' ' > firstBoot + # debug output + snap list + echo "firstBoot:" + cat firstBoot + echo "Install new ubuntu-core" snap install --dangerous /var/lib/snapd/snaps/ubuntu-core_$(cat firstBoot).snap store_next_boot REBOOT diff --git a/tests/main/writable-areas/task.yaml b/tests/main/writable-areas/task.yaml index 112b79cd9d..4c93e18a04 100644 --- a/tests/main/writable-areas/task.yaml +++ b/tests/main/writable-areas/task.yaml @@ -20,18 +20,9 @@ execute: | echo "Waiting for data writer service to finish..." unit="snap.data-writer.service.service" - while true; do - code=$(sudo systemctl show -p ExecMainCode $unit | sed 's/.*=\([0-9]\+\)/\1/') - # The main code will be 0 until the service is no longer running - if [ $code -ne 0 ]; then - status=$(sudo systemctl show -p ExecMainStatus $unit | sed 's/.*=\([0-9]\+\)/\1/') - if [ $status -ne 0 ]; then - echo "Service exited $status" - exit 1 - fi - break - fi - sleep 0.1 + while ! systemctl status $unit | grep -q "Writing to SNAP_USER_DATA"; do + systemctl status $unit || true + sleep 1 done echo "Services can write to writable areas" diff --git a/tests/manual-tests.md b/tests/manual-tests.md new file mode 100644 index 0000000000..0217c30057 --- /dev/null +++ b/tests/manual-tests.md @@ -0,0 +1,236 @@ +# Test gadget snap with pre-installed snaps + +1. Branch snappy-systems +2. Modify the `snap.yaml` to add a snap, e.g.: + + ```diff + === modified file 'generic-amd64/meta/snap.yaml' + --- generic-amd64/meta/snap.yaml 2015-07-03 12:50:03 +0000 + +++ generic-amd64/meta/snap.yaml 2015-11-09 16:26:12 +0000 + @@ -7,6 +7,8 @@ + config: + ubuntu-core: + autopilot: true + + config-example-bash: + + msg: "huzzah\n" + + gadget: + branding: + @@ -20,3 +22,7 @@ + boot-assets: + files: + - path: grub.cfg + + + + software: + + built-in: + + - config-example-bash.canonical + ``` + + (for amd64, or modify for other arch). + +3. Build the gadget snap. +4. Create an image using the gadget snap. +5. Boot the image +6. Run: + + sudo journalctl -u snapd.firstboot.service + + * Check that it shows no errors. + + +7. Run: + + config-example-bash.hello + + * Check that it prints `huzzah`. + +# Test gadget snap with modules + +1. Branch snappy-systems +2. Modify the `snap.yaml` to add a module, e.g.: + + ```diff + === modified file 'generic-amd64/meta/snap.yaml' + --- generic-amd64/meta/snap.yaml 2015-07-03 12:50:03 +0000 + +++ generic-amd64/meta/snap.yaml 2015-11-12 10:14:30 +0000 + @@ -7,6 +7,7 @@ + config: + ubuntu-core: + autopilot: true + + load-kernel-modules: [tea] + + gadget: + branding: + + ``` + +3. Build the gadget snap. +4. Create an image using the gadget snap. +5. Boot the image. +6. Run: + + sudo journalctl -u snapd.firstboot.service + + * Check that it shows no errors. + + +7. Check that the output of `lsmod` includes the module you requested. With the above example, + + lsmod | grep tea + +# Test resize of writable partition + +1. Get the start of the *writable* partition: + + parted /path/to/ubuntu-snappy.img unit b print + + * Note down the number of bytes in the *Start* column for the *writable* partition. + +2. Make a loopback block device for the writable partition, replacing *{start}* with the number + from the previous step: + + sudo losetup -f --show -o {start} /path/to/ubuntu-snappy.img + + * Note down the loop device. + +3. Shrink the file system to the minimum, replacing *{dev}* with the device from the previous + step: + + sudo e2fsck -f {dev} + sudo resize2fs -M {dev} + +4. Delete the loopback block device: + + sudo losetup -d {dev} + +5. Get the end of the *writable* partition: + + parted /path/to/ubuntu-snappy.img unit b print + + * Note down the *Number* of the *writable* partition and the number of bytes in the *End* + column. + +6. Resize the *writable* partition, using the partition *{number}* from the last step, and + replacing the *{end}* with a value that leaves more than 10% space free at the end. + + parted /path/to/ubuntu-snappy.img unit b resizepart {number} {end*85%} + +7. Boot the image. + +8. Print the free space of the file system, replacing *{dev}* with the device that has the + *writable* partition: + + sudo parted -s {dev} unit % print free + + * Check that the writable partition was resized to occupy all the empty space. + +# Test Mir interface by running Mir kiosk snap examples + +1. Install Virtual Machine Manager +2. Stitch together a new image +3. Build both the mir-server and the mir-client snaps from lp:~mir-team/+junk/mir-server-snap and lp:~mir-team/+junk/snapcraft-mir-client +4. Copy over the snaps and sideload install the mir-server snap, which should result in a mir-server launching black blank screen with a mouse available. +5. Now install the mir-client snap. +6. Manually connect mir-client:mir to mir-server:mir due to bug 1577897, then start the mir-client service manually. +7. This should result in the Qt clock example app being displayed. + +# Test serial-port interface using miniterm app + +1. Using Ubuntu classic build and install a simple snap containing the Python + pySerial module. Define a app that runs the module and starts miniterm. + +```yaml + name: miniterm + version: 1 + summary: pySerial miniterm in a snap + description: | + Simple snap that contains the modules necessary to run + pySerial. Useful for testing serial ports. + confinement: strict + apps: + open: + command: python3 -m serial.tools.miniterm + plugs: [serial-port] + parts: + my-part: + plugin: nil + stage-packages: + - python3-serial +``` + +2. Ensure the 'serial-port' interface is connected to miniterm +3. Use sudo miniterm.open /dev/tty<DEV> to open a serial port + +# Test pulseaudio interface using paplay, pactl + +1. Using a Snappy core image on a device like an RPi2/3, install the + build and install the simple-pulseaudio snap from the following + git repo: + git://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/examples +2. $ cd examples/simple-pulseaudio +3. Ensure that the 'pulseaudio' interface is connected to paplay + $ sudo snap interfaces +4. Use /snap/bin/simple-pulseaudio.pactl stat and verify that you see + valid output status from pulseaudio +5. Use /snap/bin/simple-pulseaudio.paplay $SNAP/usr/share/sounds/alsa/Noise.wav and verify + that you can hear the sound playing + +# Test bluetooth-control interface + +1. Using Ubuntu classic build and install the bluetooth-tests snap + from the store. + +2. Stop system BlueZ service + +$ sudo systemctl stop bluetooth + +or if you have the bluez snap installed + +$ snap remove bluez + +3. Run one of the tests provided by the bluetooth-tests snap + + $ sudo /snap/bin/bluetooth-tests.hci-tester + + and verify it actually passes. If some of the tests fail + there will be a problem with the particular kernel used on + the device. + +# Test tpm interface with tpm-tools + +1. Install tpm snap from store. +2. Connect plug tpm:tpm to slot ubuntu-core:tpm. +3. Reboot the system so daemon in tpm snap can get proper permissions. +4. Use tpm.version to read from tpm device and make sure it shows no error. + + $ tpm.version + xKV TPM 1.2 Version Info: + Chip Version: 1.2.5.81 + Spec Level: 2 + Errata Revision: 3 + TPM Vendor ID: WEC + Vendor Specific data: 0000 + TPM Version: 01010000 + Manufacturer Info: 57454300 + +# Test fwupd interface with uefi-fw-tools + +1. Ensure your BIOS support UEFI firmware upgrading via UEFI capsule format +2. Install the uefi-fw-tools snap from the store +3. Ensure the 'fwupd' interface is connected + + $ sudo snap connect uefi-fw-tools:fwupdmgr uefi-fw-tools:fwupd + +4. Check if the device support UEFI firmware updates + + $ sudo uefi-fw-tools.fwupdmgr get-devices + +5. Get available UEFI firmware from the server + + $ sudo uefi-fw-tools.fwupdmgr refresh + +6. Download firmware + + $ sudo uefi-fw-tools.fwupdmgr update + +7. Reboot and ensure it start the upgrading process |
