Skip to content

Commit f8ee60a

Browse files
author
Sergei Semenchuk
authored
fix zoneinfo name parsing (#398)
Add aditional test coverage for Normal, Movable and Devize zones Signed-off-by: binjip978 <[email protected]>
1 parent 8506463 commit f8ee60a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

zoneinfo.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func parseZoneinfo(zoneinfoData []byte) ([]Zoneinfo, error) {
9999
continue
100100
}
101101
if strings.HasPrefix(strings.TrimSpace(line), "per-node stats") {
102-
zoneinfoElement.Zone = ""
103102
continue
104103
}
105104
parts := strings.Fields(strings.TrimSpace(line))

zoneinfo_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,28 @@ import (
2323

2424
func TestZoneinfo(t *testing.T) {
2525
fs := getProcFixtures(t)
26-
protection1 := []*int64{newPInt64(0), newPInt64(2877), newPInt64(7826), newPInt64(7826), newPInt64(7826)}
27-
protection2 := []*int64{newPInt64(0), newPInt64(0), newPInt64(4949), newPInt64(4949), newPInt64(4949)}
26+
27+
protectionDMA := []*int64{newPInt64(0), newPInt64(2877), newPInt64(7826), newPInt64(7826), newPInt64(7826)}
28+
protectionDMA32 := []*int64{newPInt64(0), newPInt64(0), newPInt64(4949), newPInt64(4949), newPInt64(4949)}
29+
protectionNormal := []*int64{newPInt64(0), newPInt64(0), newPInt64(0), newPInt64(0), newPInt64(0)}
30+
protectionMovable := []*int64{newPInt64(0), newPInt64(0), newPInt64(0), newPInt64(0), newPInt64(0)}
31+
protectionDevice := []*int64{newPInt64(0), newPInt64(0), newPInt64(0), newPInt64(0), newPInt64(0)}
32+
2833
refs := []Zoneinfo{
29-
{Node: "0", Zone: "", NrFreePages: newPInt64(3952), Min: newPInt64(33), Low: newPInt64(41), High: newPInt64(49), Spanned: newPInt64(4095), Present: newPInt64(3975), Managed: newPInt64(3956), NrActiveAnon: newPInt64(547580), NrInactiveAnon: newPInt64(230981), NrIsolatedAnon: newPInt64(0), NrAnonPages: newPInt64(795576), NrAnonTransparentHugepages: newPInt64(0), NrActiveFile: newPInt64(346282), NrInactiveFile: newPInt64(316904), NrIsolatedFile: newPInt64(0), NrFilePages: newPInt64(761874), NrSlabReclaimable: newPInt64(131220), NrSlabUnreclaimable: newPInt64(47320), NrKernelStack: newPInt64(0), NrMapped: newPInt64(215483), NrDirty: newPInt64(908), NrWriteback: newPInt64(0), NrUnevictable: newPInt64(115467), NrShmem: newPInt64(224925), NrDirtied: newPInt64(8007423), NrWritten: newPInt64(7752121), NumaHit: newPInt64(1), NumaMiss: newPInt64(0), NumaForeign: newPInt64(0), NumaInterleave: newPInt64(0), NumaLocal: newPInt64(1), NumaOther: newPInt64(0), Protection: protection1},
30-
{Node: "0", Zone: "DMA32", NrFreePages: newPInt64(204252), Min: newPInt64(19510), Low: newPInt64(21059), High: newPInt64(22608), Spanned: newPInt64(1044480), Present: newPInt64(759231), Managed: newPInt64(742806), NrKernelStack: newPInt64(2208), NumaHit: newPInt64(113952967), NumaMiss: newPInt64(0), NumaForeign: newPInt64(0), NumaInterleave: newPInt64(0), NumaLocal: newPInt64(113952967), NumaOther: newPInt64(0), Protection: protection2},
34+
{Node: "0", Zone: "DMA", NrFreePages: newPInt64(3952), Min: newPInt64(33), Low: newPInt64(41), High: newPInt64(49), Spanned: newPInt64(4095), Present: newPInt64(3975), Managed: newPInt64(3956), NrActiveAnon: newPInt64(547580), NrInactiveAnon: newPInt64(230981), NrIsolatedAnon: newPInt64(0), NrAnonPages: newPInt64(795576), NrAnonTransparentHugepages: newPInt64(0), NrActiveFile: newPInt64(346282), NrInactiveFile: newPInt64(316904), NrIsolatedFile: newPInt64(0), NrFilePages: newPInt64(761874), NrSlabReclaimable: newPInt64(131220), NrSlabUnreclaimable: newPInt64(47320), NrKernelStack: newPInt64(0), NrMapped: newPInt64(215483), NrDirty: newPInt64(908), NrWriteback: newPInt64(0), NrUnevictable: newPInt64(115467), NrShmem: newPInt64(224925), NrDirtied: newPInt64(8007423), NrWritten: newPInt64(7752121), NumaHit: newPInt64(1), NumaMiss: newPInt64(0), NumaForeign: newPInt64(0), NumaInterleave: newPInt64(0), NumaLocal: newPInt64(1), NumaOther: newPInt64(0), Protection: protectionDMA},
35+
{Node: "0", Zone: "DMA32", NrFreePages: newPInt64(204252), Min: newPInt64(19510), Low: newPInt64(21059), High: newPInt64(22608), Spanned: newPInt64(1044480), Present: newPInt64(759231), Managed: newPInt64(742806), NrKernelStack: newPInt64(2208), NumaHit: newPInt64(113952967), NumaMiss: newPInt64(0), NumaForeign: newPInt64(0), NumaInterleave: newPInt64(0), NumaLocal: newPInt64(113952967), NumaOther: newPInt64(0), Protection: protectionDMA32},
36+
{Node: "0", Zone: "Normal", NrFreePages: newPInt64(18553), Min: newPInt64(11176), Low: newPInt64(13842), High: newPInt64(16508), Spanned: newPInt64(1308160), Present: newPInt64(1308160), Managed: newPInt64(1268711), NrKernelStack: newPInt64(15136), NumaHit: newPInt64(162718019), NumaMiss: newPInt64(0), NumaForeign: newPInt64(0), NumaInterleave: newPInt64(26812), NumaLocal: newPInt64(162718019), NumaOther: newPInt64(0), Protection: protectionNormal},
37+
{Node: "0", Zone: "Movable", Min: newPInt64(0), Low: newPInt64(0), High: newPInt64(0), Spanned: newPInt64(0), Present: newPInt64(0), Managed: newPInt64(0), Protection: protectionMovable},
38+
{Node: "0", Zone: "Device", Min: newPInt64(0), Low: newPInt64(0), High: newPInt64(0), Spanned: newPInt64(0), Present: newPInt64(0), Managed: newPInt64(0), Protection: protectionDevice},
3139
}
40+
3241
data, err := fs.Zoneinfo()
3342
if err != nil {
3443
t.Fatalf("failed to parse zoneinfo: %v", err)
3544
}
45+
if len(data) != 5 {
46+
t.Fatal("failed to get all all node info")
47+
}
3648

3749
for index, ref := range refs {
3850
want, got := ref, data[index]

0 commit comments

Comments
 (0)