...

Source file src/github.com/prometheus/procfs/kernel_random_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  //go:build !windows
    15  // +build !windows
    16  
    17  package procfs
    18  
    19  import (
    20  	"testing"
    21  )
    22  
    23  const procfsFixtures = "testdata/fixtures/proc"
    24  
    25  func TestKernelRandom(t *testing.T) {
    26  	fs, err := NewFS(procfsFixtures)
    27  	if err != nil {
    28  		t.Fatalf("failed to access %s: %v", procfsFixtures, err)
    29  	}
    30  
    31  	random, err := fs.KernelRandom()
    32  	if err != nil {
    33  		t.Fatalf("failed to collect %s/sys/kernel/random: %v", procfsFixtures, err)
    34  	}
    35  
    36  	if *random.EntropyAvaliable != 3943 {
    37  		t.Errorf("entropy_avail, want %d got %d", 3943, *random.EntropyAvaliable)
    38  	}
    39  	if *random.PoolSize != 4096 {
    40  		t.Errorf("poolsize, want %d got %d", 4096, *random.PoolSize)
    41  	}
    42  	if *random.URandomMinReseedSeconds != 60 {
    43  		t.Errorf("urandom_min_reseed_secs, want %d got %d", 60, *random.URandomMinReseedSeconds)
    44  	}
    45  	if *random.WriteWakeupThreshold != 3072 {
    46  		t.Errorf("write_wakeup_threshold, want %d got %d", 3072, *random.WriteWakeupThreshold)
    47  	}
    48  	if random.ReadWakeupThreshold != nil {
    49  		t.Errorf("read_wakeup_threshold, want %v got %d", nil, *random.ReadWakeupThreshold)
    50  	}
    51  }
    52  

View as plain text