...
1
5 package intelrdt
6
7 import (
8 "os"
9 "path/filepath"
10 "testing"
11
12 "github.com/opencontainers/runc/libcontainer/configs"
13 )
14
15 type intelRdtTestUtil struct {
16 config *configs.Config
17
18
19 IntelRdtPath string
20
21 t *testing.T
22 }
23
24
25 func NewIntelRdtTestUtil(t *testing.T) *intelRdtTestUtil {
26 config := &configs.Config{
27 IntelRdt: &configs.IntelRdt{},
28 }
29
30
31 intelRdtRoot = t.TempDir()
32
33 rootOnce.Do(func() {})
34
35 testIntelRdtPath := filepath.Join(intelRdtRoot, "resctrl")
36
37
38 if err := os.MkdirAll(testIntelRdtPath, 0o755); err != nil {
39 t.Fatal(err)
40 }
41 return &intelRdtTestUtil{config: config, IntelRdtPath: testIntelRdtPath, t: t}
42 }
43
44
45 func (c *intelRdtTestUtil) writeFileContents(fileContents map[string]string) {
46 for file, contents := range fileContents {
47 err := writeFile(c.IntelRdtPath, file, contents)
48 if err != nil {
49 c.t.Fatal(err)
50 }
51 }
52 }
53
View as plain text