Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/util/system/util_test_tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"os"
"path"
"testing"

"github.com/stretchr/testify/assert"
)

type FileTestUtil struct {
Expand All @@ -32,11 +34,15 @@ type FileTestUtil struct {

// NewFileTestUtil creates a new test util for the specified subsystem
func NewFileTestUtil(t *testing.T) *FileTestUtil {
// NOTE: When $TMPDIR is not set, `t.TempDir()` can use different base directory on Mac OS X and Linux, which may
// generates too long paths to test unix socket.
t.Setenv("TMPDIR", "/tmp")
tempDir := t.TempDir()
HostSystemInfo.IsAnolisOS = true

Conf.ProcRootDir = path.Join(tempDir, "proc")
os.MkdirAll(Conf.ProcRootDir, 0777)
err := os.MkdirAll(Conf.ProcRootDir, 0777)
assert.NoError(t, err)
Conf.CgroupRootDir = tempDir

return &FileTestUtil{TempDir: tempDir, t: t}
Expand Down