diff options
-rw-r--r-- | src/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs | 19 | ||||
-rw-r--r-- | src/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj | 6 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs b/src/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs index fba1acd298..8c0b57c04c 100644 --- a/src/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs +++ b/src/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs @@ -2707,7 +2707,7 @@ namespace System.Net.Sockets.Tests private IPAddress _connectTo; private Socket _serverSocket; - public SocketUdpClient(ITestOutputHelper output, Socket serverSocket, IPAddress connectTo, int port, bool redundant = true) + public SocketUdpClient(ITestOutputHelper output, Socket serverSocket, IPAddress connectTo, int port, bool redundant = true, bool sendNow = true) { _output = output; @@ -2715,14 +2715,18 @@ namespace System.Net.Sockets.Tests _port = port; _serverSocket = serverSocket; - Task.Run(() => ClientSend(null, redundant)); + if (sendNow) + { + Task.Run(() => ClientSend(redundant)); + } } - private void ClientSend(object state, bool redundant) + public void ClientSend(bool redundant = true, int timeout = 3) { try { Socket socket = new Socket(_connectTo.AddressFamily, SocketType.Dgram, ProtocolType.Udp); + socket.SendTimeout = timeout * 1000; for (int i = 0; i < (redundant ? TestSettings.UDPRedundancy : 1); i++) { @@ -2733,8 +2737,9 @@ namespace System.Net.Sockets.Tests socket.SendToAsync(e); } } - catch (SocketException) + catch (SocketException e) { + _output.WriteLine("Send to {0} {1} failed: {2}", _connectTo, _port, e.ToString()); _serverSocket.Dispose(); // Cancels the test } } @@ -2755,10 +2760,12 @@ namespace System.Net.Sockets.Tests { using (Socket serverSocket = new Socket(SocketType.Dgram, ProtocolType.Udp)) { - serverSocket.ReceiveTimeout = 500; + serverSocket.ReceiveTimeout = 1000; int port = serverSocket.BindToAnonymousPort(listenOn); - SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port); + SocketUdpClient client = new SocketUdpClient(_log, serverSocket, connectTo, port, sendNow: false); + + client.ClientSend(); EndPoint receivedFrom = new IPEndPoint(connectTo, port); int received = serverSocket.ReceiveFrom(new byte[1], ref receivedFrom); diff --git a/src/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj b/src/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj index 088fd2ba4d..f3feef4441 100644 --- a/src/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj +++ b/src/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj @@ -3,6 +3,7 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <ProjectGuid>{8CBA022C-635F-4C8D-9D29-CD8AAC68C8E6}</ProjectGuid> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" /> @@ -97,6 +98,9 @@ <Compile Include="$(CommonTestPath)\System\Diagnostics\Tracing\TestEventListener.cs"> <Link>Common\System\Diagnostics\Tracing\TestEventListener.cs</Link> </Compile> + <Compile Include="$(CommonPath)\System\Net\Logging\NetEventSource.Common.cs"> + <Link>Common\System\Net\Logging\NetEventSource.Common.cs</Link> + </Compile> </ItemGroup> <ItemGroup> <ProjectReference Include="$(CommonTestPath)\System\Diagnostics\RemoteExecutorConsoleApp\RemoteExecutorConsoleApp.csproj"> @@ -108,4 +112,4 @@ <EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" /> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> -</Project>
\ No newline at end of file +</Project> |