MCPcopy Create free account
hub / github.com/containerd/cgroups / TestAddTaskFilteredSubsystems

Function TestAddTaskFilteredSubsystems

cgroup1/cgroup_test.go:203–247  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

201}
202
203func TestAddTaskFilteredSubsystems(t *testing.T) {
204 mock, err := newMock(t)
205 if err != nil {
206 t.Fatal(err)
207 }
208 defer func() {
209 if err := mock.delete(); err != nil {
210 t.Errorf("failed delete: %v", err)
211 }
212 }()
213 control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
214 if err != nil {
215 t.Error(err)
216 return
217 }
218 filteredSubsystems := []Name{"memory", "cpu"}
219 if err := control.AddTask(Process{Pid: 1234}, filteredSubsystems...); err != nil {
220 t.Error(err)
221 return
222 }
223 for _, s := range filteredSubsystems {
224 if err := checkTaskid(mock, filepath.Join(string(s), "test"), 1234); err != nil {
225 t.Error(err)
226 return
227 }
228 }
229
230 if err := checkTaskid(mock, filepath.Join("devices", "test"), 1234); err == nil {
231 t.Error("Task should not be added to the devices subsystem")
232 return
233 }
234
235 bogusSubsystems := append(filteredSubsystems, "bogus")
236 if err := control.AddTask(Process{Pid: 5678}, bogusSubsystems...); err != nil {
237 t.Error(err)
238 return
239 }
240
241 for _, s := range filteredSubsystems {
242 if err := checkTaskid(mock, filepath.Join(string(s), "test"), 5678); err != nil {
243 t.Error(err)
244 return
245 }
246 }
247}
248
249func TestListPids(t *testing.T) {
250 mock, err := newMock(t)

Callers

nothing calls this directly

Calls 7

newMockFunction · 0.85
NewFunction · 0.85
StaticPathFunction · 0.85
WithHierarchyFunction · 0.85
checkTaskidFunction · 0.85
deleteMethod · 0.80
AddTaskMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…