-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathccTopology_test.go
More file actions
237 lines (204 loc) · 5.42 KB
/
ccTopology_test.go
File metadata and controls
237 lines (204 loc) · 5.42 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
// All rights reserved. This file is part of cc-lib.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package ccTopology
import (
"encoding/json"
"os"
"strings"
"testing"
)
func TestInit(t *testing.T) {
_, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
}
func TestGetHwThreads(t *testing.T) {
var topo Topology
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
hwts := topo.GetHwthreads()
if len(hwts) == 0 {
t.Error("no hwthreads reported for system")
}
Shwts := topo.GetHwthreadStrings()
if len(Shwts) == 0 {
t.Error("no hwthreads reported for system")
}
t.Log("[", strings.Join(Shwts, ","), "]")
}
func TestGetSockets(t *testing.T) {
var topo Topology
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
socks := topo.GetSockets()
if len(socks) == 0 {
t.Error("no sockets reported for system")
}
Ssocks := topo.GetSocketStrings()
if len(Ssocks) == 0 {
t.Error("no sockets reported for system")
}
t.Log("[", strings.Join(Ssocks, ","), "]")
}
func TestGetDies(t *testing.T) {
var topo Topology
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
socks := topo.GetDies()
if len(socks) == 0 {
t.Error("no dies reported for system")
}
Ssocks := topo.GetDieStrings()
if len(Ssocks) == 0 {
t.Error("no dies reported for system")
}
t.Log("[", strings.Join(Ssocks, ","), "]")
}
func TestGetCores(t *testing.T) {
var topo Topology
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
socks := topo.GetCores()
if len(socks) == 0 {
t.Error("no cores reported for system")
}
Ssocks := topo.GetCoreStrings()
if len(Ssocks) == 0 {
t.Error("no cores reported for system")
}
t.Log("[", strings.Join(Ssocks, ","), "]")
}
func TestGetMemoryDomains(t *testing.T) {
var topo Topology
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
doms := topo.GetMemoryDomains()
if len(doms) == 0 {
t.Error("no memory domains reported for system")
}
Sdoms := topo.GetMemoryDomainStrings()
if len(Sdoms) == 0 {
t.Error("no memory domains reported for system")
}
t.Log("[", strings.Join(Sdoms, ","), "]")
}
func TestGetPciDevices(t *testing.T) {
var topo Topology
if os.Getenv("CI") != "" {
t.Skip("PCI device testing in CI is not supported (there are no PCI devices)")
}
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
socks := topo.GetPciDevices()
if len(socks) == 0 {
t.Error("no pci devices reported for system")
}
Ssocks := topo.GetPciDeviceStrings()
if len(Ssocks) == 0 {
t.Error("no pci devices reported for system")
}
t.Log("[", strings.Join(Ssocks, ","), "]")
}
func TestGetHwthreadsOfSocket(t *testing.T) {
var topo Topology
socket := uint(0)
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
hwts := topo.GetHwthreadsOfSocket(socket)
if len(hwts) == 0 {
t.Error("no hwthreads reported for socket ", socket)
}
Shwts := topo.GetHwthreadStringsOfSocket(socket)
if len(Shwts) == 0 {
t.Error("no hwthreads reported for socket ", socket)
}
t.Log("[", strings.Join(Shwts, ","), "]")
}
func TestGetHwthreadsOfMemoryDomain(t *testing.T) {
var topo Topology
memoryDomain := uint(0)
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
hwts := topo.GetHwthreadsOfMemoryDomain(memoryDomain)
if len(hwts) == 0 {
t.Error("no hwthreads reported for memory domain ", memoryDomain)
}
Shwts := topo.GetHwthreadStringsOfMemoryDomain(memoryDomain)
if len(Shwts) == 0 {
t.Error("no hwthreads reported for memory domai ", memoryDomain)
}
t.Log("[", strings.Join(Shwts, ","), "]")
}
func TestCpuinfo(t *testing.T) {
var topo Topology
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
cpuinfo := topo.CpuInfo()
if cpuinfo.NumHWthreads == 0 {
t.Error("failed to detect number of hwthreads")
}
if cpuinfo.NumCores == 0 {
t.Error("failed to detect number of cores")
}
if cpuinfo.NumSockets == 0 {
t.Error("failed to detect number of sockets")
}
if cpuinfo.NumDies == 0 {
t.Error("failed to detect number of dies")
}
if cpuinfo.NumNumaDomains == 0 {
t.Error("failed to detect number of NUMA domains")
}
}
func TestRemoteTopology(t *testing.T) {
var topo Topology
topo, err := LocalTopology()
if err != nil {
t.Error("failed to initialize topology: ", err.Error())
}
topoJson, err := json.Marshal(topo)
if err != nil {
t.Error("failed to get JSON of topology: ", err.Error())
}
rtopo, err := RemoteTopology(topoJson)
if err != nil {
t.Error("failed to parse JSON of remote topology: ", err.Error())
}
cpuinfo := rtopo.CpuInfo()
if cpuinfo.NumHWthreads == 0 {
t.Error("failed to detect number of hwthreads")
}
if cpuinfo.NumCores == 0 {
t.Error("failed to detect number of cores")
}
if cpuinfo.NumSockets == 0 {
t.Error("failed to detect number of sockets")
}
if cpuinfo.NumDies == 0 {
t.Error("failed to detect number of dies")
}
if cpuinfo.NumNumaDomains == 0 {
t.Error("failed to detect number of NUMA domains")
}
}