diff --git a/unix/creds_test.go b/unix/creds_test.go index 752c82e8..a1928456 100644 --- a/unix/creds_test.go +++ b/unix/creds_test.go @@ -39,16 +39,19 @@ func TestSCMCredentials(t *testing.T) { if err != nil { t.Fatalf("Socketpair: %v", err) } - defer unix.Close(fds[0]) - defer unix.Close(fds[1]) err = unix.SetsockoptInt(fds[0], unix.SOL_SOCKET, unix.SO_PASSCRED, 1) if err != nil { + unix.Close(fds[0]) + unix.Close(fds[1]) t.Fatalf("SetsockoptInt: %v", err) } srvFile := os.NewFile(uintptr(fds[0]), "server") + cliFile := os.NewFile(uintptr(fds[1]), "client") defer srvFile.Close() + defer cliFile.Close() + srv, err := net.FileConn(srvFile) if err != nil { t.Errorf("FileConn: %v", err) @@ -56,8 +59,6 @@ func TestSCMCredentials(t *testing.T) { } defer srv.Close() - cliFile := os.NewFile(uintptr(fds[1]), "client") - defer cliFile.Close() cli, err := net.FileConn(cliFile) if err != nil { t.Errorf("FileConn: %v", err) diff --git a/unix/syscall_unix_test.go b/unix/syscall_unix_test.go index 5d31524d..6792cef5 100644 --- a/unix/syscall_unix_test.go +++ b/unix/syscall_unix_test.go @@ -206,8 +206,6 @@ func TestPassFD(t *testing.T) { if err != nil { t.Fatalf("Socketpair: %v", err) } - defer unix.Close(fds[0]) - defer unix.Close(fds[1]) writeFile := os.NewFile(uintptr(fds[0]), "child-writes") readFile := os.NewFile(uintptr(fds[1]), "parent-reads") defer writeFile.Close()