[System] Fix flaky AcceptBlockingStatus test that sometimes failed on OSX
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 4 Jan 2016 15:48:58 +0000 (16:48 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 4 Jan 2016 16:32:06 +0000 (17:32 +0100)
commitd3f0e7407674f29d13bed474191117941f50ff96
tree882f9a903609caabe525c56999a8c3286edf48e1
parenta203534b42028337b8256046e2929869c28c0ce0
[System] Fix flaky AcceptBlockingStatus test that sometimes failed on OSX

We were sometimes seeing the following failure on Jenkins on OSX:

```
Test Case Failures:
1) MonoTests.System.Net.Sockets.SocketTest.AcceptBlockingStatus : System.Net.Sockets.SocketException : Operation on non-blocking socket would block
at System.Net.Sockets.Socket.Accept () [0x00033] in /Users/builder/jenkins/workspace/test-mono-mainline/label/osx-i386/mcs/class/System/System.Net.Sockets/Socket.cs:896
at MonoTests.System.Net.Sockets.SocketTest.BlockingConnect (Boolean block) [0x0003e] in /Users/builder/jenkins/workspace/test-mono-mainline/label/osx-i386/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs:129
at MonoTests.System.Net.Sockets.SocketTest.AcceptBlockingStatus () [0x0001e] in /Users/builder/jenkins/workspace/test-mono-mainline/label/osx-i386/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs:147
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in /Users/builder/jenkins/workspace/test-mono-mainline/label/osx-i386/mcs/class/corlib/System.Reflection/MonoMethod.cs:295
```

In non-blocking mode accept() is specified to return this error when no client connection is available right now.
It looks like on OSX we don't immediately get that connection.

To fix this issue, we try to accept in a loop for 100ms and only fail when we don't get a connection in this time.
mcs/class/System/Test/System.Net.Sockets/SocketTest.cs