From 7186c01d6e8c0ebaf75db2231613c4ee761e7c4b Mon Sep 17 00:00:00 2001 From: Penny Zheng Date: Fri, 17 Jan 2020 15:29:50 +0800 Subject: [PATCH] unit-test: delete what ioutil.TempFile creates ioutil.TempFile creates a new temporary file in the directory dir. It is the caller's responsibility to remove the file when no longer needed. Fixes: #2398 Signed-off-by: Penny Zheng --- virtcontainers/acrn_arch_base_test.go | 2 ++ virtcontainers/qemu_arch_base_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/virtcontainers/acrn_arch_base_test.go b/virtcontainers/acrn_arch_base_test.go index 69fa55093..9c9c88759 100644 --- a/virtcontainers/acrn_arch_base_test.go +++ b/virtcontainers/acrn_arch_base_test.go @@ -9,6 +9,7 @@ import ( "fmt" "io/ioutil" "net" + "os" "path/filepath" "testing" @@ -128,6 +129,7 @@ func TestAcrnArchBaseAppendImage(t *testing.T) { image, err := ioutil.TempFile("", "img") assert.NoError(err) + defer os.Remove(image.Name()) err = image.Close() assert.NoError(err) diff --git a/virtcontainers/qemu_arch_base_test.go b/virtcontainers/qemu_arch_base_test.go index 5a0432eff..7a91363b3 100644 --- a/virtcontainers/qemu_arch_base_test.go +++ b/virtcontainers/qemu_arch_base_test.go @@ -9,6 +9,7 @@ import ( "fmt" "io/ioutil" "net" + "os" "path/filepath" "testing" @@ -287,6 +288,7 @@ func TestQemuArchBaseAppendImage(t *testing.T) { image, err := ioutil.TempFile("", "img") assert.NoError(err) + defer os.Remove(image.Name()) err = image.Close() assert.NoError(err)