Skip to content

Commit

Permalink
sefltest: advise reboot into 4.4 on trusty running 3.13
Browse files Browse the repository at this point in the history
This patch extends the self-test system to check if a user running
Ubuntu 14.04 has just installed snapd and is still running the 3.13
kernel that is used by trusty by default.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information
zyga committed Jun 4, 2018
1 parent ede6649 commit 50119c9
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
3 changes: 2 additions & 1 deletion selftest/export_test.go
Expand Up @@ -20,7 +20,8 @@
package selftest

var (
TrySquashfsMount = trySquashfsMount
TrySquashfsMount = trySquashfsMount
CheckKernelVersion = checkKernelVersion
)

func MockChecks(mockChecks []func() error) (restore func()) {
Expand Down
38 changes: 38 additions & 0 deletions selftest/version.go
@@ -0,0 +1,38 @@
// -*- Mode: Go; indent-tabs-mode: t -*-

/*
* Copyright (C) 2018 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package selftest

import (
"fmt"

"github.com/snapcore/snapd/release"
"github.com/snapcore/snapd/strutil"
)

// checkKernelVersion looks for some unsupported configurations that users may
// encounter and provides advice on how to resolve them.
func checkKernelVersion() error {
if release.OnClassic && release.ReleaseInfo.ID == "ubuntu" && release.ReleaseInfo.VersionID == "14.04" {
if cmp, _ := strutil.VersionCompare(release.KernelVersion(), "3.13"); cmp <= 0 {
return fmt.Errorf("you need to reboot into a 4.4 kernel to start using snapd")
}
}
return nil
}
45 changes: 45 additions & 0 deletions selftest/version_test.go
@@ -0,0 +1,45 @@
// -*- Mode: Go; indent-tabs-mode: t -*-

/*
* Copyright (C) 2018 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package selftest_test

import (
. "gopkg.in/check.v1"

"github.com/snapcore/snapd/release"
"github.com/snapcore/snapd/selftest"
)

type versionSuite struct{}

var _ = Suite(&versionSuite{})

func (s *selftestSuite) TestFreshInstallOfSnapdOnTrusty(c *C) {
// Mock an Ubuntu 14.04 system running a 3.13 kernel
restore := release.MockOnClassic(true)
defer restore()
restore = release.MockReleaseInfo(&release.OS{ID: "ubuntu", VersionID: "14.04"})
defer restore()
restore = release.MockKernelVersion("3.13.0-35-generic")
defer restore()

// Check for the given advice.
err := selftest.CheckKernelVersion()
c.Assert(err, ErrorMatches, "you need to reboot into a 4.4 kernel to start using snapd")
}

0 comments on commit 50119c9

Please sign in to comment.