forked from jaypipes/ghw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
topology_test.go
52 lines (45 loc) · 1.1 KB
/
topology_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
46
47
48
49
50
51
52
//
// Use and distribution licensed under the Apache license version 2.
//
// See the COPYING file in the root project directory for full text.
//
package ghw
import (
"testing"
)
// nolint: gocyclo
func TestTopology(t *testing.T) {
info, err := Topology()
if err != nil {
t.Fatalf("Expected nil err, but got %v", err)
}
if info == nil {
t.Fatalf("Expected non-nil TopologyInfo, but got nil")
}
if len(info.Nodes) == 0 {
t.Fatalf("Expected >0 nodes but got 0.")
}
if info.Architecture == ARCHITECTURE_NUMA && len(info.Nodes) == 1 {
t.Fatalf("Got NUMA architecture but only 1 node.")
}
for _, n := range info.Nodes {
if len(n.Cores) == 0 {
t.Fatalf("Expected >0 cores but got 0.")
}
for _, c := range n.Cores {
if len(c.LogicalProcessors) == 0 {
t.Fatalf("Expected >0 logical processors but got 0.")
}
if uint32(len(c.LogicalProcessors)) != c.NumThreads {
t.Fatalf(
"Expected NumThreads == len(logical procs) but %d != %d",
c.NumThreads,
len(c.LogicalProcessors),
)
}
}
if len(n.Caches) == 0 {
t.Fatalf("Expected >0 caches but got 0.")
}
}
}