Browse code

pkg/archive: annotate tests that requires initial userns

`rootlesskit go test ./pkg/archive` now succeeds

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>

Akihiro Suda authored on 2018/11/29 16:38:55
Showing 3 changed files
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"testing"
9 9
 
10 10
 	"github.com/docker/docker/pkg/system"
11
+	rsystem "github.com/opencontainers/runc/libcontainer/system"
11 12
 	"golang.org/x/sys/unix"
12 13
 	"gotest.tools/assert"
13 14
 	"gotest.tools/skip"
... ...
@@ -24,6 +25,7 @@ import (
24 24
 //     └── f1 # whiteout, 0644
25 25
 func setupOverlayTestDir(t *testing.T, src string) {
26 26
 	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
27
+	skip.If(t, rsystem.RunningInUserNS(), "skipping test that requires initial userns (trusted.overlay.opaque xattr cannot be set in userns, even with Ubuntu kernel)")
27 28
 	// Create opaque directory containing single file and permission 0700
28 29
 	err := os.Mkdir(filepath.Join(src, "d1"), 0700)
29 30
 	assert.NilError(t, err)
... ...
@@ -18,6 +18,7 @@ import (
18 18
 
19 19
 	"github.com/docker/docker/pkg/idtools"
20 20
 	"github.com/docker/docker/pkg/ioutils"
21
+	rsystem "github.com/opencontainers/runc/libcontainer/system"
21 22
 	"gotest.tools/assert"
22 23
 	is "gotest.tools/assert/cmp"
23 24
 	"gotest.tools/skip"
... ...
@@ -1229,6 +1230,7 @@ func TestReplaceFileTarWrapper(t *testing.T) {
1229 1229
 // version of this package that was built with <=go17 are still readable.
1230 1230
 func TestPrefixHeaderReadable(t *testing.T) {
1231 1231
 	skip.If(t, runtime.GOOS != "windows" && os.Getuid() != 0, "skipping test that requires root")
1232
+	skip.If(t, rsystem.RunningInUserNS(), "skipping test that requires more than 010000000 UIDs, which is unlikely to be satisfied when running in userns")
1232 1233
 	// https://gist.github.com/stevvooe/e2a790ad4e97425896206c0816e1a882#file-out-go
1233 1234
 	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")
1234 1235
 
... ...
@@ -14,6 +14,7 @@ import (
14 14
 	"testing"
15 15
 
16 16
 	"github.com/docker/docker/pkg/system"
17
+	rsystem "github.com/opencontainers/runc/libcontainer/system"
17 18
 	"golang.org/x/sys/unix"
18 19
 	"gotest.tools/assert"
19 20
 	is "gotest.tools/assert/cmp"
... ...
@@ -182,6 +183,7 @@ func getInode(path string) (uint64, error) {
182 182
 
183 183
 func TestTarWithBlockCharFifo(t *testing.T) {
184 184
 	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
185
+	skip.If(t, rsystem.RunningInUserNS(), "skipping test that requires initial userns")
185 186
 	origin, err := ioutil.TempDir("", "docker-test-tar-hardlink")
186 187
 	assert.NilError(t, err)
187 188