-
Notifications
You must be signed in to change notification settings - Fork 1
/
system_test.go
86 lines (68 loc) · 1.72 KB
/
system_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
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
//
// 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 (
"os"
"testing"
ghwcontext "github.com/go-hardware/ghw/pkg/context"
)
// nolint: gocyclo
func TestSystem(t *testing.T) {
if _, ok := os.LookupEnv("GHW_TESTING_SKIP_HOST"); ok {
t.Skip("Skipping system tests.")
}
ctx := ghwcontext.New(ghwcontext.WithDisableWarnings())
system, err := System(ctx)
if err != nil {
t.Fatalf("Expected nil error but got %v", err)
}
if system == nil {
t.Fatalf("Expected non-nil system but got nil.")
}
mem := system.Memory
if mem == nil {
t.Fatalf("Expected non-nil Memory but got nil.")
}
tpb := mem.TotalPhysicalBytes
if tpb < 1 {
t.Fatalf("Expected >0 total physical memory, but got %d", tpb)
}
tub := mem.TotalUsableBytes
if tub < 1 {
t.Fatalf("Expected >0 total usable memory, but got %d", tub)
}
cpu := system.CPU
if cpu == nil {
t.Fatalf("Expected non-nil CPU, but got nil")
}
cores := cpu.TotalCores
if cores < 1 {
t.Fatalf("Expected >0 total cores, but got %d", cores)
}
threads := cpu.TotalThreads
if threads < 1 {
t.Fatalf("Expected >0 total threads, but got %d", threads)
}
block := system.Block
if block == nil {
t.Fatalf("Expected non-nil Block but got nil.")
}
blockTsb := block.TotalSizeBytes
if blockTsb < 1 {
t.Fatalf("Expected >0 total size bytes, but got %d", blockTsb)
}
topology := system.Topology
if topology == nil {
t.Fatalf("Expected non-nil Topology but got nil.")
}
if len(topology.Nodes) < 1 {
t.Fatalf("Expected >0 nodes , but got %d", len(topology.Nodes))
}
gpu := system.GPU
if gpu == nil {
t.Fatalf("Expected non-nil GPU but got nil.")
}
}