-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpu_test.go
More file actions
111 lines (108 loc) · 3.11 KB
/
cpu_test.go
File metadata and controls
111 lines (108 loc) · 3.11 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
package main
import (
"testing"
"github.com/go-test/deep"
pb "github.com/lovi-cloud/satelit/api/satelit_datastore"
)
func TestParseNodeList(t *testing.T) {
tests := []struct {
input string
want *pb.NumaNode
err bool
}{
{
input: "0-23,48-71",
want: &pb.NumaNode{
PhysicalCoreMin: 0,
PhysicalCoreMax: 23,
LogicalCoreMin: 48,
LogicalCoreMax: 71,
Pairs: []*pb.CorePair{
{PhysicalCore: 0, LogicalCore: 48},
{PhysicalCore: 1, LogicalCore: 49},
{PhysicalCore: 2, LogicalCore: 50},
{PhysicalCore: 3, LogicalCore: 51},
{PhysicalCore: 4, LogicalCore: 52},
{PhysicalCore: 5, LogicalCore: 53},
{PhysicalCore: 6, LogicalCore: 54},
{PhysicalCore: 7, LogicalCore: 55},
{PhysicalCore: 8, LogicalCore: 56},
{PhysicalCore: 9, LogicalCore: 57},
{PhysicalCore: 10, LogicalCore: 58},
{PhysicalCore: 11, LogicalCore: 59},
{PhysicalCore: 12, LogicalCore: 60},
{PhysicalCore: 13, LogicalCore: 61},
{PhysicalCore: 14, LogicalCore: 62},
{PhysicalCore: 15, LogicalCore: 63},
{PhysicalCore: 16, LogicalCore: 64},
{PhysicalCore: 17, LogicalCore: 65},
{PhysicalCore: 18, LogicalCore: 66},
{PhysicalCore: 19, LogicalCore: 67},
{PhysicalCore: 20, LogicalCore: 68},
{PhysicalCore: 21, LogicalCore: 69},
{PhysicalCore: 22, LogicalCore: 70},
{PhysicalCore: 23, LogicalCore: 71},
},
},
err: false,
},
{
input: "24-47,72-95",
want: &pb.NumaNode{
PhysicalCoreMin: 24,
PhysicalCoreMax: 47,
LogicalCoreMin: 72,
LogicalCoreMax: 95,
Pairs: []*pb.CorePair{
{PhysicalCore: 24, LogicalCore: 72},
{PhysicalCore: 25, LogicalCore: 73},
{PhysicalCore: 26, LogicalCore: 74},
{PhysicalCore: 27, LogicalCore: 75},
{PhysicalCore: 28, LogicalCore: 76},
{PhysicalCore: 29, LogicalCore: 77},
{PhysicalCore: 30, LogicalCore: 78},
{PhysicalCore: 31, LogicalCore: 79},
{PhysicalCore: 32, LogicalCore: 80},
{PhysicalCore: 33, LogicalCore: 81},
{PhysicalCore: 34, LogicalCore: 82},
{PhysicalCore: 35, LogicalCore: 83},
{PhysicalCore: 36, LogicalCore: 84},
{PhysicalCore: 37, LogicalCore: 85},
{PhysicalCore: 38, LogicalCore: 86},
{PhysicalCore: 39, LogicalCore: 87},
{PhysicalCore: 40, LogicalCore: 88},
{PhysicalCore: 41, LogicalCore: 89},
{PhysicalCore: 42, LogicalCore: 90},
{PhysicalCore: 43, LogicalCore: 91},
{PhysicalCore: 44, LogicalCore: 92},
{PhysicalCore: 45, LogicalCore: 93},
{PhysicalCore: 46, LogicalCore: 94},
{PhysicalCore: 47, LogicalCore: 95},
},
},
err: false,
},
{
input: "0-23",
want: nil,
err: true,
},
{
input: "24-47",
want: nil,
err: true,
},
}
for _, test := range tests {
got, err := ParseNodeList(test.input)
if !test.err && err != nil {
t.Fatalf("should not be error for %+v but: %+v", test.input, err)
}
if test.err && err == nil {
t.Fatalf("should be error for %+v but not:", test.input)
}
if diff := deep.Equal(test.want, got); len(diff) != 0 {
t.Fatalf("want %q, but %q, diff %q:", test.want, got, diff)
}
}
}