...

Source file src/github.com/prometheus/procfs/softirqs_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 TestSoftirqs(t *testing.T) {
    19  	s, err := getProcFixtures(t).Softirqs()
    20  	if err != nil {
    21  		t.Fatal(err)
    22  	}
    23  
    24  	// hi
    25  	if want, have := uint64(3), s.Hi[0]; want != have {
    26  		t.Errorf("want softirq HI count %d, have %d", want, have)
    27  	}
    28  	// timer
    29  	if want, have := uint64(247490), s.Timer[1]; want != have {
    30  		t.Errorf("want softirq TIMER count %d, have %d", want, have)
    31  	}
    32  	// net_tx
    33  	if want, have := uint64(2419), s.NetTx[0]; want != have {
    34  		t.Errorf("want softirq NET_TX count %d, have %d", want, have)
    35  	}
    36  	// net_rx
    37  	if want, have := uint64(28694), s.NetRx[1]; want != have {
    38  		t.Errorf("want softirq NET_RX count %d, have %d", want, have)
    39  	}
    40  	// block
    41  	if want, have := uint64(262755), s.Block[1]; want != have {
    42  		t.Errorf("want softirq BLOCK count %d, have %d", want, have)
    43  	}
    44  	// irq_poll
    45  	if want, have := uint64(0), s.IRQPoll[0]; want != have {
    46  		t.Errorf("want softirq IRQ_POLL count %d, have %d", want, have)
    47  	}
    48  	// tasklet
    49  	if want, have := uint64(209), s.Tasklet[0]; want != have {
    50  		t.Errorf("want softirq TASKLET count %d, have %d", want, have)
    51  	}
    52  	// sched
    53  	if want, have := uint64(2278692), s.Sched[0]; want != have {
    54  		t.Errorf("want softirq SCHED count %d, have %d", want, have)
    55  	}
    56  	// hrtimer
    57  	if want, have := uint64(1281), s.HRTimer[0]; want != have {
    58  		t.Errorf("want softirq HRTIMER count %d, have %d", want, have)
    59  	}
    60  	// rcu
    61  	if want, have := uint64(532783), s.RCU[1]; want != have {
    62  		t.Errorf("want softirq RCU count %d, have %d", want, have)
    63  	}
    64  }
    65  

View as plain text