Commit 236baca6 authored by Tobias Klauser's avatar Tobias Klauser Committed by Tobias Klauser

unix: add timeout tests for Select and Pselect on Linux

Test for correct timeout behavior of Select and Pselect

Updates golang/go#22246

Change-Id: I86d1804c6ddf5072e93f3ef4f359198e732fae94
Reviewed-on: https://go-review.googlesource.com/84955
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 571f7bbb
......@@ -182,6 +182,39 @@ func TestSelect(t *testing.T) {
if err != nil {
t.Fatalf("Select: %v", err)
}
dur := 150 * time.Millisecond
tv := unix.NsecToTimeval(int64(dur))
start := time.Now()
_, err = unix.Select(0, nil, nil, nil, &tv)
took := time.Since(start)
if err != nil {
t.Fatalf("Select: %v", err)
}
if took < dur {
t.Errorf("Select: timeout should have been at least %v, got %v", dur, took)
}
}
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)
}
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 != nil {
t.Fatalf("Pselect: %v", err)
}
if took < dur {
t.Errorf("Pselect: timeout should have been at least %v, got %v", dur, took)
}
}
func TestFstatat(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment