From e34194de563c6589a3b72fe5dade8b494098588c Mon Sep 17 00:00:00 2001 From: Daniel Budris Date: Tue, 4 Oct 2022 16:31:07 -0400 Subject: [PATCH] add method to skip privd tests if required --- src/syscall/exec_linux_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go index 181fb1e849..085ee7f7eb 100644 --- a/src/syscall/exec_linux_test.go +++ b/src/syscall/exec_linux_test.go @@ -49,6 +49,12 @@ func skipInContainer(t *testing.T) { } } +func skipPrivilegedTests(t *testing.T) { + if os.Getenv("SKIP_PRIVILEGED_TESTS") == "true" { + t.Skip("skipping this privileged test") + } +} + func skipNoUserNamespaces(t *testing.T) { if _, err := os.Stat("/proc/self/ns/user"); err != nil { if os.IsNotExist(err) { @@ -343,6 +349,7 @@ func TestUnshareMountNameSpaceHelper(*testing.T) { // Test for Issue 38471: unshare fails because systemd has forced / to be shared func TestUnshareMountNameSpace(t *testing.T) { skipInContainer(t) + skipPrivilegedTests(t) // Make sure we are running as root so we have permissions to use unshare // and create a network namespace. if os.Getuid() != 0 { @@ -385,6 +392,7 @@ func TestUnshareMountNameSpace(t *testing.T) { // Test for Issue 20103: unshare fails when chroot is used func TestUnshareMountNameSpaceChroot(t *testing.T) { skipInContainer(t) + skipPrivilegedTests(t) // Make sure we are running as root so we have permissions to use unshare // and create a network namespace. if os.Getuid() != 0 { -- 2.38.1