diff --git a/cmd/utils/fdlimit_test.go b/cmd/utils/fdlimit_test.go index 0a950a6c9d..f1bc33bc0c 100644 --- a/cmd/utils/fdlimit_test.go +++ b/cmd/utils/fdlimit_test.go @@ -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)