unix: test returned fd in TestEpoll

Check the fd returned in EpollEvent to detect potential padding issues.

Also, fail the test if the number of events mismatches.

Updates golang/go#35479

Change-Id: I39f856ca2c336e849876a33acffb70b82aa83c3f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/206858
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Tobias Klauser
2019-11-12 20:10:44 +01:00
committed by Tobias Klauser
parent d32e6e3b99
commit 59a1497f0c

View File

@@ -693,6 +693,11 @@ func TestEpoll(t *testing.T) {
}
if n != 1 {
t.Logf("EpollWait: wrong number of events: got %v, expected 1", n)
t.Errorf("EpollWait: wrong number of events: got %v, expected 1", n)
}
got := int(events[0].Fd)
if got != fd {
t.Errorf("EpollWait: wrong Fd in event: got %v, expected %v", got, fd)
}
}