forked from opencontainers/runc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintelrdt_test.go
More file actions
113 lines (107 loc) · 2.07 KB
/
Copy pathintelrdt_test.go
File metadata and controls
113 lines (107 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package validate
import (
"testing"
"github.com/opencontainers/runc/libcontainer/configs"
)
func TestValidateIntelRdt(t *testing.T) {
// Call init to trigger the sync.Once and enable overriding the rdt status
intelRdt.init()
testCases := []struct {
name string
rdtEnabled bool
catEnabled bool
mbaEnabled bool
config *configs.IntelRdt
isErr bool
}{
{
name: "rdt not supported, no config",
},
{
name: "rdt not supported, with config",
config: &configs.IntelRdt{},
isErr: true,
},
{
name: "empty config",
rdtEnabled: true,
config: &configs.IntelRdt{},
},
{
name: "root clos",
rdtEnabled: true,
config: &configs.IntelRdt{
ClosID: "/",
},
},
{
name: "invalid ClosID (.)",
rdtEnabled: true,
config: &configs.IntelRdt{
ClosID: ".",
},
isErr: true,
},
{
name: "invalid ClosID (..)",
rdtEnabled: true,
config: &configs.IntelRdt{
ClosID: "..",
},
isErr: true,
},
{
name: "invalid ClosID (contains /)",
rdtEnabled: true,
config: &configs.IntelRdt{
ClosID: "foo/bar",
},
isErr: true,
},
{
name: "cat not supported",
rdtEnabled: true,
config: &configs.IntelRdt{
L3CacheSchema: "0=ff",
},
isErr: true,
},
{
name: "mba not supported",
rdtEnabled: true,
config: &configs.IntelRdt{
MemBwSchema: "0=100",
},
isErr: true,
},
{
name: "valid config",
rdtEnabled: true,
catEnabled: true,
mbaEnabled: true,
config: &configs.IntelRdt{
ClosID: "clos-1",
L3CacheSchema: "0=ff",
MemBwSchema: "0=100",
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
intelRdt.rdtEnabled = tc.rdtEnabled
intelRdt.catEnabled = tc.catEnabled
intelRdt.mbaEnabled = tc.mbaEnabled
config := &configs.Config{
Rootfs: "/var",
IntelRdt: tc.config,
}
err := Validate(config)
if tc.isErr && err == nil {
t.Error("expected error, got nil")
}
if !tc.isErr && err != nil {
t.Error(err)
}
})
}
}