mirror of
https://github.com/golang/sys.git
synced 2026-02-08 11:46:04 +03:00
unix: fix EINTR check in TestClockNanosleep
err == EINTR needs to be checked before err != nil for the interrupted syscall to be retried properly. Follow-up for CL 207285 Updates golang/go#35622 Change-Id: I0f8c1a75eb96e11aaba284eb75716db044257cbd Reviewed-on: https://go-review.googlesource.com/c/sys/+/207290 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
Brad Fitzpatrick
parent
81af7394a2
commit
6254a7c3ca
@@ -585,11 +585,11 @@ func TestClockNanosleep(t *testing.T) {
|
||||
until := start.Add(delay)
|
||||
abs := unix.NsecToTimespec(until.UnixNano())
|
||||
err := unix.ClockNanosleep(unix.CLOCK_REALTIME, unix.TIMER_ABSTIME, &abs, nil)
|
||||
if err != nil {
|
||||
t.Errorf("ClockNanosleep(CLOCK_REALTIME, TIMER_ABSTIME, %#v (=%v), nil) = %v", &abs, until, err)
|
||||
} else if err == unix.EINTR {
|
||||
if err == unix.EINTR {
|
||||
t.Logf("ClockNanosleep interrupted after %v", time.Since(start))
|
||||
continue
|
||||
} else if err != nil {
|
||||
t.Errorf("ClockNanosleep(CLOCK_REALTIME, TIMER_ABSTIME, %#v (=%v), nil) = %v", &abs, until, err)
|
||||
} else if slept := time.Since(start); slept < delay {
|
||||
t.Errorf("ClockNanosleep(CLOCK_REALTIME, TIMER_ABSTIME, %#v (=%v), nil) slept only %v", &abs, until, slept)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user