forked from prometheus/procfs
-
Notifications
You must be signed in to change notification settings - Fork 2
/
meminfo_test.go
77 lines (72 loc) · 2.03 KB
/
meminfo_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
// Copyright 2019 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package procfs
import (
"reflect"
"testing"
)
func TestMeminfo(t *testing.T) {
expected := Meminfo{
MemTotal: 15666184,
MemFree: 440324,
Buffers: 1020128,
Cached: 12007640,
SwapCached: 0,
Active: 6761276,
Inactive: 6532708,
ActiveAnon: 267256,
InactiveAnon: 268,
ActiveFile: 6494020,
InactiveFile: 6532440,
Unevictable: 0,
Mlocked: 0,
SwapTotal: 0,
SwapFree: 0,
Dirty: 768,
Writeback: 0,
AnonPages: 266216,
Mapped: 44204,
Shmem: 1308,
Slab: 1807264,
SReclaimable: 1738124,
SUnreclaim: 69140,
KernelStack: 1616,
PageTables: 5288,
NFSUnstable: 0,
Bounce: 0,
WritebackTmp: 0,
CommitLimit: 7833092,
CommittedAS: 530844,
VmallocTotal: 34359738367,
VmallocUsed: 36596,
VmallocChunk: 34359637840,
HardwareCorrupted: 0,
AnonHugePages: 12288,
HugePagesTotal: 0,
HugePagesFree: 0,
HugePagesRsvd: 0,
HugePagesSurp: 0,
Hugepagesize: 2048,
DirectMap4k: 91136,
DirectMap2M: 16039936,
}
have, err := getProcFixtures(t).Meminfo()
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(have, expected) {
t.Logf("have: %+v", have)
t.Logf("expected: %+v", expected)
t.Errorf("structs are not equal")
}
}