diff options
| -rw-r--r-- | interfaces/mount/mountinfo.go | 23 | ||||
| -rw-r--r-- | interfaces/mount/mountinfo_test.go | 14 | ||||
| -rw-r--r-- | spread.yaml | 1 | ||||
| -rwxr-xr-x | tests/lib/prepare.sh | 16 | ||||
| -rw-r--r-- | tests/main/classic-ubuntu-core-transition-auth/task.yaml | 8 | ||||
| -rw-r--r-- | tests/main/classic-ubuntu-core-transition/task.yaml | 8 |
6 files changed, 54 insertions, 16 deletions
diff --git a/interfaces/mount/mountinfo.go b/interfaces/mount/mountinfo.go index 96b0f93d83..a160f1db43 100644 --- a/interfaces/mount/mountinfo.go +++ b/interfaces/mount/mountinfo.go @@ -36,11 +36,11 @@ type InfoEntry struct { DevMinor int Root string MountDir string - MountOptions string + MountOptions map[string]string OptionalFields []string FsType string MountSource string - SuperOptions string + SuperOptions map[string]string } // ParseInfoEntry parses a single line of /proc/$PID/mountinfo file. @@ -82,7 +82,7 @@ func ParseInfoEntry(s string) (*InfoEntry, error) { // Parse Root, MountDir and MountOptions fields. e.Root = unescape(fields[3]) e.MountDir = unescape(fields[4]) - e.MountOptions = unescape(fields[5]) + e.MountOptions = parseMountOpts(unescape(fields[5])) // Optional fields are terminated with a "-" value and start // after the mount options field. Skip ahead until we see the "-" // marker. @@ -103,6 +103,21 @@ func ParseInfoEntry(s string) (*InfoEntry, error) { } e.FsType = unescape(tailFields[0]) e.MountSource = unescape(tailFields[1]) - e.SuperOptions = unescape(tailFields[2]) + e.SuperOptions = parseMountOpts(unescape(tailFields[2])) return &e, nil } + +func parseMountOpts(opts string) map[string]string { + result := make(map[string]string) + for _, opt := range strings.Split(opts, ",") { + keyValue := strings.SplitN(opt, "=", 2) + key := keyValue[0] + if len(keyValue) == 2 { + value := keyValue[1] + result[key] = value + } else { + result[key] = "" + } + } + return result +} diff --git a/interfaces/mount/mountinfo_test.go b/interfaces/mount/mountinfo_test.go index d1efa9f7f6..8873c76912 100644 --- a/interfaces/mount/mountinfo_test.go +++ b/interfaces/mount/mountinfo_test.go @@ -40,11 +40,11 @@ func (s *mountinfoSuite) TestParseInfoEntry1(c *C) { c.Assert(entry.DevMinor, Equals, 0) c.Assert(entry.Root, Equals, "/mnt1") c.Assert(entry.MountDir, Equals, "/mnt2") - c.Assert(entry.MountOptions, Equals, "rw,noatime") + c.Assert(entry.MountOptions, DeepEquals, map[string]string{"rw": "", "noatime": ""}) c.Assert(entry.OptionalFields, DeepEquals, []string{"master:1"}) c.Assert(entry.FsType, Equals, "ext3") c.Assert(entry.MountSource, Equals, "/dev/root") - c.Assert(entry.SuperOptions, Equals, "rw,errors=continue") + c.Assert(entry.SuperOptions, DeepEquals, map[string]string{"rw": "", "errors": "continue"}) } // Check that various combinations of optional fields are parsed correctly. @@ -53,21 +53,21 @@ func (s *mountinfoSuite) TestParseInfoEntry2(c *C) { entry, err := mount.ParseInfoEntry( "36 35 98:0 /mnt1 /mnt2 rw,noatime - ext3 /dev/root rw,errors=continue") c.Assert(err, IsNil) - c.Assert(entry.MountOptions, Equals, "rw,noatime") + c.Assert(entry.MountOptions, DeepEquals, map[string]string{"rw": "", "noatime": ""}) c.Assert(entry.OptionalFields, HasLen, 0) c.Assert(entry.FsType, Equals, "ext3") // One optional field. entry, err = mount.ParseInfoEntry( "36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue") c.Assert(err, IsNil) - c.Assert(entry.MountOptions, Equals, "rw,noatime") + c.Assert(entry.MountOptions, DeepEquals, map[string]string{"rw": "", "noatime": ""}) c.Assert(entry.OptionalFields, DeepEquals, []string{"master:1"}) c.Assert(entry.FsType, Equals, "ext3") // Two optional fields. entry, err = mount.ParseInfoEntry( "36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 slave:2 - ext3 /dev/root rw,errors=continue") c.Assert(err, IsNil) - c.Assert(entry.MountOptions, Equals, "rw,noatime") + c.Assert(entry.MountOptions, DeepEquals, map[string]string{"rw": "", "noatime": ""}) c.Assert(entry.OptionalFields, DeepEquals, []string{"master:1", "slave:2"}) c.Assert(entry.FsType, Equals, "ext3") } @@ -83,12 +83,12 @@ func (s *mountinfoSuite) TestParseInfoEntry3(c *C) { c.Assert(entry.DevMinor, Equals, 0) c.Assert(entry.Root, Equals, "/mnt 1") c.Assert(entry.MountDir, Equals, "/mnt 2") - c.Assert(entry.MountOptions, Equals, "rw ,noatime") + c.Assert(entry.MountOptions, DeepEquals, map[string]string{"rw ": "", "noatime": ""}) // This field is still escaped as it is space-separated and needs further parsing. c.Assert(entry.OptionalFields, DeepEquals, []string{"mas ter:1"}) c.Assert(entry.FsType, Equals, "ext 3") c.Assert(entry.MountSource, Equals, "/dev/ro ot") - c.Assert(entry.SuperOptions, Equals, "rw ,errors=continue") + c.Assert(entry.SuperOptions, DeepEquals, map[string]string{"rw ": "", "errors": "continue"}) } // Check that various malformed entries are detected. diff --git a/spread.yaml b/spread.yaml index b02bbd64bd..98b6e6866a 100644 --- a/spread.yaml +++ b/spread.yaml @@ -35,6 +35,7 @@ environment: HTTPS_PROXY: "$(HOST: echo $HTTPS_PROXY)" NO_PROXY: "127.0.0.1" NEW_CORE_CHANNEL: "$(HOST: echo $SPREAD_NEW_CORE_CHANNEL)" + SRU_VALIDATION: "$(HOST: echo ${SPREAD_SRU_VALIDATION:-0})" backends: linode: diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index ea3be7e307..108a4854b7 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -53,6 +53,16 @@ update_core_snap_for_classic_reexec() { done } +upgrade_snapd_from_proposed(){ + apt install -y snapd + cp /etc/apt/sources.list sources.list.back + echo "deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -c -s)-proposed restricted main multiverse universe" | tee /etc/apt/sources.list -a + apt update + apt install -y --only-upgrade snapd + mv sources.list.back /etc/apt/sources.list + apt update +} + prepare_each_classic() { mkdir -p /etc/systemd/system/snapd.service.d if [ -z "${SNAP_REEXEC:-}" ]; then @@ -70,7 +80,11 @@ EOF } prepare_classic() { - apt_install_local ${GOPATH}/snapd_*.deb + if [ "$SRU_VALIDATION" = "1" ]; then + upgrade_snapd_from_proposed + else + apt_install_local ${GOPATH}/snapd_*.deb + fi if snap --version |MATCH unknown; then echo "Package build incorrect, 'snap --version' mentions 'unknown'" snap --version diff --git a/tests/main/classic-ubuntu-core-transition-auth/task.yaml b/tests/main/classic-ubuntu-core-transition-auth/task.yaml index 259b8b3a68..509e1d66a4 100644 --- a/tests/main/classic-ubuntu-core-transition-auth/task.yaml +++ b/tests/main/classic-ubuntu-core-transition-auth/task.yaml @@ -10,14 +10,18 @@ execute: | . "$TESTSLIB/apt.sh" echo "Ensure core is gone and we have ubuntu-core instead" dpkg --purge snapd - apt_install_local ${GOPATH}/snapd_*.deb + if [ "$SRU_VALIDATION" = "1" ]; then + upgrade_snapd_from_proposed + else + apt_install_local ${GOPATH}/snapd_*.deb + fi snap install --${CORE_CHANNEL} ubuntu-core mkdir -p /root/.snap/ echo '{}' > /root/.snap/auth.json mkdir -p /home/test/.snap/ echo '{}' > /home/test/.snap/auth.json - + echo "Ensure transition is triggered" snap debug ensure-state-soon diff --git a/tests/main/classic-ubuntu-core-transition/task.yaml b/tests/main/classic-ubuntu-core-transition/task.yaml index 67d9c684ec..3e2bbc3ef1 100644 --- a/tests/main/classic-ubuntu-core-transition/task.yaml +++ b/tests/main/classic-ubuntu-core-transition/task.yaml @@ -30,7 +30,11 @@ execute: | . "$TESTSLIB/apt.sh" echo "Ensure core is gone and we have ubuntu-core instead" dpkg --purge snapd - apt_install_local ${GOPATH}/snapd_*.deb + if [ "$SRU_VALIDATION" = "1" ]; then + upgrade_snapd_from_proposed + else + apt_install_local ${GOPATH}/snapd_*.deb + fi # modify daemon state to set ubuntu-core-transition-last-retry-time to the # current time to prevent the ubuntu-core transition before the test snap is @@ -71,7 +75,7 @@ execute: | exit 1 fi snap interfaces | MATCH ":network +test-snapd-python-webserver" - snap interfaces | MATCH ":network-bind +test-snapd-python-webserver" + snap interfaces | MATCH ":network-bind +test-snapd-python-webserver" echo "Ensure the webserver is still working" wait_for_service snap.test-snapd-python-webserver.test-snapd-python-webserver curl http://localhost | MATCH "XKCD rocks" |
