Browse code

Skip some tests requires root uid when run as user

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2018/04/20 18:59:08
Showing 16 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 package dockerfile // import "github.com/docker/docker/builder/dockerfile"
2 2
 
3 3
 import (
4
+	"os"
4 5
 	"testing"
5 6
 
6 7
 	"github.com/docker/docker/builder/dockerfile/instructions"
... ...
@@ -8,6 +9,7 @@ import (
8 8
 	"github.com/docker/docker/internal/testutil"
9 9
 	"github.com/docker/docker/pkg/archive"
10 10
 	"github.com/docker/docker/pkg/reexec"
11
+	"github.com/gotestyourself/gotestyourself/skip"
11 12
 )
12 13
 
13 14
 type dispatchTestCase struct {
... ...
@@ -94,6 +96,7 @@ func initDispatchTestCases() []dispatchTestCase {
94 94
 }
95 95
 
96 96
 func TestDispatch(t *testing.T) {
97
+	skip.IfCondition(t, os.Getuid() != 0, "skipping test that requires root")
97 98
 	testCases := initDispatchTestCases()
98 99
 
99 100
 	for _, testCase := range testCases {
... ...
@@ -2,6 +2,7 @@ package dockerfile // import "github.com/docker/docker/builder/dockerfile"
2 2
 
3 3
 import (
4 4
 	"fmt"
5
+	"os"
5 6
 	"runtime"
6 7
 	"testing"
7 8
 
... ...
@@ -14,6 +15,7 @@ import (
14 14
 	"github.com/docker/go-connections/nat"
15 15
 	"github.com/gotestyourself/gotestyourself/assert"
16 16
 	is "github.com/gotestyourself/gotestyourself/assert/cmp"
17
+	"github.com/gotestyourself/gotestyourself/skip"
17 18
 )
18 19
 
19 20
 func TestEmptyDockerfile(t *testing.T) {
... ...
@@ -59,6 +61,7 @@ func TestNonExistingDockerfile(t *testing.T) {
59 59
 }
60 60
 
61 61
 func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath, expectedError string) {
62
+	skip.IfCondition(t, os.Getuid() != 0, "skipping test that requires root")
62 63
 	tarStream, err := archive.Tar(contextDir, archive.Uncompressed)
63 64
 	assert.NilError(t, err)
64 65
 
... ...
@@ -9,6 +9,7 @@ import (
9 9
 	"github.com/docker/docker/builder"
10 10
 	"github.com/docker/docker/pkg/archive"
11 11
 	"github.com/docker/docker/pkg/reexec"
12
+	"github.com/gotestyourself/gotestyourself/skip"
12 13
 	"github.com/pkg/errors"
13 14
 )
14 15
 
... ...
@@ -136,6 +137,7 @@ func TestRemoveDirectory(t *testing.T) {
136 136
 }
137 137
 
138 138
 func makeTestArchiveContext(t *testing.T, dir string) builder.Source {
139
+	skip.IfCondition(t, os.Getuid() != 0, "skipping test that requires root")
139 140
 	tarStream, err := archive.Tar(dir, archive.Uncompressed)
140 141
 	if err != nil {
141 142
 		t.Fatalf("error: %s", err)
... ...
@@ -12,6 +12,7 @@ import (
12 12
 	"github.com/gotestyourself/gotestyourself/assert"
13 13
 	is "github.com/gotestyourself/gotestyourself/assert/cmp"
14 14
 	"github.com/gotestyourself/gotestyourself/fs"
15
+	"github.com/gotestyourself/gotestyourself/skip"
15 16
 	"github.com/spf13/pflag"
16 17
 )
17 18
 
... ...
@@ -432,6 +433,7 @@ func TestReloadSetConfigFileNotExist(t *testing.T) {
432 432
 // TestReloadDefaultConfigNotExist tests that if the default configuration file
433 433
 // doesn't exist the daemon still will be reloaded.
434 434
 func TestReloadDefaultConfigNotExist(t *testing.T) {
435
+	skip.IfCondition(t, os.Getuid() != 0, "skipping test that requires root")
435 436
 	reloaded := false
436 437
 	configFile := "/etc/docker/daemon.json"
437 438
 	flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
... ...
@@ -9,6 +9,7 @@ import (
9 9
 
10 10
 	"github.com/docker/docker/pkg/system"
11 11
 	"github.com/gotestyourself/gotestyourself/assert"
12
+	"github.com/gotestyourself/gotestyourself/skip"
12 13
 	"golang.org/x/sys/unix"
13 14
 )
14 15
 
... ...
@@ -22,6 +23,7 @@ import (
22 22
 // └── d3     # 0700
23 23
 //     └── f1 # whiteout, 0644
24 24
 func setupOverlayTestDir(t *testing.T, src string) {
25
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
25 26
 	// Create opaque directory containing single file and permission 0700
26 27
 	err := os.Mkdir(filepath.Join(src, "d1"), 0700)
27 28
 	assert.NilError(t, err)
... ...
@@ -20,6 +20,7 @@ import (
20 20
 	"github.com/docker/docker/pkg/ioutils"
21 21
 	"github.com/gotestyourself/gotestyourself/assert"
22 22
 	is "github.com/gotestyourself/gotestyourself/assert/cmp"
23
+	"github.com/gotestyourself/gotestyourself/skip"
23 24
 )
24 25
 
25 26
 var tmp string
... ...
@@ -304,6 +305,7 @@ func TestUntarPathWithInvalidSrc(t *testing.T) {
304 304
 }
305 305
 
306 306
 func TestUntarPath(t *testing.T) {
307
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
307 308
 	tmpFolder, err := ioutil.TempDir("", "docker-archive-test")
308 309
 	assert.NilError(t, err)
309 310
 	defer os.RemoveAll(tmpFolder)
... ...
@@ -434,6 +436,7 @@ func TestCopyWithTarInvalidSrc(t *testing.T) {
434 434
 }
435 435
 
436 436
 func TestCopyWithTarInexistentDestWillCreateIt(t *testing.T) {
437
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
437 438
 	tempFolder, err := ioutil.TempDir("", "docker-archive-test")
438 439
 	if err != nil {
439 440
 		t.Fatal(nil)
... ...
@@ -968,9 +971,8 @@ func TestUntarInvalidFilenames(t *testing.T) {
968 968
 
969 969
 func TestUntarHardlinkToSymlink(t *testing.T) {
970 970
 	// TODO Windows. There may be a way of running this, but turning off for now
971
-	if runtime.GOOS == "windows" {
972
-		t.Skip("hardlinks on Windows")
973
-	}
971
+	skip.If(t, runtime.GOOS == "windows", "hardlinks on Windows")
972
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
974 973
 	for i, headers := range [][]*tar.Header{
975 974
 		{
976 975
 			{
... ...
@@ -1252,6 +1254,7 @@ func TestReplaceFileTarWrapper(t *testing.T) {
1252 1252
 // TestPrefixHeaderReadable tests that files that could be created with the
1253 1253
 // version of this package that was built with <=go17 are still readable.
1254 1254
 func TestPrefixHeaderReadable(t *testing.T) {
1255
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
1255 1256
 	// https://gist.github.com/stevvooe/e2a790ad4e97425896206c0816e1a882#file-out-go
1256 1257
 	var testFile = []byte("\x1f\x8b\x08\x08\x44\x21\x68\x59\x00\x03\x74\x2e\x74\x61\x72\x00\x4b\xcb\xcf\x67\xa0\x35\x30\x80\x00\x86\x06\x10\x47\x01\xc1\x37\x40\x00\x54\xb6\xb1\xa1\xa9\x99\x09\x48\x25\x1d\x40\x69\x71\x49\x62\x91\x02\xe5\x76\xa1\x79\x84\x21\x91\xd6\x80\x72\xaf\x8f\x82\x51\x30\x0a\x46\x36\x00\x00\xf0\x1c\x1e\x95\x00\x06\x00\x00")
1257 1258
 
... ...
@@ -1309,6 +1312,7 @@ func appendModifier(path string, header *tar.Header, content io.Reader) (*tar.He
1309 1309
 }
1310 1310
 
1311 1311
 func readFileFromArchive(t *testing.T, archive io.ReadCloser, name string, expectedCount int, doc string) string {
1312
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
1312 1313
 	destDir, err := ioutil.TempDir("", "docker-test-destDir")
1313 1314
 	assert.NilError(t, err)
1314 1315
 	defer os.RemoveAll(destDir)
... ...
@@ -15,6 +15,7 @@ import (
15 15
 	"github.com/docker/docker/pkg/system"
16 16
 	"github.com/gotestyourself/gotestyourself/assert"
17 17
 	is "github.com/gotestyourself/gotestyourself/assert/cmp"
18
+	"github.com/gotestyourself/gotestyourself/skip"
18 19
 	"golang.org/x/sys/unix"
19 20
 )
20 21
 
... ...
@@ -183,6 +184,7 @@ func getInode(path string) (uint64, error) {
183 183
 }
184 184
 
185 185
 func TestTarWithBlockCharFifo(t *testing.T) {
186
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
186 187
 	origin, err := ioutil.TempDir("", "docker-test-tar-hardlink")
187 188
 	assert.NilError(t, err)
188 189
 
... ...
@@ -223,6 +225,7 @@ func TestTarWithBlockCharFifo(t *testing.T) {
223 223
 
224 224
 // TestTarUntarWithXattr is Unix as Lsetxattr is not supported on Windows
225 225
 func TestTarUntarWithXattr(t *testing.T) {
226
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
226 227
 	origin, err := ioutil.TempDir("", "docker-test-untar-origin")
227 228
 	assert.NilError(t, err)
228 229
 	defer os.RemoveAll(origin)
... ...
@@ -12,6 +12,7 @@ import (
12 12
 
13 13
 	"github.com/docker/docker/pkg/system"
14 14
 	"github.com/gotestyourself/gotestyourself/assert"
15
+	"github.com/gotestyourself/gotestyourself/skip"
15 16
 )
16 17
 
17 18
 func max(x, y int) int {
... ...
@@ -480,6 +481,7 @@ func TestChangesSize(t *testing.T) {
480 480
 }
481 481
 
482 482
 func checkChanges(expectedChanges, changes []Change, t *testing.T) {
483
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
483 484
 	sort.Sort(changesByPath(expectedChanges))
484 485
 	sort.Sort(changesByPath(changes))
485 486
 	for i := 0; i < max(len(changes), len(expectedChanges)); i++ {
... ...
@@ -16,6 +16,7 @@ import (
16 16
 	"github.com/docker/docker/pkg/archive"
17 17
 	"github.com/docker/docker/pkg/reexec"
18 18
 	"github.com/docker/docker/pkg/system"
19
+	"github.com/gotestyourself/gotestyourself/skip"
19 20
 )
20 21
 
21 22
 func init() {
... ...
@@ -41,6 +42,7 @@ func CopyWithTar(src, dst string) error {
41 41
 }
42 42
 
43 43
 func TestChrootTarUntar(t *testing.T) {
44
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
44 45
 	tmpdir, err := ioutil.TempDir("", "docker-TestChrootTarUntar")
45 46
 	if err != nil {
46 47
 		t.Fatal(err)
... ...
@@ -72,6 +74,7 @@ func TestChrootTarUntar(t *testing.T) {
72 72
 // gh#10426: Verify the fix for having a huge excludes list (like on `docker load` with large # of
73 73
 // local images)
74 74
 func TestChrootUntarWithHugeExcludesList(t *testing.T) {
75
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
75 76
 	tmpdir, err := ioutil.TempDir("", "docker-TestChrootUntarHugeExcludes")
76 77
 	if err != nil {
77 78
 		t.Fatal(err)
... ...
@@ -170,10 +173,8 @@ func compareFiles(src string, dest string) error {
170 170
 }
171 171
 
172 172
 func TestChrootTarUntarWithSymlink(t *testing.T) {
173
-	// TODO Windows: Figure out why this is failing
174
-	if runtime.GOOS == "windows" {
175
-		t.Skip("Failing on Windows")
176
-	}
173
+	skip.If(t, runtime.GOOS == "windows", "FIXME: figure out why this is failing")
174
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
177 175
 	tmpdir, err := ioutil.TempDir("", "docker-TestChrootTarUntarWithSymlink")
178 176
 	if err != nil {
179 177
 		t.Fatal(err)
... ...
@@ -196,10 +197,8 @@ func TestChrootTarUntarWithSymlink(t *testing.T) {
196 196
 }
197 197
 
198 198
 func TestChrootCopyWithTar(t *testing.T) {
199
-	// TODO Windows: Figure out why this is failing
200
-	if runtime.GOOS == "windows" {
201
-		t.Skip("Failing on Windows")
202
-	}
199
+	skip.If(t, runtime.GOOS == "windows", "FIXME: figure out why this is failing")
200
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
203 201
 	tmpdir, err := ioutil.TempDir("", "docker-TestChrootCopyWithTar")
204 202
 	if err != nil {
205 203
 		t.Fatal(err)
... ...
@@ -246,6 +245,7 @@ func TestChrootCopyWithTar(t *testing.T) {
246 246
 }
247 247
 
248 248
 func TestChrootCopyFileWithTar(t *testing.T) {
249
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
249 250
 	tmpdir, err := ioutil.TempDir("", "docker-TestChrootCopyFileWithTar")
250 251
 	if err != nil {
251 252
 		t.Fatal(err)
... ...
@@ -289,10 +289,8 @@ func TestChrootCopyFileWithTar(t *testing.T) {
289 289
 }
290 290
 
291 291
 func TestChrootUntarPath(t *testing.T) {
292
-	// TODO Windows: Figure out why this is failing
293
-	if runtime.GOOS == "windows" {
294
-		t.Skip("Failing on Windows")
295
-	}
292
+	skip.If(t, runtime.GOOS == "windows", "FIXME: figure out why this is failing")
293
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
296 294
 	tmpdir, err := ioutil.TempDir("", "docker-TestChrootUntarPath")
297 295
 	if err != nil {
298 296
 		t.Fatal(err)
... ...
@@ -354,6 +352,7 @@ func (s *slowEmptyTarReader) Read(p []byte) (int, error) {
354 354
 }
355 355
 
356 356
 func TestChrootUntarEmptyArchiveFromSlowReader(t *testing.T) {
357
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
357 358
 	tmpdir, err := ioutil.TempDir("", "docker-TestChrootUntarEmptyArchiveFromSlowReader")
358 359
 	if err != nil {
359 360
 		t.Fatal(err)
... ...
@@ -370,6 +369,7 @@ func TestChrootUntarEmptyArchiveFromSlowReader(t *testing.T) {
370 370
 }
371 371
 
372 372
 func TestChrootApplyEmptyArchiveFromSlowReader(t *testing.T) {
373
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
373 374
 	tmpdir, err := ioutil.TempDir("", "docker-TestChrootApplyEmptyArchiveFromSlowReader")
374 375
 	if err != nil {
375 376
 		t.Fatal(err)
... ...
@@ -386,6 +386,7 @@ func TestChrootApplyEmptyArchiveFromSlowReader(t *testing.T) {
386 386
 }
387 387
 
388 388
 func TestChrootApplyDotDotFile(t *testing.T) {
389
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
389 390
 	tmpdir, err := ioutil.TempDir("", "docker-TestChrootApplyDotDotFile")
390 391
 	if err != nil {
391 392
 		t.Fatal(err)
... ...
@@ -393,5 +393,5 @@ func TestMkdirIsNotDir(t *testing.T) {
393 393
 }
394 394
 
395 395
 func RequiresRoot(t *testing.T) {
396
-	skip.IfCondition(t, os.Getuid() != 0, "skipping test that requires root")
396
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
397 397
 }
... ...
@@ -9,6 +9,7 @@ import (
9 9
 	"time"
10 10
 
11 11
 	"github.com/docker/docker/pkg/mount"
12
+	"github.com/gotestyourself/gotestyourself/skip"
12 13
 )
13 14
 
14 15
 func TestEnsureRemoveAllNotExist(t *testing.T) {
... ...
@@ -40,9 +41,8 @@ func TestEnsureRemoveAllWithFile(t *testing.T) {
40 40
 }
41 41
 
42 42
 func TestEnsureRemoveAllWithMount(t *testing.T) {
43
-	if runtime.GOOS == "windows" {
44
-		t.Skip("mount not supported on Windows")
45
-	}
43
+	skip.If(t, runtime.GOOS == "windows", "mount not supported on Windows")
44
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
46 45
 
47 46
 	dir1, err := ioutil.TempDir("", "test-ensure-removeall-with-dir1")
48 47
 	if err != nil {
... ...
@@ -11,11 +11,13 @@ import (
11 11
 	"github.com/docker/docker/pkg/mount"
12 12
 	"github.com/docker/docker/pkg/system"
13 13
 	"github.com/docker/docker/plugin/v2"
14
+	"github.com/gotestyourself/gotestyourself/skip"
14 15
 	specs "github.com/opencontainers/runtime-spec/specs-go"
15 16
 	"github.com/pkg/errors"
16 17
 )
17 18
 
18 19
 func TestManagerWithPluginMounts(t *testing.T) {
20
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
19 21
 	root, err := ioutil.TempDir("", "test-store-with-plugin-mounts")
20 22
 	if err != nil {
21 23
 		t.Fatal(err)
... ...
@@ -5,6 +5,7 @@ import (
5 5
 	"net/http"
6 6
 	"net/http/httputil"
7 7
 	"net/url"
8
+	"os"
8 9
 	"strings"
9 10
 	"testing"
10 11
 
... ...
@@ -13,6 +14,7 @@ import (
13 13
 	"github.com/docker/docker/api/types"
14 14
 	registrytypes "github.com/docker/docker/api/types/registry"
15 15
 	"github.com/gotestyourself/gotestyourself/assert"
16
+	"github.com/gotestyourself/gotestyourself/skip"
16 17
 )
17 18
 
18 19
 var (
... ...
@@ -53,6 +55,7 @@ func spawnTestRegistrySession(t *testing.T) *Session {
53 53
 }
54 54
 
55 55
 func TestPingRegistryEndpoint(t *testing.T) {
56
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
56 57
 	testPing := func(index *registrytypes.IndexInfo, expectedStandalone bool, assertMessage string) {
57 58
 		ep, err := NewV1Endpoint(index, "", nil)
58 59
 		if err != nil {
... ...
@@ -72,6 +75,7 @@ func TestPingRegistryEndpoint(t *testing.T) {
72 72
 }
73 73
 
74 74
 func TestEndpoint(t *testing.T) {
75
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
75 76
 	// Simple wrapper to fail test if err != nil
76 77
 	expandEndpoint := func(index *registrytypes.IndexInfo) *V1Endpoint {
77 78
 		endpoint, err := NewV1Endpoint(index, "", nil)
... ...
@@ -661,6 +665,7 @@ func TestNewIndexInfo(t *testing.T) {
661 661
 }
662 662
 
663 663
 func TestMirrorEndpointLookup(t *testing.T) {
664
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
664 665
 	containsMirror := func(endpoints []APIEndpoint) bool {
665 666
 		for _, pe := range endpoints {
666 667
 			if pe.URL.Host == "my.mirror" {
... ...
@@ -1,8 +1,14 @@
1 1
 package registry // import "github.com/docker/docker/registry"
2 2
 
3
-import "testing"
3
+import (
4
+	"os"
5
+	"testing"
6
+
7
+	"github.com/gotestyourself/gotestyourself/skip"
8
+)
4 9
 
5 10
 func TestLookupV1Endpoints(t *testing.T) {
11
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
6 12
 	s, err := NewService(ServiceOptions{})
7 13
 	if err != nil {
8 14
 		t.Fatal(err)
... ...
@@ -11,6 +11,7 @@ import (
11 11
 
12 12
 	"github.com/docker/docker/pkg/idtools"
13 13
 	"github.com/docker/docker/pkg/mount"
14
+	"github.com/gotestyourself/gotestyourself/skip"
14 15
 )
15 16
 
16 17
 func TestGetAddress(t *testing.T) {
... ...
@@ -30,11 +31,8 @@ func TestGetAddress(t *testing.T) {
30 30
 }
31 31
 
32 32
 func TestRemove(t *testing.T) {
33
-	// TODO Windows: Investigate why this test fails on Windows under CI
34
-	//               but passes locally.
35
-	if runtime.GOOS == "windows" {
36
-		t.Skip("Test failing on Windows CI")
37
-	}
33
+	skip.If(t, runtime.GOOS == "windows", "FIXME: investigate why this test fails on CI")
34
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
38 35
 	rootDir, err := ioutil.TempDir("", "local-volume-test")
39 36
 	if err != nil {
40 37
 		t.Fatal(err)
... ...
@@ -77,6 +75,7 @@ func TestRemove(t *testing.T) {
77 77
 }
78 78
 
79 79
 func TestInitializeWithVolumes(t *testing.T) {
80
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
80 81
 	rootDir, err := ioutil.TempDir("", "local-volume-test")
81 82
 	if err != nil {
82 83
 		t.Fatal(err)
... ...
@@ -109,6 +108,7 @@ func TestInitializeWithVolumes(t *testing.T) {
109 109
 }
110 110
 
111 111
 func TestCreate(t *testing.T) {
112
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
112 113
 	rootDir, err := ioutil.TempDir("", "local-volume-test")
113 114
 	if err != nil {
114 115
 		t.Fatal(err)
... ...
@@ -181,13 +181,8 @@ func TestValidateName(t *testing.T) {
181 181
 }
182 182
 
183 183
 func TestCreateWithOpts(t *testing.T) {
184
-	if runtime.GOOS == "windows" {
185
-		t.Skip()
186
-	}
187
-	if os.Getuid() != 0 {
188
-		t.Skip("root required")
189
-	}
190
-
184
+	skip.If(t, runtime.GOOS == "windows")
185
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
191 186
 	rootDir, err := ioutil.TempDir("", "local-volume-test")
192 187
 	if err != nil {
193 188
 		t.Fatal(err)
... ...
@@ -284,7 +279,8 @@ func TestCreateWithOpts(t *testing.T) {
284 284
 	}
285 285
 }
286 286
 
287
-func TestRealodNoOpts(t *testing.T) {
287
+func TestRelaodNoOpts(t *testing.T) {
288
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
288 289
 	rootDir, err := ioutil.TempDir("", "volume-test-reload-no-opts")
289 290
 	if err != nil {
290 291
 		t.Fatal(err)
... ...
@@ -15,9 +15,11 @@ import (
15 15
 	"github.com/google/go-cmp/cmp"
16 16
 	"github.com/gotestyourself/gotestyourself/assert"
17 17
 	is "github.com/gotestyourself/gotestyourself/assert/cmp"
18
+	"github.com/gotestyourself/gotestyourself/skip"
18 19
 )
19 20
 
20 21
 func TestCreate(t *testing.T) {
22
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
21 23
 	t.Parallel()
22 24
 
23 25
 	s, cleanup := setupTest(t)
... ...
@@ -47,6 +49,7 @@ func TestCreate(t *testing.T) {
47 47
 }
48 48
 
49 49
 func TestRemove(t *testing.T) {
50
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
50 51
 	t.Parallel()
51 52
 
52 53
 	s, cleanup := setupTest(t)
... ...
@@ -125,6 +128,7 @@ func TestList(t *testing.T) {
125 125
 }
126 126
 
127 127
 func TestFilterByDriver(t *testing.T) {
128
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
128 129
 	t.Parallel()
129 130
 	s, cleanup := setupTest(t)
130 131
 	defer cleanup()
... ...
@@ -152,6 +156,7 @@ func TestFilterByDriver(t *testing.T) {
152 152
 }
153 153
 
154 154
 func TestFilterByUsed(t *testing.T) {
155
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
155 156
 	t.Parallel()
156 157
 	s, cleanup := setupTest(t)
157 158
 	defer cleanup()
... ...
@@ -189,6 +194,7 @@ func TestFilterByUsed(t *testing.T) {
189 189
 }
190 190
 
191 191
 func TestDerefMultipleOfSameRef(t *testing.T) {
192
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
192 193
 	t.Parallel()
193 194
 	s, cleanup := setupTest(t)
194 195
 	defer cleanup()
... ...
@@ -210,6 +216,7 @@ func TestDerefMultipleOfSameRef(t *testing.T) {
210 210
 }
211 211
 
212 212
 func TestCreateKeepOptsLabelsWhenExistsRemotely(t *testing.T) {
213
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
213 214
 	t.Parallel()
214 215
 	s, cleanup := setupTest(t)
215 216
 	defer cleanup()
... ...
@@ -238,6 +245,7 @@ func TestCreateKeepOptsLabelsWhenExistsRemotely(t *testing.T) {
238 238
 }
239 239
 
240 240
 func TestDefererencePluginOnCreateError(t *testing.T) {
241
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
241 242
 	t.Parallel()
242 243
 
243 244
 	var (
... ...
@@ -284,6 +292,7 @@ func TestDefererencePluginOnCreateError(t *testing.T) {
284 284
 }
285 285
 
286 286
 func TestRefDerefRemove(t *testing.T) {
287
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
287 288
 	t.Parallel()
288 289
 
289 290
 	driverName := "test-ref-deref-remove"
... ...
@@ -304,6 +313,7 @@ func TestRefDerefRemove(t *testing.T) {
304 304
 }
305 305
 
306 306
 func TestGet(t *testing.T) {
307
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
307 308
 	t.Parallel()
308 309
 
309 310
 	driverName := "test-get"
... ...
@@ -330,6 +340,7 @@ func TestGet(t *testing.T) {
330 330
 }
331 331
 
332 332
 func TestGetWithRef(t *testing.T) {
333
+	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
333 334
 	t.Parallel()
334 335
 
335 336
 	driverName := "test-get-with-ref"