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

Function Test_getOomControlValue

cgroup1/memory_test.go:291–345  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

289}
290
291func Test_getOomControlValue(t *testing.T) {
292 var (
293 oneInt64 int64 = 1
294 zeroInt64 int64 = 0
295 trueBool = true
296 falseBool = false
297 )
298
299 type args struct {
300 mem *specs.LinuxMemory
301 }
302 tests := []struct {
303 name string
304 args args
305 want *int64
306 }{
307 {
308 name: "enable",
309 args: args{
310 mem: &specs.LinuxMemory{
311 DisableOOMKiller: &falseBool,
312 },
313 },
314 want: &zeroInt64,
315 },
316 {
317 name: "disable",
318 args: args{
319 mem: &specs.LinuxMemory{
320 DisableOOMKiller: &trueBool,
321 },
322 },
323 want: &oneInt64,
324 },
325 {
326 name: "nil",
327 args: args{
328 mem: &specs.LinuxMemory{},
329 },
330 want: nil,
331 },
332 }
333 for _, tt := range tests {
334 t.Run(tt.name, func(t *testing.T) {
335 got := getOomControlValue(tt.args.mem)
336 if (got == nil || tt.want == nil) && got != tt.want {
337 t.Errorf("getOomControlValue() = %v, want %v", got, tt.want)
338 return
339 }
340 if got != nil && tt.want != nil && *got != *tt.want {
341 t.Errorf("getOomControlValue() = %v, want %v", got, tt.want)
342 }
343 })
344 }
345}

Callers

nothing calls this directly

Calls 1

getOomControlValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…