aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/host/machine_info_linux_test.go
diff options
context:
space:
mode:
authorEng Zer Jun <engzerjun@gmail.com>2022-03-23 16:04:21 +0800
committerAleksandr Nogikh <wp32pw@gmail.com>2022-03-28 12:03:24 +0200
commit0d08379d0a6e5c91206a82e207c6c05f0f9fddc4 (patch)
tree56b9d5c90b545c2d2e7bd74b059b1d1e2be50834 /pkg/host/machine_info_linux_test.go
parent89bc860804252dbacb8c2bea60b9204859f4afd7 (diff)
all: use `t.TempDir` to create temporary test directory
This commit replaces all `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Diffstat (limited to 'pkg/host/machine_info_linux_test.go')
-rw-r--r--pkg/host/machine_info_linux_test.go8
1 files changed, 1 insertions, 7 deletions
diff --git a/pkg/host/machine_info_linux_test.go b/pkg/host/machine_info_linux_test.go
index fdb3f3011..755b792f7 100644
--- a/pkg/host/machine_info_linux_test.go
+++ b/pkg/host/machine_info_linux_test.go
@@ -7,8 +7,6 @@ import (
"bufio"
"bytes"
"fmt"
- "io/ioutil"
- "os"
"path/filepath"
"runtime"
"strings"
@@ -385,11 +383,7 @@ power management:
}
func TestGetGlobsInfo(t *testing.T) {
- dir, err := ioutil.TempDir("", "syz-host-globstest")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(dir)
+ dir := t.TempDir()
if err := osutil.MkdirAll(filepath.Join(dir, "a", "b", "c", "d")); err != nil {
t.Fatal(err)
}