From: Marcos Henrich Date: Mon, 27 Jun 2016 08:50:48 +0000 (+0100) Subject: [System] Test Unhandled Ex on ConnectAsync X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=a05bc5465aa463f4f702c26c22f0312a376b337c;p=mono.git [System] Test Unhandled Ex on ConnectAsync Covers #41616 Our console runner is currently swallowing this test unhandled exceptions. To make it test show the failure I had to set legacyUnhandledExceptionPolicy to 0 in mcs/class/lib/net_4_x/nunit-console.exe.config Then running we can observe the crash by running: make -C mcs/class/System check TESTNAME=System.Net.Sockets.SocketTest.ConnectAsyncUnhandledEx Other tests appear to crash with legacyUEP set to 0, while the runner shows no errors. --- diff --git a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs index 2b12d7019bf..f4586a253f8 100755 --- a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs +++ b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs @@ -15,6 +15,7 @@ using System.Collections; using System.Threading; using System.Reflection; using System.Text.RegularExpressions; +using System.Threading.Tasks; using System.Net; using System.Net.Sockets; using NUnit.Framework; @@ -4345,6 +4346,23 @@ namespace MonoTests.System.Net.Sockets socket.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 19); } } + + [Test] // Covers 41616 + public void ConnectAsyncUnhandledEx () + { + var mre = new ManualResetEvent (false); + + var endPoint = new IPEndPoint(0,0); + var socket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Unspecified); + + var socketArgs = new SocketAsyncEventArgs(); + socketArgs.RemoteEndPoint = endPoint; + socketArgs.Completed += (sender, e) => mre.Set (); + + socket.ConnectAsync (socketArgs); + + Assert.IsTrue (mre.WaitOne (1000), "ConnectedAsync timeout"); + } } }