forked from kata-containers/agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cgroup_test.go
45 lines (38 loc) · 858 Bytes
/
cgroup_test.go
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
// Copyright (c) 2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetAvailableCpusetList(t *testing.T) {
fakeGuestCpuset := "0-3"
getCpusetGuest = func() (string, error) {
return fakeGuestCpuset, nil
}
type testCase struct {
input string
expectedOutput string
}
cases := []testCase{
{"0", "0"},
{"0,1", "0,1"},
{"0,1,2", "0,1,2"},
{"0,1,2,3", "0,1,2,3"},
{"0,1,2,3,4", fakeGuestCpuset},
{"0-3", "0-3"},
{"0-3,4", fakeGuestCpuset},
{"0-4", fakeGuestCpuset},
{"1", "1"},
{"1,3", "1,3"},
{"2-3", "2-3"},
{"2-4", fakeGuestCpuset},
}
for _, c := range cases {
out, err := getAvailableCpusetList(c.input)
assert.Nil(t, err, "Failed to calculate : %v", err)
assert.Equal(t, out, c.expectedOutput)
}
}