forked from go-ego/riot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
info_test.go
103 lines (78 loc) · 2.04 KB
/
info_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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// +build !windows
package riot
import (
"log"
"testing"
"github.com/vcaesar/tt"
)
// TestSysInfo
func TestMem(t *testing.T) {
log.Println("SYS info test...")
var engine Engine
log.Println("Mem info test...")
tt.Equal(t, true, InitMemUsed != 0)
tt.Equal(t, true, InitMemUsed != 0)
memPercent, err := MemPercent()
tt.Equal(t, nil, err)
tt.Equal(t, true, memPercent != "")
mem, err := MemUsed()
tt.Equal(t, nil, err)
tt.Equal(t, true, mem != 0)
useMem, err := engine.UsedMem()
tt.Equal(t, nil, err)
tt.Equal(t, true, useMem != 0)
memT, err := MemTotal()
tt.Equal(t, nil, err)
tt.Equal(t, true, memT != 0)
memFree, err := MemFree()
tt.Equal(t, nil, err)
tt.Equal(t, true, memFree != 0)
tt.Equal(t, 1, ToKB(1024))
tt.Equal(t, 1, ToMB(1024*1024))
tt.Equal(t, 1, ToGB(1024*1024*1024))
}
func TestDisk(t *testing.T) {
log.Println("Disk info test...")
var engine Engine
diskPercent, err := DiskPercent()
tt.Equal(t, nil, err)
tt.Equal(t, true, diskPercent != "")
disk, err := DiskUsed()
tt.Equal(t, nil, err)
tt.Equal(t, true, disk != 0)
useDisk, err := engine.UsedDisk()
tt.Equal(t, nil, err)
log.Println("useDisk: ", useDisk)
// tt.Equal(t, true, useDisk != 0)
diskTotal, err := DiskTotal()
tt.Equal(t, nil, err)
tt.Equal(t, true, diskTotal != 0)
diskFree, err := DiskFree()
tt.Equal(t, nil, err)
tt.Equal(t, true, diskFree != 0)
}
func TestCPU(t *testing.T) {
log.Println("CPU info test...")
cpuInfo, err := CPUInfo()
tt.Equal(t, nil, err)
tt.Equal(t, true, cpuInfo != "")
cpuPct, err := CPUPercent()
tt.Equal(t, nil, err)
tt.Equal(t, true, cpuPct != nil)
}
func TestPlatform(t *testing.T) {
log.Println("Platform info test...")
uptime, err := Uptime()
tt.Equal(t, nil, err)
tt.Equal(t, true, uptime != 0)
platform, family, osVersion, err := PlatformInfo()
tt.Equal(t, nil, err)
tt.Equal(t, true, platform != "" && osVersion != "")
log.Println(family)
palt, err := Platform()
tt.Equal(t, nil, err)
tt.Equal(t, true, palt != "")
kver, err := KernelVer()
tt.Equal(t, nil, err)
tt.Equal(t, true, kver != "")
}