mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 04:04:45 +00:00
runtime: Don't use fixed /tmp/mountPoint path
Several tests in kata_agent_test.go create /tmp/mountPoint as a dummy directory to mount. This is not cleaned up after the test. Although it is in /tmp, that's still a little messy and can be confusing to a user. In addition, because it uses the same name every time, it allows for one run of the test to interfere with the next. Use the built in t.TempDir() to use an automatically named and deleted temporary directory instead. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
83979ece18
commit
2eeb5dc223
@ -191,8 +191,7 @@ func TestKataAgentSendReq(t *testing.T) {
|
||||
func TestHandleEphemeralStorage(t *testing.T) {
|
||||
k := kataAgent{}
|
||||
var ociMounts []specs.Mount
|
||||
mountSource := "/tmp/mountPoint"
|
||||
os.Mkdir(mountSource, 0755)
|
||||
mountSource := t.TempDir()
|
||||
|
||||
mount := specs.Mount{
|
||||
Type: KataEphemeralDevType,
|
||||
@ -212,8 +211,7 @@ func TestHandleEphemeralStorage(t *testing.T) {
|
||||
func TestHandleLocalStorage(t *testing.T) {
|
||||
k := kataAgent{}
|
||||
var ociMounts []specs.Mount
|
||||
mountSource := "/tmp/mountPoint"
|
||||
os.Mkdir(mountSource, 0755)
|
||||
mountSource := t.TempDir()
|
||||
|
||||
mount := specs.Mount{
|
||||
Type: KataLocalDevType,
|
||||
@ -688,8 +686,7 @@ func TestHandleShm(t *testing.T) {
|
||||
// In case the type of mount is ephemeral, the container mount is not
|
||||
// shared with the sandbox shm.
|
||||
ociMounts[0].Type = KataEphemeralDevType
|
||||
mountSource := "/tmp/mountPoint"
|
||||
os.Mkdir(mountSource, 0755)
|
||||
mountSource := t.TempDir()
|
||||
ociMounts[0].Source = mountSource
|
||||
k.handleShm(ociMounts, sandbox)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user