From efcec3674a9ef78993b011eb7853c80e324d928c Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Wed, 18 Oct 2017 10:38:34 -0700 Subject: [PATCH] Skip user namespace tests in kernels which have it disabled Signed-off-by: Derek McGowan --- container_linux_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/container_linux_test.go b/container_linux_test.go index aa53fc487..0fc439526 100644 --- a/container_linux_test.go +++ b/container_linux_test.go @@ -987,7 +987,20 @@ func TestUserNamespaces(t *testing.T) { t.Run("ReadonlyRootFS", func(t *testing.T) { testUserNamespaces(t, true) }) } +func checkUserNS(t *testing.T) { + cmd := exec.Command("true") + cmd.SysProcAttr = &syscall.SysProcAttr{ + Cloneflags: syscall.CLONE_NEWUSER, + } + + if err := cmd.Run(); err != nil { + t.Skip("User namespaces are unavailable") + } +} + func testUserNamespaces(t *testing.T, readonlyRootFS bool) { + checkUserNS(t) + client, err := newClient(t, address) if err != nil { t.Fatal(err)