Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
ut: fix UT failure due to non-root
Browse files Browse the repository at this point in the history
We should allow UT to run without root.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
  • Loading branch information
bergwolf committed Apr 12, 2019
1 parent 6d81e44 commit a0f49a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions virtcontainers/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions virtcontainers/hyperstart_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down
6 changes: 6 additions & 0 deletions virtcontainers/kata_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down

0 comments on commit a0f49a9

Please sign in to comment.