diff --git a/virtcontainers/container_test.go b/virtcontainers/container_test.go index 8dfdafc38..c164b72be 100644 --- a/virtcontainers/container_test.go +++ b/virtcontainers/container_test.go @@ -137,6 +137,10 @@ func TestContainerRemoveDrive(t *testing.T) { } func testSetupFakeRootfs(t *testing.T) (testRawFile, loopDev, mntDir string, err error) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + tmpDir, err := ioutil.TempDir("", "") if err != nil { t.Fatal(err) diff --git a/virtcontainers/hyperstart_agent_test.go b/virtcontainers/hyperstart_agent_test.go index 6d8aaae30..b65c19086 100644 --- a/virtcontainers/hyperstart_agent_test.go +++ b/virtcontainers/hyperstart_agent_test.go @@ -282,6 +282,12 @@ func TestHyperCopyFile(t *testing.T) { func TestHyperCleanupSandbox(t *testing.T) { assert := assert.New(t) + defaultSharedDirSaved := defaultSharedDir + defaultSharedDir, _ = ioutil.TempDir("", "hyper-cleanup") + defer func() { + defaultSharedDir = defaultSharedDirSaved + }() + s := Sandbox{ id: "testFoo", } diff --git a/virtcontainers/kata_agent_test.go b/virtcontainers/kata_agent_test.go index 378c4fc65..caad5d782 100644 --- a/virtcontainers/kata_agent_test.go +++ b/virtcontainers/kata_agent_test.go @@ -935,6 +935,12 @@ func TestKataCopyFile(t *testing.T) { func TestKataCleanupSandbox(t *testing.T) { assert := assert.New(t) + kataHostSharedDirSaved := kataHostSharedDir + kataHostSharedDir, _ = ioutil.TempDir("", "kata-cleanup") + defer func() { + kataHostSharedDir = kataHostSharedDirSaved + }() + s := Sandbox{ id: "testFoo", }