From 35076e362689ec433a94a99cc1b974f9fcccd0cf 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 0ec9c4db0f..099696f9a8 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) { @@ -320,6 +326,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 { @@ -362,6 +369,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.30.1 (Apple Git-130)