diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs index 52db82ab7c399..c31a2bd89a1e0 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs @@ -688,35 +688,6 @@ public unsafe void Ctor_SafeHandle_SocketPair_Success() close(ptr[1]); } - // On some Unix machines the second (manual) handle close succeeds despite Socket's/SafeSocketHandle's Dispose - // completing a succesful close of the same handle value previously. - // We may investigate this, but it doesn't indicate incorrect behavior in Socket code, - // so making the test PlatformSpecific seems to be good enough. The SafeSocketHandle lifecycle logic is platform cross-platform. - [PlatformSpecific(TestPlatforms.Windows)] - [Theory] - [InlineData(false)] - [InlineData(true)] - public void Ctor_Dispose_HandleClosedIfOwnsHandle(bool ownsHandle) - { - Socket original = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - IntPtr handleValue = original.Handle; - - SafeSocketHandle handleClone = new SafeSocketHandle(handleValue, ownsHandle: ownsHandle); - Socket socketClone = new Socket(handleClone); - socketClone.Dispose(); - - bool manualCloseSucceeded = closesocket(handleValue) == 0; - Assert.Equal(!ownsHandle, manualCloseSucceeded); - -#if DEBUG // The finalizer will fail to close the handle which leads to an assertion failure in Debug builds. - GC.SuppressFinalize(original); - GC.SuppressFinalize(original.SafeHandle); -#endif - - [DllImport("ws2_32.dll", SetLastError = true)] - static extern int closesocket(IntPtr socketHandle); - } - private static void AssertEqualOrSameException(Func expected, Func actual) { T r1 = default, r2 = default;