mirror of
https://github.com/golang/sys.git
synced 2026-02-08 03:36:03 +03:00
unix: don't fail TestPselect on EINTR from Pselect
Updates golang/go#35555 Change-Id: I3efb010c8edf92a75941c6b7ec749665235020d8 Reviewed-on: https://go-review.googlesource.com/c/sys/+/207284 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
6254a7c3ca
commit
2f86c98f34
@@ -287,20 +287,31 @@ func TestSelect(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPselect(t *testing.T) {
|
||||
_, err := unix.Pselect(0, nil, nil, nil, &unix.Timespec{Sec: 0, Nsec: 0}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Pselect: %v", err)
|
||||
for {
|
||||
_, err := unix.Pselect(0, nil, nil, nil, &unix.Timespec{Sec: 0, Nsec: 0}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Pselect: %v", err)
|
||||
} else if err == unix.EINTR {
|
||||
t.Logf("Pselect interrupted")
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
dur := 2500 * time.Microsecond
|
||||
ts := unix.NsecToTimespec(int64(dur))
|
||||
start := time.Now()
|
||||
_, err = unix.Pselect(0, nil, nil, nil, &ts, nil)
|
||||
took := time.Since(start)
|
||||
if err == unix.EINTR {
|
||||
t.Skipf("Pselect interrupted after %v timeout", took)
|
||||
} else if err != nil {
|
||||
t.Fatalf("Pselect: %v", err)
|
||||
var took time.Duration
|
||||
for {
|
||||
start := time.Now()
|
||||
_, err := unix.Pselect(0, nil, nil, nil, &ts, nil)
|
||||
took = time.Since(start)
|
||||
if err == unix.EINTR {
|
||||
t.Logf("Pselect interrupted after %v", took)
|
||||
continue
|
||||
} else if err != nil {
|
||||
t.Fatalf("Pselect: %v", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if took < dur {
|
||||
|
||||
Reference in New Issue
Block a user