mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
cmd/utils: Cross platform compatible fd limit test
This commit is contained in:
parent
4aad14510a
commit
500b44cbdb
4 changed files with 23 additions and 2 deletions
|
|
@ -52,3 +52,11 @@ func getFdLimit() (int, error) {
|
|||
}
|
||||
return int(limit.Cur), nil
|
||||
}
|
||||
|
||||
func getFdMaxLimit() (int, error) {
|
||||
var limit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int(limit.Max), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,11 @@ import (
|
|||
func TestFileDescriptorLimits(t *testing.T) {
|
||||
target := 4096
|
||||
var limit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
|
||||
hardlimit, err := getFdMaxLimit()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if int(limit.Max) < target {
|
||||
if hardlimit < target {
|
||||
t.Skip(fmt.Sprintf("system limit is less than desired test target: %d < %d", limit.Max, target))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,3 +48,11 @@ func getFdLimit() (int, error) {
|
|||
}
|
||||
return int(limit.Cur), nil
|
||||
}
|
||||
|
||||
func getFdMaxLimit() (int, error) {
|
||||
var limit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int(limit.Max), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,3 +39,7 @@ func getFdLimit() (int, error) {
|
|||
// Please see raiseFdLimit for the reason why we use hard coded 16K as the limit
|
||||
return 16384, nil
|
||||
}
|
||||
|
||||
func getFdMaxLimit() (int, error) {
|
||||
return getFdLimit()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue