...

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

Documentation: github.com/prometheus/procfs

     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  
    14  package procfs
    15  
    16  import (
    17  	"testing"
    18  )
    19  
    20  func TestSlabInfo(t *testing.T) {
    21  	slabs, err := getProcFixtures(t).SlabInfo()
    22  	if err != nil {
    23  		t.Fatal(err)
    24  	}
    25  	if numSlabs := len(slabs.Slabs); numSlabs != 300 {
    26  		t.Errorf("expected 300 slabs, got %v", numSlabs)
    27  	}
    28  	if name := slabs.Slabs[0].Name; name != "pid_3" {
    29  		t.Errorf("Expected slab name to be 'pid_3', got %v", name)
    30  	}
    31  	if objActive := slabs.Slabs[0].ObjActive; objActive != 375 {
    32  		t.Errorf("Expected slab objects active to be 375, got %v", objActive)
    33  	}
    34  	if objNum := slabs.Slabs[0].ObjNum; objNum != 532 {
    35  		t.Errorf("Expected slab objects number to be 532, got %v", objNum)
    36  	}
    37  	if objSize := slabs.Slabs[0].ObjSize; objSize != 576 {
    38  		t.Errorf("Expected slab objects Size to be 576, got %+v", objSize)
    39  	}
    40  	if objPerSlab := slabs.Slabs[0].ObjPerSlab; objPerSlab != 28 {
    41  		t.Errorf("Expected slab objects per slab to be 28, got %v", objPerSlab)
    42  	}
    43  	if pagesPerSlab := slabs.Slabs[0].PagesPerSlab; pagesPerSlab != 4 {
    44  		t.Errorf("Expected pages per slab to be 4, got %v", pagesPerSlab)
    45  	}
    46  	if limit := slabs.Slabs[0].Limit; limit != 0 {
    47  		t.Errorf("Expected limit to be 0, got %v", limit)
    48  	}
    49  	if batch := slabs.Slabs[0].Batch; batch != 0 {
    50  		t.Errorf("Expected batch to be 0, got %v", batch)
    51  	}
    52  	if sharedFactor := slabs.Slabs[0].SharedFactor; sharedFactor != 0 {
    53  		t.Errorf("Expected shared factor to be 0, got %v", sharedFactor)
    54  	}
    55  	if slabActive := slabs.Slabs[0].SlabActive; slabActive != 19 {
    56  		t.Errorf("Expected slab active to be 19, got %v", slabActive)
    57  	}
    58  	if slabNum := slabs.Slabs[0].SlabNum; slabNum != 19 {
    59  		t.Errorf("Expected slab num to be 19, got %v", slabNum)
    60  	}
    61  	if sharedAvail := slabs.Slabs[0].SharedAvail; sharedAvail != 0 {
    62  		t.Errorf("Expected shared available to be 0, got %v", sharedAvail)
    63  	}
    64  }
    65  

View as plain text