summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/sys/unix/syscall_bsd_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/sys/unix/syscall_bsd_test.go')
-rw-r--r--vendor/golang.org/x/sys/unix/syscall_bsd_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd_test.go b/vendor/golang.org/x/sys/unix/syscall_bsd_test.go
index d8085a072..6c4e2aca0 100644
--- a/vendor/golang.org/x/sys/unix/syscall_bsd_test.go
+++ b/vendor/golang.org/x/sys/unix/syscall_bsd_test.go
@@ -10,6 +10,7 @@ import (
"os/exec"
"runtime"
"testing"
+ "time"
"golang.org/x/sys/unix"
)
@@ -50,6 +51,28 @@ func TestGetfsstat(t *testing.T) {
}
}
+func TestSelect(t *testing.T) {
+ err := unix.Select(0, nil, nil, nil, &unix.Timeval{Sec: 0, Usec: 0})
+ if err != nil {
+ t.Fatalf("Select: %v", err)
+ }
+
+ dur := 250 * time.Millisecond
+ tv := unix.NsecToTimeval(int64(dur))
+ start := time.Now()
+ err = unix.Select(0, nil, nil, nil, &tv)
+ took := time.Since(start)
+ if err != nil {
+ t.Fatalf("Select: %v", err)
+ }
+
+ // On some BSDs the actual timeout might also be slightly less than the requested.
+ // Add an acceptable margin to avoid flaky tests.
+ if took < dur*2/3 {
+ t.Errorf("Select: timeout should have been at least %v, got %v", dur, took)
+ }
+}
+
func TestSysctlRaw(t *testing.T) {
if runtime.GOOS == "openbsd" {
t.Skip("kern.proc.pid does not exist on OpenBSD")
@@ -60,3 +83,11 @@ func TestSysctlRaw(t *testing.T) {
t.Fatal(err)
}
}
+
+func TestSysctlUint32(t *testing.T) {
+ maxproc, err := unix.SysctlUint32("kern.maxproc")
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Logf("kern.maxproc: %v", maxproc)
+}