From eeb0b21c5ed62764329331bd3eff4110a5db2e70 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 25 Aug 2021 20:32:45 +0200 Subject: [PATCH 1/7] Increase some of the DnsEndPointTest timeouts --- .../tests/FunctionalTests/DnsEndPointTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs index 1e362a04819c0f..484eec5cd529ab 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs @@ -53,7 +53,7 @@ public void Socket_ConnectDnsEndPoint_SetSocketProperties_Success(SocketImplemen } } - [OuterLoop] + //[OuterLoop] [Fact] public void Socket_ConnectDnsEndPoint_Failure() { @@ -272,7 +272,7 @@ public void Socket_ConnectAsyncDnsEndPoint_HostNotFound() bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TimeSpan.FromSeconds(30)), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -332,7 +332,7 @@ public void Socket_StaticConnectAsync_Success(SocketImplementationType type) if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args)) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TimeSpan.FromSeconds(30)), "Timed out while waiting for connection"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -404,7 +404,7 @@ public void Socket_StaticConnectAsync_HostNotFound() OnConnectAsyncCompleted(null, args); } - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TimeSpan.FromSeconds(30)), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance AssertHostNotFoundOrNoData(args); From d9a1302178f6331604d05389492b96f31759166e Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 25 Aug 2021 20:35:20 +0200 Subject: [PATCH 2/7] remove accidental comment --- .../System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs index 484eec5cd529ab..dd6d437ef89205 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs @@ -53,7 +53,7 @@ public void Socket_ConnectDnsEndPoint_SetSocketProperties_Success(SocketImplemen } } - //[OuterLoop] + [OuterLoop] [Fact] public void Socket_ConnectDnsEndPoint_Failure() { From 75caacfad4a935e290fc6d459d0e504288c68aa6 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 31 Aug 2021 15:53:01 +0200 Subject: [PATCH 3/7] PassingTestTimeout -> PassingTestShortTimeout & PassingTestLongTimeout --- .../Net/Sockets/SocketTestServerAsync.cs | 2 +- .../tests/System/Net/Sockets/TestSettings.cs | 5 +-- .../FunctionalTests/CreateSocketTests.cs | 4 +-- .../FunctionalTests/DisposedSocketTests.cs | 2 +- .../tests/FunctionalTests/DnsEndPointTest.cs | 18 +++++------ .../FunctionalTests/DualModeSocketTest.cs | 32 +++++++++---------- .../ExecutionContextFlowTest.cs | 4 +-- .../tests/FunctionalTests/SendPacketsAsync.cs | 12 +++---- .../SendReceive/SendReceive.cs | 12 +++---- .../SendReceive/SendReceiveMisc.cs | 6 ++-- .../SocketAsyncEventArgsTest.cs | 2 +- .../tests/FunctionalTests/UdpClientTest.cs | 2 +- 12 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs b/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs index e42d4b55cd810f..c3adfbb46c2578 100644 --- a/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs +++ b/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs @@ -136,7 +136,7 @@ private void StartAccept(SocketAsyncEventArgs acceptEventArg) } _log.WriteLine(this.GetHashCode() + " StartAccept(_numConnectedSockets={0})", _numConnectedSockets); - if (!_maxNumberAcceptedClientsSemaphore.WaitOne(TestSettings.PassingTestTimeout)) + if (!_maxNumberAcceptedClientsSemaphore.WaitOne(TestSettings.PassingTestShortTimeout)) { throw new TimeoutException("Timeout waiting for client connection."); } diff --git a/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs b/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs index 0accade3d3f445..59700d9eb5c25c 100644 --- a/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs +++ b/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs @@ -8,9 +8,10 @@ namespace System.Net.Sockets.Tests public static class TestSettings { // Timeout values in milliseconds. - public const int PassingTestTimeout = 10000; + public const int PassingTestShortTimeout = 10_000; + public const int PassingTestLongTimeout = 30_000; public const int FailingTestTimeout = 100; - public static Task WhenAllOrAnyFailedWithTimeout(params Task[] tasks) => tasks.WhenAllOrAnyFailed(PassingTestTimeout); + public static Task WhenAllOrAnyFailedWithTimeout(params Task[] tasks) => tasks.WhenAllOrAnyFailed(PassingTestShortTimeout); } } diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs index 552c77e9044216..6df926b7132ee4 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs @@ -480,7 +480,7 @@ await Task.Run(async () => } } } - }).WaitAsync(TestSettings.PassingTestTimeout); + }).WaitAsync(TestSettings.PassingTestShortTimeout); } [DllImport("libc")] @@ -611,7 +611,7 @@ public unsafe void Ctor_SafeHandle_UnknownSocket_Success() netlink.Send(new ReadOnlySpan(Unsafe.AsPointer(ref req), sizeof(nl_request))); - Assert.True(netlink.Poll(TestSettings.PassingTestTimeout, SelectMode.SelectRead)); + Assert.True(netlink.Poll(TestSettings.PassingTestShortTimeout, SelectMode.SelectRead)); byte[] response = new byte[4000]; int readBytes = netlink.Receive(response); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs index c8394930b552a8..4d67cfb025012e 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs @@ -772,7 +772,7 @@ public class DisposedSocketTestsNonParallel [InlineData(true)] public async Task NonDisposedSocket_SafeHandlesCollected(bool clientAsync) { - TimeSpan timeout = TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout); + TimeSpan timeout = TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout); List handles = await CreateHandlesAsync(clientAsync).WaitAsync(timeout); await RetryHelper.ExecuteAsync(() => Task.Run(() => { diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs index dd6d437ef89205..8452ef4546e10a 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs @@ -205,7 +205,7 @@ public void Socket_ConnectAsyncDnsEndPoint_Success(SocketImplementationType type bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -244,7 +244,7 @@ public void Socket_ConnectAsyncDnsEndPoint_SetSocketProperties_Success(SocketImp bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -272,7 +272,7 @@ public void Socket_ConnectAsyncDnsEndPoint_HostNotFound() bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TimeSpan.FromSeconds(30)), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestLongTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -299,7 +299,7 @@ public void Socket_ConnectAsyncDnsEndPoint_ConnectionRefused() bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -332,7 +332,7 @@ public void Socket_StaticConnectAsync_Success(SocketImplementationType type) if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args)) { - Assert.True(complete.WaitOne(TimeSpan.FromSeconds(30)), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestLongTimeout), "Timed out while waiting for connection"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -348,7 +348,7 @@ public void Socket_StaticConnectAsync_Success(SocketImplementationType type) if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args)) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); } complete.Dispose(); // only dispose on success as we know we're done with the instance @@ -377,7 +377,7 @@ public void Socket_StaticConnectAsync_IPv6MappedIPv4_Success() if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args)) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -404,7 +404,7 @@ public void Socket_StaticConnectAsync_HostNotFound() OnConnectAsyncCompleted(null, args); } - Assert.True(complete.WaitOne(TimeSpan.FromSeconds(30)), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestLongTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance AssertHostNotFoundOrNoData(args); @@ -431,7 +431,7 @@ public void Socket_StaticConnectAsync_ConnectionRefused() OnConnectAsyncCompleted(null, args); } - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance Assert.Equal(SocketError.ConnectionRefused, args.SocketError); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs index 4b419358a2fa02..7c0c1d5ccd018b 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs @@ -545,7 +545,7 @@ private void DualModeConnectAsync_IPEndPointToHost_Helper(IPAddress connectTo, I if (!pending) waitHandle.Set(); - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); if (args.SocketError != SocketError.Success) { throw new SocketException((int)args.SocketError); @@ -585,7 +585,7 @@ public void DualModeConnectAsync_DnsEndPointToHost_Helper(IPAddress listenOn, bo if (!pending) waitHandle.Set(); - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); if (args.SocketError != SocketError.Success) { throw new SocketException((int)args.SocketError); @@ -611,7 +611,7 @@ public void DualModeConnectAsync_Static_DnsEndPointToHost_Helper(IPAddress liste if (!pending) waitHandle.Set(); - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); if (args.SocketError != SocketError.Success) { throw new SocketException((int)args.SocketError); @@ -845,10 +845,10 @@ private void DualModeConnect_BeginAccept_Helper(IPAddress listenOn, IPAddress co SocketClient client = new SocketClient(_log, serverSocket, connectTo, port); Assert.True( - client.WaitHandle.WaitOne(TestSettings.PassingTestTimeout), + client.WaitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); Assert.True( - async.AsyncWaitHandle.WaitOne(TestSettings.PassingTestTimeout), + async.AsyncWaitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting to accept the client"); // Due to the nondeterministic nature of calling dispose on a Socket that is doing @@ -969,7 +969,7 @@ private void DualModeConnect_AcceptAsync_Helper(IPAddress listenOn, IPAddress co waitHandles[0] = waitHandle; waitHandles[1] = client.WaitHandle; - int completedHandle = WaitHandle.WaitAny(waitHandles, TestSettings.PassingTestTimeout); + int completedHandle = WaitHandle.WaitAny(waitHandles, TestSettings.PassingTestShortTimeout); if (completedHandle == WaitHandle.WaitTimeout) { @@ -1101,7 +1101,7 @@ private void DualModeSendTo_IPEndPointToHost_Helper(IPAddress connectTo, IPAddre int sent = client.SendTo(new byte[1], new IPEndPoint(connectTo, port)); Assert.Equal(1, sent); - bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); // Make sure the bytes were received + bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); // Make sure the bytes were received if (!success) { throw new TimeoutException(); @@ -1202,7 +1202,7 @@ private void DualModeBeginSendTo_EndPointToHost_Helper(IPAddress connectTo, IPAd int sent = client.EndSendTo(async); Assert.Equal(1, sent); - bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); // Make sure the bytes were received + bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); // Make sure the bytes were received if (!success) { throw new TimeoutException(); @@ -1326,7 +1326,7 @@ private void DualModeSendToAsync_IPEndPointToHost_Helper(IPAddress connectTo, IP bool async = client.SendToAsync(args); if (async) { - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timeout while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timeout while waiting for connection"); } Assert.Equal(1, args.BytesTransferred); @@ -1336,7 +1336,7 @@ private void DualModeSendToAsync_IPEndPointToHost_Helper(IPAddress connectTo, IP } } - bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); // Make sure the bytes were received + bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); // Make sure the bytes were received if (!success) { throw new TimeoutException(); @@ -1606,7 +1606,7 @@ private void BeginReceiveFrom_Helper(IPAddress listenOn, IPAddress connectTo, bo // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address); SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); - bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); + bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); if (!success) { throw new TimeoutException(); @@ -1751,7 +1751,7 @@ private void ReceiveFromAsync_Helper(IPAddress listenOn, IPAddress connectTo, bo bool async = serverSocket.ReceiveFromAsync(args); SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); - if (async && !waitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout)) + if (async && !waitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout)) { throw new TimeoutException(); } @@ -1984,7 +1984,7 @@ public void ReceiveMessageFromAsync_SocketAsyncEventArgs_Success(bool ipv4) { completed.Set(); } - Assert.True(completed.Wait(TestSettings.PassingTestTimeout), "Timeout while waiting for connection"); + Assert.True(completed.Wait(TestSettings.PassingTestShortTimeout), "Timeout while waiting for connection"); completed.Reset(); Assert.Equal(DataLength, args.BytesTransferred); @@ -2031,7 +2031,7 @@ private void ReceiveMessageFrom_Helper(IPAddress listenOn, IPAddress connectTo, }); } - serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout; + serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout; SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); @@ -2201,7 +2201,7 @@ private void BeginReceiveMessageFrom_Helper(IPAddress listenOn, IPAddress connec // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address); SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); - bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); + bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); if (!success) { throw new TimeoutException(); @@ -2361,7 +2361,7 @@ private void ReceiveMessageFromAsync_Helper(IPAddress listenOn, IPAddress connec { using (Socket serverSocket = new Socket(SocketType.Dgram, ProtocolType.Udp)) { - serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout; + serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout; int port = serverSocket.BindToAnonymousPort(listenOn); ManualResetEvent waitHandle = new ManualResetEvent(false); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs index dd4c41fbb1a800..c9d4f64aa56902 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs @@ -524,7 +524,7 @@ public void ExecutionContext_NotCachedInSocketAsyncEventArgs() al.Value = null; server.Send(new byte[1]); - Assert.True(receiveCompleted.Wait(TestSettings.PassingTestTimeout)); + Assert.True(receiveCompleted.Wait(TestSettings.PassingTestShortTimeout)); for (int i = 0; i < 3; i++) { @@ -532,7 +532,7 @@ public void ExecutionContext_NotCachedInSocketAsyncEventArgs() GC.WaitForPendingFinalizers(); } - Assert.True(ecDropped.Wait(TestSettings.PassingTestTimeout)); + Assert.True(ecDropped.Wait(TestSettings.PassingTestShortTimeout)); } } } diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs index 29c24352c1a76c..d0b99b652e8498 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs @@ -208,7 +208,7 @@ public void BufferZeroCountThenNormal_ZeroCountIgnored(BufferType bufferType) args.SendPacketsElements = new SendPacketsElement[] { e1.Element }; if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -221,7 +221,7 @@ public void BufferZeroCountThenNormal_ZeroCountIgnored(BufferType bufferType) args.SendPacketsElements = new SendPacketsElement[] { e2.Element }; if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -381,13 +381,13 @@ public void SendPacketsElement_FileStreamIsReleasedOnError() if (r1) { - Assert.True(completed1.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); + Assert.True(completed1.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); } Assert.Equal(SocketError.Success, args1.SocketError); if (r2) { - Assert.True(completed2.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); + Assert.True(completed2.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); } Assert.Equal(SocketError.InvalidArgument, args2.SocketError); @@ -639,7 +639,7 @@ private void SendPackets(SendPacketsElement element, TransmitFileOptions flags, if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); } Assert.Equal(SocketError.Success, args.SocketError); Assert.Equal(bytesExpected, args.BytesTransferred); @@ -690,7 +690,7 @@ private void SendPackets(SendPacketsElement[] elements, SocketError expectedResu if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); } Assert.Equal(expectedResult, args.SocketError); Assert.Equal(bytesExpected, args.BytesTransferred); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs index 4d43977fa2b3cf..47fdfda77fe47b 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs @@ -953,7 +953,7 @@ await RetryHelper.ExecuteAsync(async () => Task disposeTask = Task.Run(() => socket.Dispose()); await Task.WhenAny(disposeTask, receiveTask) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); await disposeTask; SocketError? localSocketError = null; @@ -1030,7 +1030,7 @@ await RetryHelper.ExecuteAsync(async () => while (true) { SendAsync(socket1, buffer) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)) + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)) .GetAwaiter().GetResult(); } }); @@ -1042,16 +1042,16 @@ await RetryHelper.ExecuteAsync(async () => Task disposeTask = Task.Run(() => socket1.Dispose()); await Task.WhenAny(disposeTask, socketOperation) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); await disposeTask - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); SocketError? localSocketError = null; bool disposedException = false; try { await socketOperation - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); } catch (SocketException se) { @@ -1087,7 +1087,7 @@ await socketOperation try { int received = await ReceiveAsync(socket2, receiveBuffer) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); if (received == 0) { break; diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs index 0a28ab0a52ee2b..891ad618e43890 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs @@ -250,7 +250,7 @@ public async Task Socket_ReceiveFlags_Success() args.SocketFlags = SocketFlags.Peek; if (receiver.ReceiveAsync(args)) { - await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); + await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); } Assert.Equal(SocketFlags.None, args.SocketFlags); Assert.Equal(1, receiveBuffer[0]); @@ -262,7 +262,7 @@ public async Task Socket_ReceiveFlags_Success() args.SocketFlags = SocketFlags.None; if (receiver.ReceiveAsync(args)) { - await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); + await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); } Assert.Equal(SocketFlags.None, args.SocketFlags); Assert.Equal(1, receiveBuffer[0]); @@ -274,7 +274,7 @@ public async Task Socket_ReceiveFlags_Success() args.SetBuffer(receiveBuffer, 0, 100); if (receiver.ReceiveAsync(args)) { - await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); + await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); } Assert.Equal(SocketFlags.Truncated, args.SocketFlags); Assert.Equal(2, receiveBuffer[0]); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs index 2c0ec09e6a6cf5..5b2ac24fe59100 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs @@ -577,7 +577,7 @@ public void AcceptAsync_WithReceiveBuffer_Success() client.Shutdown(SocketShutdown.Both); } - Assert.True(accepted.WaitOne(TestSettings.PassingTestTimeout), "Test completed in allotted time"); + Assert.True(accepted.WaitOne(TestSettings.PassingTestShortTimeout), "Test completed in allotted time"); Assert.Equal(SocketError.Success, acceptArgs.SocketError); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs index 66f69e1ce70da4..d155b3652f14d6 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs @@ -370,7 +370,7 @@ public void BeginSend_AsyncOperationCompletes_Success() _waitHandle.Reset(); udpClient.BeginSend(sendBytes, sendBytes.Length, remoteServer, new AsyncCallback(AsyncCompleted), udpClient); - Assert.True(_waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); + Assert.True(_waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); } } From 4daff4b001b4e529126d9f65832f6786ec07967a Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 1 Sep 2021 15:08:25 +0200 Subject: [PATCH 4/7] undo renaming PassingTestTimeout --- .../Net/Sockets/SocketTestServerAsync.cs | 2 +- .../tests/System/Net/Sockets/TestSettings.cs | 4 +-- .../FunctionalTests/CreateSocketTests.cs | 4 +-- .../FunctionalTests/DisposedSocketTests.cs | 2 +- .../tests/FunctionalTests/DnsEndPointTest.cs | 12 +++---- .../FunctionalTests/DualModeSocketTest.cs | 32 +++++++++---------- .../ExecutionContextFlowTest.cs | 4 +-- .../tests/FunctionalTests/SendPacketsAsync.cs | 12 +++---- .../SendReceive/SendReceive.cs | 12 +++---- .../SendReceive/SendReceiveMisc.cs | 6 ++-- .../SocketAsyncEventArgsTest.cs | 2 +- .../tests/FunctionalTests/UdpClientTest.cs | 2 +- 12 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs b/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs index c3adfbb46c2578..e26e9fa84bef5d 100644 --- a/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs +++ b/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs @@ -136,7 +136,7 @@ private void StartAccept(SocketAsyncEventArgs acceptEventArg) } _log.WriteLine(this.GetHashCode() + " StartAccept(_numConnectedSockets={0})", _numConnectedSockets); - if (!_maxNumberAcceptedClientsSemaphore.WaitOne(TestSettings.PassingTestShortTimeout)) + if (!_maxNumberAcceptedClientsSemaphore.WaitOne(TestSettings.PassingTestTimeout )) { throw new TimeoutException("Timeout waiting for client connection."); } diff --git a/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs b/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs index 59700d9eb5c25c..5d966928a0ad00 100644 --- a/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs +++ b/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs @@ -8,10 +8,10 @@ namespace System.Net.Sockets.Tests public static class TestSettings { // Timeout values in milliseconds. - public const int PassingTestShortTimeout = 10_000; + public const int PassingTestTimeout = 10_000; public const int PassingTestLongTimeout = 30_000; public const int FailingTestTimeout = 100; - public static Task WhenAllOrAnyFailedWithTimeout(params Task[] tasks) => tasks.WhenAllOrAnyFailed(PassingTestShortTimeout); + public static Task WhenAllOrAnyFailedWithTimeout(params Task[] tasks) => tasks.WhenAllOrAnyFailed(PassingTestTimeout ); } } diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs index 6df926b7132ee4..01c8a291aaf76b 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs @@ -480,7 +480,7 @@ await Task.Run(async () => } } } - }).WaitAsync(TestSettings.PassingTestShortTimeout); + }).WaitAsync(TestSettings.PassingTestTimeout ); } [DllImport("libc")] @@ -611,7 +611,7 @@ public unsafe void Ctor_SafeHandle_UnknownSocket_Success() netlink.Send(new ReadOnlySpan(Unsafe.AsPointer(ref req), sizeof(nl_request))); - Assert.True(netlink.Poll(TestSettings.PassingTestShortTimeout, SelectMode.SelectRead)); + Assert.True(netlink.Poll(TestSettings.PassingTestTimeout , SelectMode.SelectRead)); byte[] response = new byte[4000]; int readBytes = netlink.Receive(response); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs index 4d67cfb025012e..5b029358c293b0 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs @@ -772,7 +772,7 @@ public class DisposedSocketTestsNonParallel [InlineData(true)] public async Task NonDisposedSocket_SafeHandlesCollected(bool clientAsync) { - TimeSpan timeout = TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout); + TimeSpan timeout = TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout ); List handles = await CreateHandlesAsync(clientAsync).WaitAsync(timeout); await RetryHelper.ExecuteAsync(() => Task.Run(() => { diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs index 8452ef4546e10a..0e0e0cb9d1696b 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs @@ -205,7 +205,7 @@ public void Socket_ConnectAsyncDnsEndPoint_Success(SocketImplementationType type bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -244,7 +244,7 @@ public void Socket_ConnectAsyncDnsEndPoint_SetSocketProperties_Success(SocketImp bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -299,7 +299,7 @@ public void Socket_ConnectAsyncDnsEndPoint_ConnectionRefused() bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -348,7 +348,7 @@ public void Socket_StaticConnectAsync_Success(SocketImplementationType type) if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args)) { - Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); } complete.Dispose(); // only dispose on success as we know we're done with the instance @@ -377,7 +377,7 @@ public void Socket_StaticConnectAsync_IPv6MappedIPv4_Success() if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args)) { - Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -431,7 +431,7 @@ public void Socket_StaticConnectAsync_ConnectionRefused() OnConnectAsyncCompleted(null, args); } - Assert.True(complete.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance Assert.Equal(SocketError.ConnectionRefused, args.SocketError); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs index 7c0c1d5ccd018b..924aa4ec43ac6a 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs @@ -545,7 +545,7 @@ private void DualModeConnectAsync_IPEndPointToHost_Helper(IPAddress connectTo, I if (!pending) waitHandle.Set(); - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); if (args.SocketError != SocketError.Success) { throw new SocketException((int)args.SocketError); @@ -585,7 +585,7 @@ public void DualModeConnectAsync_DnsEndPointToHost_Helper(IPAddress listenOn, bo if (!pending) waitHandle.Set(); - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); if (args.SocketError != SocketError.Success) { throw new SocketException((int)args.SocketError); @@ -611,7 +611,7 @@ public void DualModeConnectAsync_Static_DnsEndPointToHost_Helper(IPAddress liste if (!pending) waitHandle.Set(); - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); if (args.SocketError != SocketError.Success) { throw new SocketException((int)args.SocketError); @@ -845,10 +845,10 @@ private void DualModeConnect_BeginAccept_Helper(IPAddress listenOn, IPAddress co SocketClient client = new SocketClient(_log, serverSocket, connectTo, port); Assert.True( - client.WaitHandle.WaitOne(TestSettings.PassingTestShortTimeout), + client.WaitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); Assert.True( - async.AsyncWaitHandle.WaitOne(TestSettings.PassingTestShortTimeout), + async.AsyncWaitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting to accept the client"); // Due to the nondeterministic nature of calling dispose on a Socket that is doing @@ -969,7 +969,7 @@ private void DualModeConnect_AcceptAsync_Helper(IPAddress listenOn, IPAddress co waitHandles[0] = waitHandle; waitHandles[1] = client.WaitHandle; - int completedHandle = WaitHandle.WaitAny(waitHandles, TestSettings.PassingTestShortTimeout); + int completedHandle = WaitHandle.WaitAny(waitHandles, TestSettings.PassingTestTimeout ); if (completedHandle == WaitHandle.WaitTimeout) { @@ -1101,7 +1101,7 @@ private void DualModeSendTo_IPEndPointToHost_Helper(IPAddress connectTo, IPAddre int sent = client.SendTo(new byte[1], new IPEndPoint(connectTo, port)); Assert.Equal(1, sent); - bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); // Make sure the bytes were received + bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); // Make sure the bytes were received if (!success) { throw new TimeoutException(); @@ -1202,7 +1202,7 @@ private void DualModeBeginSendTo_EndPointToHost_Helper(IPAddress connectTo, IPAd int sent = client.EndSendTo(async); Assert.Equal(1, sent); - bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); // Make sure the bytes were received + bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); // Make sure the bytes were received if (!success) { throw new TimeoutException(); @@ -1326,7 +1326,7 @@ private void DualModeSendToAsync_IPEndPointToHost_Helper(IPAddress connectTo, IP bool async = client.SendToAsync(args); if (async) { - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timeout while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timeout while waiting for connection"); } Assert.Equal(1, args.BytesTransferred); @@ -1336,7 +1336,7 @@ private void DualModeSendToAsync_IPEndPointToHost_Helper(IPAddress connectTo, IP } } - bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); // Make sure the bytes were received + bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); // Make sure the bytes were received if (!success) { throw new TimeoutException(); @@ -1606,7 +1606,7 @@ private void BeginReceiveFrom_Helper(IPAddress listenOn, IPAddress connectTo, bo // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address); SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); - bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); + bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); if (!success) { throw new TimeoutException(); @@ -1751,7 +1751,7 @@ private void ReceiveFromAsync_Helper(IPAddress listenOn, IPAddress connectTo, bo bool async = serverSocket.ReceiveFromAsync(args); SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); - if (async && !waitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout)) + if (async && !waitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout )) { throw new TimeoutException(); } @@ -1984,7 +1984,7 @@ public void ReceiveMessageFromAsync_SocketAsyncEventArgs_Success(bool ipv4) { completed.Set(); } - Assert.True(completed.Wait(TestSettings.PassingTestShortTimeout), "Timeout while waiting for connection"); + Assert.True(completed.Wait(TestSettings.PassingTestTimeout ), "Timeout while waiting for connection"); completed.Reset(); Assert.Equal(DataLength, args.BytesTransferred); @@ -2031,7 +2031,7 @@ private void ReceiveMessageFrom_Helper(IPAddress listenOn, IPAddress connectTo, }); } - serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout; + serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ; SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); @@ -2201,7 +2201,7 @@ private void BeginReceiveMessageFrom_Helper(IPAddress listenOn, IPAddress connec // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address); SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); - bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout); + bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); if (!success) { throw new TimeoutException(); @@ -2361,7 +2361,7 @@ private void ReceiveMessageFromAsync_Helper(IPAddress listenOn, IPAddress connec { using (Socket serverSocket = new Socket(SocketType.Dgram, ProtocolType.Udp)) { - serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestShortTimeout; + serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ; int port = serverSocket.BindToAnonymousPort(listenOn); ManualResetEvent waitHandle = new ManualResetEvent(false); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs index c9d4f64aa56902..44b23cdb7f30dd 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs @@ -524,7 +524,7 @@ public void ExecutionContext_NotCachedInSocketAsyncEventArgs() al.Value = null; server.Send(new byte[1]); - Assert.True(receiveCompleted.Wait(TestSettings.PassingTestShortTimeout)); + Assert.True(receiveCompleted.Wait(TestSettings.PassingTestTimeout )); for (int i = 0; i < 3; i++) { @@ -532,7 +532,7 @@ public void ExecutionContext_NotCachedInSocketAsyncEventArgs() GC.WaitForPendingFinalizers(); } - Assert.True(ecDropped.Wait(TestSettings.PassingTestShortTimeout)); + Assert.True(ecDropped.Wait(TestSettings.PassingTestTimeout )); } } } diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs index d0b99b652e8498..7ce36f751a1a06 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs @@ -208,7 +208,7 @@ public void BufferZeroCountThenNormal_ZeroCountIgnored(BufferType bufferType) args.SendPacketsElements = new SendPacketsElement[] { e1.Element }; if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -221,7 +221,7 @@ public void BufferZeroCountThenNormal_ZeroCountIgnored(BufferType bufferType) args.SendPacketsElements = new SendPacketsElement[] { e2.Element }; if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -381,13 +381,13 @@ public void SendPacketsElement_FileStreamIsReleasedOnError() if (r1) { - Assert.True(completed1.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); + Assert.True(completed1.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); } Assert.Equal(SocketError.Success, args1.SocketError); if (r2) { - Assert.True(completed2.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); + Assert.True(completed2.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); } Assert.Equal(SocketError.InvalidArgument, args2.SocketError); @@ -639,7 +639,7 @@ private void SendPackets(SendPacketsElement element, TransmitFileOptions flags, if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); } Assert.Equal(SocketError.Success, args.SocketError); Assert.Equal(bytesExpected, args.BytesTransferred); @@ -690,7 +690,7 @@ private void SendPackets(SendPacketsElement[] elements, SocketError expectedResu if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); } Assert.Equal(expectedResult, args.SocketError); Assert.Equal(bytesExpected, args.BytesTransferred); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs index 47fdfda77fe47b..a05ccde94c7ba7 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs @@ -953,7 +953,7 @@ await RetryHelper.ExecuteAsync(async () => Task disposeTask = Task.Run(() => socket.Dispose()); await Task.WhenAny(disposeTask, receiveTask) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); await disposeTask; SocketError? localSocketError = null; @@ -1030,7 +1030,7 @@ await RetryHelper.ExecuteAsync(async () => while (true) { SendAsync(socket1, buffer) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)) + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )) .GetAwaiter().GetResult(); } }); @@ -1042,16 +1042,16 @@ await RetryHelper.ExecuteAsync(async () => Task disposeTask = Task.Run(() => socket1.Dispose()); await Task.WhenAny(disposeTask, socketOperation) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); await disposeTask - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); SocketError? localSocketError = null; bool disposedException = false; try { await socketOperation - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); } catch (SocketException se) { @@ -1087,7 +1087,7 @@ await socketOperation try { int received = await ReceiveAsync(socket2, receiveBuffer) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); if (received == 0) { break; diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs index 891ad618e43890..d4772440196bdd 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs @@ -250,7 +250,7 @@ public async Task Socket_ReceiveFlags_Success() args.SocketFlags = SocketFlags.Peek; if (receiver.ReceiveAsync(args)) { - await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); + await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); } Assert.Equal(SocketFlags.None, args.SocketFlags); Assert.Equal(1, receiveBuffer[0]); @@ -262,7 +262,7 @@ public async Task Socket_ReceiveFlags_Success() args.SocketFlags = SocketFlags.None; if (receiver.ReceiveAsync(args)) { - await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); + await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); } Assert.Equal(SocketFlags.None, args.SocketFlags); Assert.Equal(1, receiveBuffer[0]); @@ -274,7 +274,7 @@ public async Task Socket_ReceiveFlags_Success() args.SetBuffer(receiveBuffer, 0, 100); if (receiver.ReceiveAsync(args)) { - await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestShortTimeout)); + await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); } Assert.Equal(SocketFlags.Truncated, args.SocketFlags); Assert.Equal(2, receiveBuffer[0]); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs index 5b2ac24fe59100..a64e3443e386ac 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs @@ -577,7 +577,7 @@ public void AcceptAsync_WithReceiveBuffer_Success() client.Shutdown(SocketShutdown.Both); } - Assert.True(accepted.WaitOne(TestSettings.PassingTestShortTimeout), "Test completed in allotted time"); + Assert.True(accepted.WaitOne(TestSettings.PassingTestTimeout ), "Test completed in allotted time"); Assert.Equal(SocketError.Success, acceptArgs.SocketError); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs index d155b3652f14d6..c84bb5565f6670 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs @@ -370,7 +370,7 @@ public void BeginSend_AsyncOperationCompletes_Success() _waitHandle.Reset(); udpClient.BeginSend(sendBytes, sendBytes.Length, remoteServer, new AsyncCallback(AsyncCompleted), udpClient); - Assert.True(_waitHandle.WaitOne(TestSettings.PassingTestShortTimeout), "Timed out while waiting for connection"); + Assert.True(_waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); } } From 918b59f8dbb1166704c1f970f7c6525bc3d23b80 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 1 Sep 2021 15:25:33 +0200 Subject: [PATCH 5/7] remove whitespaces VS inserted --- .../FunctionalTests/CreateSocketTests.cs | 2 +- .../FunctionalTests/DisposedSocketTests.cs | 2 +- .../tests/FunctionalTests/DnsEndPointTest.cs | 10 +++--- .../FunctionalTests/DualModeSocketTest.cs | 32 +++++++++---------- .../ExecutionContextFlowTest.cs | 4 +-- .../tests/FunctionalTests/SendPacketsAsync.cs | 12 +++---- .../SendReceive/SendReceive.cs | 12 +++---- .../SendReceive/SendReceiveMisc.cs | 6 ++-- .../SocketAsyncEventArgsTest.cs | 2 +- .../tests/FunctionalTests/UdpClientTest.cs | 2 +- 10 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs index 01c8a291aaf76b..1061bdf090945b 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs @@ -480,7 +480,7 @@ await Task.Run(async () => } } } - }).WaitAsync(TestSettings.PassingTestTimeout ); + }).WaitAsync(TestSettings.PassingTestTimeout); } [DllImport("libc")] diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs index 5b029358c293b0..c8394930b552a8 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DisposedSocketTests.cs @@ -772,7 +772,7 @@ public class DisposedSocketTestsNonParallel [InlineData(true)] public async Task NonDisposedSocket_SafeHandlesCollected(bool clientAsync) { - TimeSpan timeout = TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout ); + TimeSpan timeout = TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout); List handles = await CreateHandlesAsync(clientAsync).WaitAsync(timeout); await RetryHelper.ExecuteAsync(() => Task.Run(() => { diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs index 0e0e0cb9d1696b..5b2ea19d3a93c9 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs @@ -205,7 +205,7 @@ public void Socket_ConnectAsyncDnsEndPoint_Success(SocketImplementationType type bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -299,7 +299,7 @@ public void Socket_ConnectAsyncDnsEndPoint_ConnectionRefused() bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } @@ -348,7 +348,7 @@ public void Socket_StaticConnectAsync_Success(SocketImplementationType type) if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args)) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestLongTimeout), "Timed out while waiting for connection"); } complete.Dispose(); // only dispose on success as we know we're done with the instance @@ -377,7 +377,7 @@ public void Socket_StaticConnectAsync_IPv6MappedIPv4_Success() if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, args)) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -431,7 +431,7 @@ public void Socket_StaticConnectAsync_ConnectionRefused() OnConnectAsyncCompleted(null, args); } - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance Assert.Equal(SocketError.ConnectionRefused, args.SocketError); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs index 924aa4ec43ac6a..4b419358a2fa02 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs @@ -545,7 +545,7 @@ private void DualModeConnectAsync_IPEndPointToHost_Helper(IPAddress connectTo, I if (!pending) waitHandle.Set(); - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); if (args.SocketError != SocketError.Success) { throw new SocketException((int)args.SocketError); @@ -585,7 +585,7 @@ public void DualModeConnectAsync_DnsEndPointToHost_Helper(IPAddress listenOn, bo if (!pending) waitHandle.Set(); - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); if (args.SocketError != SocketError.Success) { throw new SocketException((int)args.SocketError); @@ -611,7 +611,7 @@ public void DualModeConnectAsync_Static_DnsEndPointToHost_Helper(IPAddress liste if (!pending) waitHandle.Set(); - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); if (args.SocketError != SocketError.Success) { throw new SocketException((int)args.SocketError); @@ -845,10 +845,10 @@ private void DualModeConnect_BeginAccept_Helper(IPAddress listenOn, IPAddress co SocketClient client = new SocketClient(_log, serverSocket, connectTo, port); Assert.True( - client.WaitHandle.WaitOne(TestSettings.PassingTestTimeout ), + client.WaitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); Assert.True( - async.AsyncWaitHandle.WaitOne(TestSettings.PassingTestTimeout ), + async.AsyncWaitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting to accept the client"); // Due to the nondeterministic nature of calling dispose on a Socket that is doing @@ -969,7 +969,7 @@ private void DualModeConnect_AcceptAsync_Helper(IPAddress listenOn, IPAddress co waitHandles[0] = waitHandle; waitHandles[1] = client.WaitHandle; - int completedHandle = WaitHandle.WaitAny(waitHandles, TestSettings.PassingTestTimeout ); + int completedHandle = WaitHandle.WaitAny(waitHandles, TestSettings.PassingTestTimeout); if (completedHandle == WaitHandle.WaitTimeout) { @@ -1101,7 +1101,7 @@ private void DualModeSendTo_IPEndPointToHost_Helper(IPAddress connectTo, IPAddre int sent = client.SendTo(new byte[1], new IPEndPoint(connectTo, port)); Assert.Equal(1, sent); - bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); // Make sure the bytes were received + bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); // Make sure the bytes were received if (!success) { throw new TimeoutException(); @@ -1202,7 +1202,7 @@ private void DualModeBeginSendTo_EndPointToHost_Helper(IPAddress connectTo, IPAd int sent = client.EndSendTo(async); Assert.Equal(1, sent); - bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); // Make sure the bytes were received + bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); // Make sure the bytes were received if (!success) { throw new TimeoutException(); @@ -1326,7 +1326,7 @@ private void DualModeSendToAsync_IPEndPointToHost_Helper(IPAddress connectTo, IP bool async = client.SendToAsync(args); if (async) { - Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timeout while waiting for connection"); + Assert.True(waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timeout while waiting for connection"); } Assert.Equal(1, args.BytesTransferred); @@ -1336,7 +1336,7 @@ private void DualModeSendToAsync_IPEndPointToHost_Helper(IPAddress connectTo, IP } } - bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); // Make sure the bytes were received + bool success = server.WaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); // Make sure the bytes were received if (!success) { throw new TimeoutException(); @@ -1606,7 +1606,7 @@ private void BeginReceiveFrom_Helper(IPAddress listenOn, IPAddress connectTo, bo // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address); SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); - bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); + bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); if (!success) { throw new TimeoutException(); @@ -1751,7 +1751,7 @@ private void ReceiveFromAsync_Helper(IPAddress listenOn, IPAddress connectTo, bo bool async = serverSocket.ReceiveFromAsync(args); SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); - if (async && !waitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout )) + if (async && !waitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout)) { throw new TimeoutException(); } @@ -1984,7 +1984,7 @@ public void ReceiveMessageFromAsync_SocketAsyncEventArgs_Success(bool ipv4) { completed.Set(); } - Assert.True(completed.Wait(TestSettings.PassingTestTimeout ), "Timeout while waiting for connection"); + Assert.True(completed.Wait(TestSettings.PassingTestTimeout), "Timeout while waiting for connection"); completed.Reset(); Assert.Equal(DataLength, args.BytesTransferred); @@ -2031,7 +2031,7 @@ private void ReceiveMessageFrom_Helper(IPAddress listenOn, IPAddress connectTo, }); } - serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ; + serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout; SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); @@ -2201,7 +2201,7 @@ private void BeginReceiveMessageFrom_Helper(IPAddress listenOn, IPAddress connec // Assert.Equal(connectTo.MapToIPv6(), remoteEndPoint.Address); SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); - bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ); + bool success = async.AsyncWaitHandle.WaitOne(expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout); if (!success) { throw new TimeoutException(); @@ -2361,7 +2361,7 @@ private void ReceiveMessageFromAsync_Helper(IPAddress listenOn, IPAddress connec { using (Socket serverSocket = new Socket(SocketType.Dgram, ProtocolType.Udp)) { - serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout ; + serverSocket.ReceiveTimeout = expectedToTimeout ? TestSettings.FailingTestTimeout : TestSettings.PassingTestTimeout; int port = serverSocket.BindToAnonymousPort(listenOn); ManualResetEvent waitHandle = new ManualResetEvent(false); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs index 44b23cdb7f30dd..dd4c41fbb1a800 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs @@ -524,7 +524,7 @@ public void ExecutionContext_NotCachedInSocketAsyncEventArgs() al.Value = null; server.Send(new byte[1]); - Assert.True(receiveCompleted.Wait(TestSettings.PassingTestTimeout )); + Assert.True(receiveCompleted.Wait(TestSettings.PassingTestTimeout)); for (int i = 0; i < 3; i++) { @@ -532,7 +532,7 @@ public void ExecutionContext_NotCachedInSocketAsyncEventArgs() GC.WaitForPendingFinalizers(); } - Assert.True(ecDropped.Wait(TestSettings.PassingTestTimeout )); + Assert.True(ecDropped.Wait(TestSettings.PassingTestTimeout)); } } } diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs index 7ce36f751a1a06..29c24352c1a76c 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendPacketsAsync.cs @@ -208,7 +208,7 @@ public void BufferZeroCountThenNormal_ZeroCountIgnored(BufferType bufferType) args.SendPacketsElements = new SendPacketsElement[] { e1.Element }; if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -221,7 +221,7 @@ public void BufferZeroCountThenNormal_ZeroCountIgnored(BufferType bufferType) args.SendPacketsElements = new SendPacketsElement[] { e2.Element }; if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); } Assert.Equal(SocketError.Success, args.SocketError); @@ -381,13 +381,13 @@ public void SendPacketsElement_FileStreamIsReleasedOnError() if (r1) { - Assert.True(completed1.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); + Assert.True(completed1.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); } Assert.Equal(SocketError.Success, args1.SocketError); if (r2) { - Assert.True(completed2.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); + Assert.True(completed2.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); } Assert.Equal(SocketError.InvalidArgument, args2.SocketError); @@ -639,7 +639,7 @@ private void SendPackets(SendPacketsElement element, TransmitFileOptions flags, if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); } Assert.Equal(SocketError.Success, args.SocketError); Assert.Equal(bytesExpected, args.BytesTransferred); @@ -690,7 +690,7 @@ private void SendPackets(SendPacketsElement[] elements, SocketError expectedResu if (sock.SendPacketsAsync(args)) { - Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout ), "Timed out"); + Assert.True(completed.WaitOne(TestSettings.PassingTestTimeout), "Timed out"); } Assert.Equal(expectedResult, args.SocketError); Assert.Equal(bytesExpected, args.BytesTransferred); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs index a05ccde94c7ba7..4d43977fa2b3cf 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs @@ -953,7 +953,7 @@ await RetryHelper.ExecuteAsync(async () => Task disposeTask = Task.Run(() => socket.Dispose()); await Task.WhenAny(disposeTask, receiveTask) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); await disposeTask; SocketError? localSocketError = null; @@ -1030,7 +1030,7 @@ await RetryHelper.ExecuteAsync(async () => while (true) { SendAsync(socket1, buffer) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )) + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)) .GetAwaiter().GetResult(); } }); @@ -1042,16 +1042,16 @@ await RetryHelper.ExecuteAsync(async () => Task disposeTask = Task.Run(() => socket1.Dispose()); await Task.WhenAny(disposeTask, socketOperation) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); await disposeTask - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); SocketError? localSocketError = null; bool disposedException = false; try { await socketOperation - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); } catch (SocketException se) { @@ -1087,7 +1087,7 @@ await socketOperation try { int received = await ReceiveAsync(socket2, receiveBuffer) - .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); + .WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); if (received == 0) { break; diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs index d4772440196bdd..0a28ab0a52ee2b 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceiveMisc.cs @@ -250,7 +250,7 @@ public async Task Socket_ReceiveFlags_Success() args.SocketFlags = SocketFlags.Peek; if (receiver.ReceiveAsync(args)) { - await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); + await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); } Assert.Equal(SocketFlags.None, args.SocketFlags); Assert.Equal(1, receiveBuffer[0]); @@ -262,7 +262,7 @@ public async Task Socket_ReceiveFlags_Success() args.SocketFlags = SocketFlags.None; if (receiver.ReceiveAsync(args)) { - await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); + await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); } Assert.Equal(SocketFlags.None, args.SocketFlags); Assert.Equal(1, receiveBuffer[0]); @@ -274,7 +274,7 @@ public async Task Socket_ReceiveFlags_Success() args.SetBuffer(receiveBuffer, 0, 100); if (receiver.ReceiveAsync(args)) { - await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout )); + await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(TestSettings.PassingTestTimeout)); } Assert.Equal(SocketFlags.Truncated, args.SocketFlags); Assert.Equal(2, receiveBuffer[0]); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs index a64e3443e386ac..2c0ec09e6a6cf5 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs @@ -577,7 +577,7 @@ public void AcceptAsync_WithReceiveBuffer_Success() client.Shutdown(SocketShutdown.Both); } - Assert.True(accepted.WaitOne(TestSettings.PassingTestTimeout ), "Test completed in allotted time"); + Assert.True(accepted.WaitOne(TestSettings.PassingTestTimeout), "Test completed in allotted time"); Assert.Equal(SocketError.Success, acceptArgs.SocketError); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs index c84bb5565f6670..66f69e1ce70da4 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/UdpClientTest.cs @@ -370,7 +370,7 @@ public void BeginSend_AsyncOperationCompletes_Success() _waitHandle.Reset(); udpClient.BeginSend(sendBytes, sendBytes.Length, remoteServer, new AsyncCallback(AsyncCompleted), udpClient); - Assert.True(_waitHandle.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(_waitHandle.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); } } From b34261307b4a62afcb0aaf15170dde46788e8806 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 1 Sep 2021 15:27:27 +0200 Subject: [PATCH 6/7] whitespaces --- src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs | 2 +- .../tests/FunctionalTests/CreateSocketTests.cs | 2 +- .../System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs b/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs index 5d966928a0ad00..164b4b8632a43b 100644 --- a/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs +++ b/src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs @@ -12,6 +12,6 @@ public static class TestSettings public const int PassingTestLongTimeout = 30_000; public const int FailingTestTimeout = 100; - public static Task WhenAllOrAnyFailedWithTimeout(params Task[] tasks) => tasks.WhenAllOrAnyFailed(PassingTestTimeout ); + public static Task WhenAllOrAnyFailedWithTimeout(params Task[] tasks) => tasks.WhenAllOrAnyFailed(PassingTestTimeout); } } diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs index 1061bdf090945b..552c77e9044216 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs @@ -611,7 +611,7 @@ public unsafe void Ctor_SafeHandle_UnknownSocket_Success() netlink.Send(new ReadOnlySpan(Unsafe.AsPointer(ref req), sizeof(nl_request))); - Assert.True(netlink.Poll(TestSettings.PassingTestTimeout , SelectMode.SelectRead)); + Assert.True(netlink.Poll(TestSettings.PassingTestTimeout, SelectMode.SelectRead)); byte[] response = new byte[4000]; int readBytes = netlink.Receive(response); diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs index 5b2ea19d3a93c9..f23a1e835b7be3 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs @@ -244,7 +244,7 @@ public void Socket_ConnectAsyncDnsEndPoint_SetSocketProperties_Success(SocketImp bool willRaiseEvent = sock.ConnectAsync(args); if (willRaiseEvent) { - Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout ), "Timed out while waiting for connection"); + Assert.True(complete.WaitOne(TestSettings.PassingTestTimeout), "Timed out while waiting for connection"); complete.Dispose(); // only dispose on success as we know we're done with the instance } From 37969d477ed2ac5684888d43a04fc659399ba2b5 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 1 Sep 2021 15:28:50 +0200 Subject: [PATCH 7/7] whitespaces --- .../Common/tests/System/Net/Sockets/SocketTestServerAsync.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs b/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs index e26e9fa84bef5d..e42d4b55cd810f 100644 --- a/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs +++ b/src/libraries/Common/tests/System/Net/Sockets/SocketTestServerAsync.cs @@ -136,7 +136,7 @@ private void StartAccept(SocketAsyncEventArgs acceptEventArg) } _log.WriteLine(this.GetHashCode() + " StartAccept(_numConnectedSockets={0})", _numConnectedSockets); - if (!_maxNumberAcceptedClientsSemaphore.WaitOne(TestSettings.PassingTestTimeout )) + if (!_maxNumberAcceptedClientsSemaphore.WaitOne(TestSettings.PassingTestTimeout)) { throw new TimeoutException("Timeout waiting for client connection."); }