unix: in TestSelect, only error for an early wakeup on Linux

On Linux, 'man 2 select' explicitly lists the conditions under which
select may return before the timeout interval. Most other platforms
make no such guarantee, so do not test for it on those platforms.

Fixes golang/go#36409

Change-Id: I194a34af3132a7db7fc186dec9de67fa6dd0bfae
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363455
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/unix/syscall_unix_test.go b/unix/syscall_unix_test.go
index c1478ed..cfcdd0e 100644
--- a/unix/syscall_unix_test.go
+++ b/unix/syscall_unix_test.go
@@ -562,10 +562,17 @@
 		break
 	}
 
-	// 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: got %v timeout, expected at least %v", took, dur)
+	// On some platforms (e.g. NetBSD) the actual timeout might be arbitrarily
+	// less than requested. However, Linux in particular promises to only return
+	// early if a file descriptor becomes ready (not applicable here), or the call
+	// is interrupted by a signal handler (explicitly retried in the loop above),
+	// or the timeout expires.
+	if took < dur {
+		if runtime.GOOS == "linux" {
+			t.Errorf("Select: slept for %v, expected %v", took, dur)
+		} else {
+			t.Logf("Select: slept for %v, requested %v", took, dur)
+		}
 	}
 
 	rr, ww, err := os.Pipe()