1// Copyright 2017 Prometheus Team 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 "testing" 18) 19 20func TestXfrmStats(t *testing.T) { 21 xfrmStats, err := getProcFixtures(t).NewXfrmStat() 22 if err != nil { 23 t.Fatal(err) 24 } 25 26 for _, test := range []struct { 27 name string 28 want int 29 got int 30 }{ 31 {name: "XfrmInError", want: 1, got: xfrmStats.XfrmInError}, 32 {name: "XfrmInBufferError", want: 2, got: xfrmStats.XfrmInBufferError}, 33 {name: "XfrmInHdrError", want: 4, got: xfrmStats.XfrmInHdrError}, 34 {name: "XfrmInNoStates", want: 3, got: xfrmStats.XfrmInNoStates}, 35 {name: "XfrmInStateProtoError", want: 40, got: xfrmStats.XfrmInStateProtoError}, 36 {name: "XfrmInStateModeError", want: 100, got: xfrmStats.XfrmInStateModeError}, 37 {name: "XfrmInStateSeqError", want: 6000, got: xfrmStats.XfrmInStateSeqError}, 38 {name: "XfrmInStateExpired", want: 4, got: xfrmStats.XfrmInStateExpired}, 39 {name: "XfrmInStateMismatch", want: 23451, got: xfrmStats.XfrmInStateMismatch}, 40 {name: "XfrmInStateInvalid", want: 55555, got: xfrmStats.XfrmInStateInvalid}, 41 {name: "XfrmInTmplMismatch", want: 51, got: xfrmStats.XfrmInTmplMismatch}, 42 {name: "XfrmInNoPols", want: 65432, got: xfrmStats.XfrmInNoPols}, 43 {name: "XfrmInPolBlock", want: 100, got: xfrmStats.XfrmInPolBlock}, 44 {name: "XfrmInPolError", want: 10000, got: xfrmStats.XfrmInPolError}, 45 {name: "XfrmOutError", want: 1000000, got: xfrmStats.XfrmOutError}, 46 {name: "XfrmOutBundleGenError", want: 43321, got: xfrmStats.XfrmOutBundleGenError}, 47 {name: "XfrmOutBundleCheckError", want: 555, got: xfrmStats.XfrmOutBundleCheckError}, 48 {name: "XfrmOutNoStates", want: 869, got: xfrmStats.XfrmOutNoStates}, 49 {name: "XfrmOutStateProtoError", want: 4542, got: xfrmStats.XfrmOutStateProtoError}, 50 {name: "XfrmOutStateModeError", want: 4, got: xfrmStats.XfrmOutStateModeError}, 51 {name: "XfrmOutStateSeqError", want: 543, got: xfrmStats.XfrmOutStateSeqError}, 52 {name: "XfrmOutStateExpired", want: 565, got: xfrmStats.XfrmOutStateExpired}, 53 {name: "XfrmOutPolBlock", want: 43456, got: xfrmStats.XfrmOutPolBlock}, 54 {name: "XfrmOutPolDead", want: 7656, got: xfrmStats.XfrmOutPolDead}, 55 {name: "XfrmOutPolError", want: 1454, got: xfrmStats.XfrmOutPolError}, 56 {name: "XfrmFwdHdrError", want: 6654, got: xfrmStats.XfrmFwdHdrError}, 57 {name: "XfrmOutStateInvaliad", want: 28765, got: xfrmStats.XfrmOutStateInvalid}, 58 {name: "XfrmAcquireError", want: 24532, got: xfrmStats.XfrmAcquireError}, 59 {name: "XfrmInStateInvalid", want: 55555, got: xfrmStats.XfrmInStateInvalid}, 60 {name: "XfrmOutError", want: 1000000, got: xfrmStats.XfrmOutError}, 61 } { 62 if test.want != test.got { 63 t.Errorf("Want %s %d, have %d", test.name, test.want, test.got) 64 } 65 } 66} 67