1// Copyright 2019 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 procfs
15
16import (
17	"net"
18	"testing"
19)
20
21func TestARP(t *testing.T) {
22	fs, err := NewFS(procTestFixtures)
23	if err != nil {
24		t.Fatal(err)
25	}
26
27	arpFile, err := fs.GatherARPEntries()
28	if err != nil {
29		t.Fatal(err)
30	}
31
32	if want, got := "192.168.224.1", arpFile[0].IPAddr.String(); want != got {
33		t.Errorf("want 192.168.224.1, got %s", got)
34	}
35
36	if want, got := net.HardwareAddr("00:50:56:c0:00:08").String(), arpFile[0].HWAddr.String(); want != got {
37		t.Errorf("want 00:50:56:c0:00:08, got %s", got)
38	}
39
40	if want, got := "ens33", arpFile[0].Device; want != got {
41		t.Errorf("want ens33, got %s", got)
42	}
43}
44