mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-02 15:17:31 -04: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
+21
-10
@@ -287,20 +287,31 @@ func TestSelect(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPselect(t *testing.T) {
|
func TestPselect(t *testing.T) {
|
||||||
_, err := unix.Pselect(0, nil, nil, nil, &unix.Timespec{Sec: 0, Nsec: 0}, nil)
|
for {
|
||||||
if err != nil {
|
_, err := unix.Pselect(0, nil, nil, nil, &unix.Timespec{Sec: 0, Nsec: 0}, nil)
|
||||||
t.Fatalf("Pselect: %v", err)
|
if err != nil {
|
||||||
|
t.Fatalf("Pselect: %v", err)
|
||||||
|
} else if err == unix.EINTR {
|
||||||
|
t.Logf("Pselect interrupted")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
dur := 2500 * time.Microsecond
|
dur := 2500 * time.Microsecond
|
||||||
ts := unix.NsecToTimespec(int64(dur))
|
ts := unix.NsecToTimespec(int64(dur))
|
||||||
start := time.Now()
|
var took time.Duration
|
||||||
_, err = unix.Pselect(0, nil, nil, nil, &ts, nil)
|
for {
|
||||||
took := time.Since(start)
|
start := time.Now()
|
||||||
if err == unix.EINTR {
|
_, err := unix.Pselect(0, nil, nil, nil, &ts, nil)
|
||||||
t.Skipf("Pselect interrupted after %v timeout", took)
|
took = time.Since(start)
|
||||||
} else if err != nil {
|
if err == unix.EINTR {
|
||||||
t.Fatalf("Pselect: %v", err)
|
t.Logf("Pselect interrupted after %v", took)
|
||||||
|
continue
|
||||||
|
} else if err != nil {
|
||||||
|
t.Fatalf("Pselect: %v", err)
|
||||||
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if took < dur {
|
if took < dur {
|
||||||
|
|||||||
Reference in New Issue
Block a user