Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
undo renaming PassingTestTimeout
  • Loading branch information
antonfirsov committed Sep 1, 2021
commit 4daff4b001b4e529126d9f65832f6786ec07967a
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/Common/tests/System/Net/Sockets/TestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ await Task.Run(async () =>
}
}
}
}).WaitAsync(TestSettings.PassingTestShortTimeout);
}).WaitAsync(TestSettings.PassingTestTimeout );
}

[DllImport("libc")]
Expand Down Expand Up @@ -611,7 +611,7 @@ public unsafe void Ctor_SafeHandle_UnknownSocket_Success()

netlink.Send(new ReadOnlySpan<byte>(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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<WeakReference> handles = await CreateHandlesAsync(clientAsync).WaitAsync(timeout);
await RetryHelper.ExecuteAsync(() => Task.Run(() =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,15 @@ 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++)
{
GC.Collect();
GC.WaitForPendingFinalizers();
}

Assert.True(ecDropped.Wait(TestSettings.PassingTestShortTimeout));
Assert.True(ecDropped.Wait(TestSettings.PassingTestTimeout ));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading