Skip to content

Commit

Permalink
add method to skip privd tests if required
Browse files Browse the repository at this point in the history
  • Loading branch information
danbudris authored and rcrozean committed Oct 12, 2022
1 parent 7f7f8c8 commit e141d50
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/syscall/exec_linux_test.go
Expand Up @@ -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) {
Expand Down Expand Up @@ -344,6 +350,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 {
Expand Down Expand Up @@ -386,6 +393,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 {
Expand Down

0 comments on commit e141d50

Please sign in to comment.