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