Skip to content

Commit c2d0d8c

Browse files
committed
test: make tests pass when the file descriptor limit is low.
1 parent a6a239f commit c2d0d8c

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

nofile_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// +build !windows,!wasm
2+
3+
package dht
4+
5+
import (
6+
"fmt"
7+
"os"
8+
"testing"
9+
10+
"syscall"
11+
)
12+
13+
func TestMain(m *testing.M) {
14+
err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &syscall.Rlimit{
15+
Cur: 4096,
16+
Max: 4096,
17+
})
18+
if err != nil {
19+
fmt.Println("failed to increase open file descriptor limit, can't run tests")
20+
os.Exit(1)
21+
}
22+
os.Exit(m.Run())
23+
}

nofile_test_posix.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

nofile_test_windows.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)