mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
cmd/utils: Add check on hard limit, skip test if below target
This commit is contained in:
parent
c6069a627c
commit
4aad14510a
1 changed files with 12 additions and 1 deletions
|
|
@ -16,12 +16,23 @@
|
|||
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFileDescriptorLimits simply tests whether the file descriptor allowance
|
||||
// per this process can be retrieved.
|
||||
func TestFileDescriptorLimits(t *testing.T) {
|
||||
target := 4096
|
||||
var limit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if int(limit.Max) < target {
|
||||
t.Skip(fmt.Sprintf("system limit is less than desired test target: %d < %d", limit.Max, target))
|
||||
}
|
||||
|
||||
if limit, err := getFdLimit(); err != nil || limit <= 0 {
|
||||
t.Fatalf("failed to retrieve file descriptor limit (%d): %v", limit, err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue