1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package procfs
18
19 import (
20 "testing"
21
22 "github.com/google/go-cmp/cmp"
23 )
24
25 func newPInt64(i int64) *int64 {
26 return &i
27 }
28
29 func TestVM(t *testing.T) {
30 fs, err := NewFS(procTestFixtures)
31 if err != nil {
32 t.Fatal(err)
33 }
34 got, err := fs.VM()
35 if err != nil {
36 t.Fatal(err)
37 }
38 zeroPointer := newPInt64(0)
39 lowmemreserveratio := []*int64{newPInt64(256), newPInt64(256), newPInt64(32), zeroPointer, zeroPointer}
40 want := &VM{
41 AdminReserveKbytes: newPInt64(8192),
42 BlockDump: zeroPointer,
43 CompactUnevictableAllowed: newPInt64(1),
44 DirtyBackgroundBytes: zeroPointer,
45 DirtyBackgroundRatio: newPInt64(10),
46 DirtyBytes: zeroPointer,
47 DirtyExpireCentisecs: newPInt64(3000),
48 DirtyRatio: newPInt64(20),
49 DirtytimeExpireSeconds: newPInt64(43200),
50 DirtyWritebackCentisecs: newPInt64(500),
51 DropCaches: zeroPointer,
52 ExtfragThreshold: newPInt64(500),
53 HugetlbShmGroup: zeroPointer,
54 LaptopMode: newPInt64(5),
55 LegacyVaLayout: zeroPointer,
56 LowmemReserveRatio: lowmemreserveratio,
57 MaxMapCount: newPInt64(65530),
58 MemoryFailureEarlyKill: zeroPointer,
59 MemoryFailureRecovery: newPInt64(1),
60 MinFreeKbytes: newPInt64(67584),
61 MinSlabRatio: newPInt64(5),
62 MinUnmappedRatio: newPInt64(1),
63 MmapMinAddr: newPInt64(65536),
64 NumaStat: newPInt64(1),
65 NumaZonelistOrder: "Node",
66 NrHugepages: zeroPointer,
67 NrHugepagesMempolicy: zeroPointer,
68 NrOvercommitHugepages: zeroPointer,
69 OomDumpTasks: newPInt64(1),
70 OomKillAllocatingTask: zeroPointer,
71 OvercommitKbytes: zeroPointer,
72 OvercommitMemory: zeroPointer,
73 OvercommitRatio: newPInt64(50),
74 PageCluster: newPInt64(3),
75 PanicOnOom: zeroPointer,
76 PercpuPagelistFraction: zeroPointer,
77 StatInterval: newPInt64(1),
78 Swappiness: newPInt64(60),
79 UserReserveKbytes: newPInt64(131072),
80 VfsCachePressure: newPInt64(100),
81 WatermarkBoostFactor: newPInt64(15000),
82 WatermarkScaleFactor: newPInt64(10),
83 ZoneReclaimMode: zeroPointer,
84 }
85 if diff := cmp.Diff(want, got); diff != "" {
86 t.Fatalf("unexpected power supply class (-want +got):\n%s", diff)
87 }
88 }
89
View as plain text