diff --git a/virtcontainers/api_test.go b/virtcontainers/api_test.go index 714586d4fd..3601b69cef 100644 --- a/virtcontainers/api_test.go +++ b/virtcontainers/api_test.go @@ -279,6 +279,10 @@ func testGenerateCCProxySockDir() (string, error) { } func TestCreatePodHyperstartAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigHyperstartAgent() @@ -308,6 +312,10 @@ func TestCreatePodHyperstartAgentSuccessful(t *testing.T) { } func TestCreatePodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() @@ -383,6 +391,10 @@ func TestDeletePodNoopAgentSuccessful(t *testing.T) { } func TestDeletePodHyperstartAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigHyperstartAgent() @@ -422,6 +434,10 @@ func TestDeletePodHyperstartAgentSuccessful(t *testing.T) { } func TestDeletePodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() @@ -527,6 +543,10 @@ func TestStartPodHyperstartAgentSuccessful(t *testing.T) { } func TestStartPodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() @@ -685,6 +705,10 @@ func TestStopPodHyperstartAgentSuccessful(t *testing.T) { } func TestStopPodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() @@ -791,6 +815,10 @@ func TestRunPodHyperstartAgentSuccessful(t *testing.T) { } func TestRunPodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() diff --git a/virtcontainers/container_test.go b/virtcontainers/container_test.go index a2e7a063f3..1fac1c2073 100644 --- a/virtcontainers/container_test.go +++ b/virtcontainers/container_test.go @@ -193,6 +193,10 @@ func cleanupFakeRootfsSetup(testRawFile, loopDev, mntDir string) { } func TestContainerAddDriveDir(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + testRawFile, loopDev, fakeRootfs, err := testSetupFakeRootfs(t) defer cleanupFakeRootfsSetup(testRawFile, loopDev, fakeRootfs) diff --git a/virtcontainers/network_test.go b/virtcontainers/network_test.go index db63de80b6..1cb04b8359 100644 --- a/virtcontainers/network_test.go +++ b/virtcontainers/network_test.go @@ -309,6 +309,10 @@ func TestCreateVirtualNetworkEndpointInvalidArgs(t *testing.T) { } func TestIsPhysicalIface(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + testNetIface := "testIface0" testMTU := 1500 testMACAddr := "00:00:00:00:00:01"