From aefe72fb5fe5f497624e3b6e94bd571cecebef51 Mon Sep 17 00:00:00 2001 From: Daniel Budris Date: Tue, 4 Oct 2022 16:31:07 -0400 Subject: [PATCH 9/9] 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 d62b80b017..84deb60d2a 100644 --- a/src/syscall/exec_linux_test.go +++ b/src/syscall/exec_linux_test.go @@ -50,6 +50,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) { @@ -337,6 +343,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 { @@ -379,6 +386,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