...

Source file src/github.com/prometheus/procfs/proc_snmp6_test.go

Documentation: github.com/prometheus/procfs

     1  // Copyright 2022 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  
    14  package procfs
    15  
    16  import "testing"
    17  
    18  func TestProcSnmp6(t *testing.T) {
    19  	p, err := getProcFixtures(t).Proc(26231)
    20  	if err != nil {
    21  		t.Fatal(err)
    22  	}
    23  
    24  	procSnmp6, err := p.Snmp6()
    25  	if err != nil {
    26  		t.Fatal(err)
    27  	}
    28  
    29  	for _, test := range []struct {
    30  		name string
    31  		want float64
    32  		have float64
    33  	}{
    34  		{name: "pid", want: 26231, have: float64(procSnmp6.PID)},
    35  		{name: "Ip6InReceives", want: 92166, have: *procSnmp6.Ip6.InReceives},
    36  		{name: "Ip6InDelivers", want: 92053, have: *procSnmp6.Ip6.InDelivers},
    37  		{name: "Ip6OutNoRoutes", want: 169, have: *procSnmp6.Ip6.OutNoRoutes},
    38  		{name: "Ip6InOctets", want: 113479132, have: *procSnmp6.Ip6.InOctets},
    39  		{name: "Icmp6InMsgs", want: 142, have: *procSnmp6.Icmp6.InMsgs},
    40  		{name: "Udp6InDatagrams", want: 2016, have: *procSnmp6.Udp6.InDatagrams},
    41  		{name: "UdpLite6InDatagrams", want: 0, have: *procSnmp6.UdpLite6.InDatagrams},
    42  	} {
    43  		if test.want != test.have {
    44  			t.Errorf("want %s %f, have %f", test.name, test.want, test.have)
    45  		}
    46  	}
    47  
    48  }
    49  

View as plain text