net: don't ignore errors in TestUnixUnlink

TestUnixUnlink calls some functions and methods that can fail, but it
ignores the returned errors. This test is flaky on Windows, and those
errors should be checked to help diagnose the problem.

Updates #75282
Updates #76582
Updates #77038

Change-Id: Ia868762a4c0b94a7255d57add63777568caa6cd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/734720
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
qmuntal 2026-01-08 10:25:44 +01:00 committed by Quim Muntal
parent df6c351aa4
commit 5741608de2

View file

@ -375,6 +375,17 @@ func TestUnixUnlink(t *testing.T) {
}
return l.(*UnixListener)
}
fileListener := func(t *testing.T, l *UnixListener) (*os.File, Listener) {
f, err := l.File()
if err != nil {
t.Fatal(err)
}
ln, err := FileListener(f)
if err != nil {
t.Fatal(err)
}
return f, ln
}
checkExists := func(t *testing.T, desc string) {
if _, err := os.Stat(name); err != nil {
t.Fatalf("unix socket does not exist %s: %v", desc, err)
@ -397,8 +408,7 @@ func TestUnixUnlink(t *testing.T) {
// FileListener should not.
t.Run("FileListener", func(t *testing.T) {
l := listen(t)
f, _ := l.File()
l1, _ := FileListener(f)
f, l1 := fileListener(t, l)
checkExists(t, "after FileListener")
f.Close()
checkExists(t, "after File close")
@ -444,8 +454,7 @@ func TestUnixUnlink(t *testing.T) {
t.Run("FileListener/SetUnlinkOnClose(true)", func(t *testing.T) {
l := listen(t)
f, _ := l.File()
l1, _ := FileListener(f)
f, l1 := fileListener(t, l)
checkExists(t, "after FileListener")
l1.(*UnixListener).SetUnlinkOnClose(true)
f.Close()
@ -457,8 +466,7 @@ func TestUnixUnlink(t *testing.T) {
t.Run("FileListener/SetUnlinkOnClose(false)", func(t *testing.T) {
l := listen(t)
f, _ := l.File()
l1, _ := FileListener(f)
f, l1 := fileListener(t, l)
checkExists(t, "after FileListener")
l1.(*UnixListener).SetUnlinkOnClose(false)
f.Close()