mirror of
https://github.com/golang/sys.git
synced 2026-02-08 03:36:03 +03:00
unix: check number of ready file descriptors in TestPselect
Like in TestSelect, check the number of ready file descriptors returned by Pselect. Change-Id: I4a64720092132c5ba432d6d1274df8c68bb5b6bf Reviewed-on: https://go-review.googlesource.com/c/sys/+/207862 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
76d669a226
commit
bd437916bb
@@ -239,13 +239,16 @@ func TestRlimitAs(t *testing.T) {
|
||||
|
||||
func TestPselect(t *testing.T) {
|
||||
for {
|
||||
_, err := unix.Pselect(0, nil, nil, nil, &unix.Timespec{Sec: 0, Nsec: 0}, nil)
|
||||
n, err := unix.Pselect(0, nil, nil, nil, &unix.Timespec{Sec: 0, Nsec: 0}, nil)
|
||||
if err == unix.EINTR {
|
||||
t.Logf("Pselect interrupted")
|
||||
continue
|
||||
} else if err != nil {
|
||||
t.Fatalf("Pselect: %v", err)
|
||||
}
|
||||
if n != 0 {
|
||||
t.Fatalf("Pselect: got %v ready file descriptors, expected 0", n)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@@ -254,7 +257,7 @@ func TestPselect(t *testing.T) {
|
||||
var took time.Duration
|
||||
for {
|
||||
start := time.Now()
|
||||
_, err := unix.Pselect(0, nil, nil, nil, &ts, nil)
|
||||
n, err := unix.Pselect(0, nil, nil, nil, &ts, nil)
|
||||
took = time.Since(start)
|
||||
if err == unix.EINTR {
|
||||
t.Logf("Pselect interrupted after %v", took)
|
||||
@@ -262,6 +265,9 @@ func TestPselect(t *testing.T) {
|
||||
} else if err != nil {
|
||||
t.Fatalf("Pselect: %v", err)
|
||||
}
|
||||
if n != 0 {
|
||||
t.Fatalf("Pselect: got %v ready file descriptors, expected 0", n)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user