From 59a1497f0cead4659791683f1514d15ae8cf3934 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 12 Nov 2019 20:10:44 +0100 Subject: [PATCH] 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 Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- unix/syscall_linux_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unix/syscall_linux_test.go b/unix/syscall_linux_test.go index d3161d68..2feb5a10 100644 --- a/unix/syscall_linux_test.go +++ b/unix/syscall_linux_test.go @@ -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) } }