From 9ff4f40094c5863951c965f6cdf5844843a3fe1b Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Wed, 18 Jul 2018 22:04:40 +0200 Subject: Skip unit tests which require storage when not running as root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS NewImageRuntimeFromOptions fails with chown EPERM because the "vfs" driver tries to chown its home to root:root 0700; in fact running as root seems to be a generic requirement. So, skip the tests if not running as root. (This could maybe benefit from an extra state, maybe an environment variable like RUNNING_IN_CI, to make sure the tests are actually run often enough.) Signed-off-by: Miloslav Trmač Closes: #1115 Approved by: rhatdan --- libpod/image/image_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libpod/image/image_test.go') diff --git a/libpod/image/image_test.go b/libpod/image/image_test.go index 2236b2010..0aa637dab 100644 --- a/libpod/image/image_test.go +++ b/libpod/image/image_test.go @@ -70,6 +70,10 @@ func makeLocalMatrix(b, bg *Image) ([]localImageTest, error) { // TestImage_NewFromLocal tests finding the image locally by various names, // tags, and aliases func TestImage_NewFromLocal(t *testing.T) { + if os.Geteuid() != 0 { // containers/storage requires root access + t.Skipf("Test not running as root") + } + workdir, err := mkWorkDir() assert.NoError(t, err) so := storage.StoreOptions{ @@ -108,6 +112,10 @@ func TestImage_NewFromLocal(t *testing.T) { // TestImage_New tests pulling the image by various names, tags, and from // different registries func TestImage_New(t *testing.T) { + if os.Geteuid() != 0 { // containers/storage requires root access + t.Skipf("Test not running as root") + } + var names []string workdir, err := mkWorkDir() assert.NoError(t, err) @@ -141,6 +149,10 @@ func TestImage_New(t *testing.T) { // TestImage_MatchRepoTag tests the various inputs we need to match // against an image's reponames func TestImage_MatchRepoTag(t *testing.T) { + if os.Geteuid() != 0 { // containers/storage requires root access + t.Skipf("Test not running as root") + } + //Set up workdir, err := mkWorkDir() assert.NoError(t, err) -- cgit v1.2.3-54-g00ecf