1// Copyright 2020 The Prometheus Authors
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14package sysfs
15
16import (
17	"testing"
18)
19
20func TestParseVMStatNUMA(t *testing.T) {
21	fs, err := NewFS(sysTestFixtures)
22	if err != nil {
23		t.Fatal(err)
24	}
25
26	vmstat, err := fs.VMStatNUMA()
27	if err != nil {
28		t.Fatal(err)
29	}
30	if want, got := uint64(1), vmstat[1].NrFreePages; want != got {
31		t.Errorf("want vmstat stat nr_free_pages value %d, got %d", want, got)
32	}
33
34	if want, got := uint64(5), vmstat[1].NrZoneActiveFile; want != got {
35		t.Errorf("want numa stat nr_zone_active_file %d, got %d", want, got)
36	}
37	if want, got := uint64(7), vmstat[2].NrFreePages; want != got {
38		t.Errorf("want vmstat stat nr_free_pages value %d, got %d", want, got)
39	}
40
41	if want, got := uint64(11), vmstat[2].NrZoneActiveFile; want != got {
42		t.Errorf("want numa stat nr_zone_active_file %d, got %d", want, got)
43	}
44}
45