mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-14 15:44:58 +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>
(cherry picked from commit 2eeb5dc223
)
Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
dc1288de8d
commit
688b9abd35
@ -191,8 +191,7 @@ func TestKataAgentSendReq(t *testing.T) {
|
|||||||
func TestHandleEphemeralStorage(t *testing.T) {
|
func TestHandleEphemeralStorage(t *testing.T) {
|
||||||
k := kataAgent{}
|
k := kataAgent{}
|
||||||
var ociMounts []specs.Mount
|
var ociMounts []specs.Mount
|
||||||
mountSource := "/tmp/mountPoint"
|
mountSource := t.TempDir()
|
||||||
os.Mkdir(mountSource, 0755)
|
|
||||||
|
|
||||||
mount := specs.Mount{
|
mount := specs.Mount{
|
||||||
Type: KataEphemeralDevType,
|
Type: KataEphemeralDevType,
|
||||||
@ -212,8 +211,7 @@ func TestHandleEphemeralStorage(t *testing.T) {
|
|||||||
func TestHandleLocalStorage(t *testing.T) {
|
func TestHandleLocalStorage(t *testing.T) {
|
||||||
k := kataAgent{}
|
k := kataAgent{}
|
||||||
var ociMounts []specs.Mount
|
var ociMounts []specs.Mount
|
||||||
mountSource := "/tmp/mountPoint"
|
mountSource := t.TempDir()
|
||||||
os.Mkdir(mountSource, 0755)
|
|
||||||
|
|
||||||
mount := specs.Mount{
|
mount := specs.Mount{
|
||||||
Type: KataLocalDevType,
|
Type: KataLocalDevType,
|
||||||
@ -688,8 +686,7 @@ func TestHandleShm(t *testing.T) {
|
|||||||
// In case the type of mount is ephemeral, the container mount is not
|
// In case the type of mount is ephemeral, the container mount is not
|
||||||
// shared with the sandbox shm.
|
// shared with the sandbox shm.
|
||||||
ociMounts[0].Type = KataEphemeralDevType
|
ociMounts[0].Type = KataEphemeralDevType
|
||||||
mountSource := "/tmp/mountPoint"
|
mountSource := t.TempDir()
|
||||||
os.Mkdir(mountSource, 0755)
|
|
||||||
ociMounts[0].Source = mountSource
|
ociMounts[0].Source = mountSource
|
||||||
k.handleShm(ociMounts, sandbox)
|
k.handleShm(ociMounts, sandbox)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user