Skip to content

Commit f66b943

Browse files
committed
refactor TestRunIpcHost
Signed-off-by: Akihiro Suda <[email protected]>
1 parent b7d9eee commit f66b943

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

cmd/nerdctl/run_linux_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,13 @@ func TestRunPidHost(t *testing.T) {
7474
func TestRunIpcHost(t *testing.T) {
7575
t.Parallel()
7676
base := testutil.NewBase(t)
77-
testFile, err := os.Create("/dev/shm/test")
77+
testFilePath := filepath.Join("/dev/shm",
78+
fmt.Sprintf("%s-%d-%s", testutil.Identifier(t), os.Geteuid(), base.Target))
79+
err := os.WriteFile(testFilePath, []byte(""), 0644)
7880
assert.NilError(base.T, err)
81+
defer os.Remove(testFilePath)
7982

80-
defer func() {
81-
testFile.Close()
82-
os.Remove(testFile.Name())
83-
}()
84-
85-
base.Cmd("run", "--rm", "--ipc=host", testutil.AlpineImage, "ls", testFile.Name()).AssertExitCode(0)
83+
base.Cmd("run", "--rm", "--ipc=host", testutil.AlpineImage, "ls", testFilePath).AssertOK()
8684
}
8785

8886
func TestRunAddHost(t *testing.T) {

0 commit comments

Comments
 (0)