Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -20,7 +20,12 @@ namespace MonoTests.System.Net.Sockets
{
[Test]
// See bug #371923
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException(typeof(IOException))]
#endif
public void NetworkStreamConnection ()
{
IPEndPoint ipe = new IPEndPoint(Dns.GetHostEntry ("www.google.com").AddressList [0], 80);
@@ -30,6 +35,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ReadTimeout ()
{
Socket sock = new Socket (AddressFamily.InterNetwork,

View File

@@ -1,3 +1,4 @@
using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
@@ -9,6 +10,9 @@ namespace MonoTests.System.Net.Sockets
public class SocketAcceptAsyncTest
{
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void AcceptAsyncShouldUseAcceptSocketFromEventArgs()
{
var readyEvent = new ManualResetEvent(false);
@@ -18,27 +22,40 @@ namespace MonoTests.System.Net.Sockets
var serverSocket = new Socket(
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Socket acceptedSocket = null;
Exception ex = null;
ThreadPool.QueueUserWorkItem(_ =>
{
listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
listenSocket.Listen(1);
SocketAsyncEventArgs asyncEventArgs;
try {
listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
listenSocket.Listen(1);
var asyncEventArgs = new SocketAsyncEventArgs {AcceptSocket = serverSocket};
asyncEventArgs.Completed += (s, e) =>
{
acceptedSocket = e.AcceptSocket;
mainEvent.Set();
};
asyncEventArgs = new SocketAsyncEventArgs {AcceptSocket = serverSocket};
asyncEventArgs.Completed += (s, e) =>
{
acceptedSocket = e.AcceptSocket;
mainEvent.Set();
};
readyEvent.Set();
if (listenSocket.AcceptAsync(asyncEventArgs))
} catch (Exception e) {
ex = e;
return;
acceptedSocket = asyncEventArgs.AcceptSocket;
mainEvent.Set();
} finally {
readyEvent.Set();
}
try {
if (listenSocket.AcceptAsync(asyncEventArgs))
return;
acceptedSocket = asyncEventArgs.AcceptSocket;
mainEvent.Set();
} catch (Exception e) {
ex = e;
}
});
Assert.IsTrue(readyEvent.WaitOne(1500));
if (ex != null)
throw ex;
var clientSocket = new Socket(
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

View File

@@ -16,8 +16,7 @@ namespace MonoTests.System.Net.Sockets
ManualResetEvent mainEvent;
Exception error;
[TestFixtureSetUp]
public void SetUp ()
void SetUp ()
{
readyEvent = new ManualResetEvent (false);
mainEvent = new ManualResetEvent (false);
@@ -25,6 +24,9 @@ namespace MonoTests.System.Net.Sockets
ThreadPool.QueueUserWorkItem (_ => DoWork ());
readyEvent.WaitOne ();
if (error != null)
throw error;
clientSocket = new Socket (
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
clientSocket.Connect (serverSocket.LocalEndPoint);
@@ -42,18 +44,22 @@ namespace MonoTests.System.Net.Sockets
void DoWork ()
{
serverSocket = new Socket (
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
serverSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
serverSocket.Listen (1);
try {
serverSocket = new Socket (
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
serverSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
serverSocket.Listen (1);
var async = new SocketAsyncEventArgs ();
async.Completed += (s,e) => OnAccepted (e);
var async = new SocketAsyncEventArgs ();
async.Completed += (s,e) => OnAccepted (e);
readyEvent.Set ();
if (!serverSocket.AcceptAsync (async))
OnAccepted (async);
if (!serverSocket.AcceptAsync (async))
OnAccepted (async);
} catch (Exception e) {
error = e;
} finally {
readyEvent.Set ();
}
}
void OnAccepted (SocketAsyncEventArgs e)
@@ -92,8 +98,12 @@ namespace MonoTests.System.Net.Sockets
[Test]
[Category("Test")]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void SendAsync ()
{
SetUp ();
var buffer = new byte [] { 0x12, 0x34, 0x56, 0x78 };
var m = new ManualResetEvent (false);
var e = new SocketAsyncEventArgs ();

View File

@@ -1 +1 @@
7d024238d081e85b535a28cb160e824d94975df7
14ec2700869c289ee1159851c5402e07138b70a5

View File

@@ -29,6 +29,9 @@ namespace MonoTests.System.Net.Sockets
/// (from System.Net.Sockets)
/// </summary>
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TcpClient()
{
// set up a listening Socket
@@ -76,6 +79,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test] // bug #81105
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void CloseTest ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -139,7 +145,11 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof(ArgumentNullException))]
#endif
public void ConnectMultiNull ()
{
TcpClient client = new TcpClient ();
@@ -149,6 +159,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ConnectMultiAny ()
{
TcpClient client = new TcpClient ();
@@ -167,6 +180,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ConnectMultiRefused ()
{
TcpClient client = new TcpClient ();

View File

@@ -23,6 +23,9 @@ namespace MonoTests.System.Net.Sockets
public class TcpListenerTest
{
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TcpListener ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -74,6 +77,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void CtorInt1 ()
{
int nex = 0;
@@ -86,21 +92,33 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (ArgumentNullException))]
#endif
public void CtorIPEndPoint ()
{
new TcpListener (null);
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (ArgumentNullException))]
#endif
public void CtorIPAddressInt1 ()
{
new TcpListener (null, 100000);
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (ArgumentOutOfRangeException))]
#endif
public void CtorIPAddressInt2 ()
{
new TcpListener (IPAddress.Any, 100000);
@@ -124,6 +142,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void PreStartStatus ()
{
MyListener listener = new MyListener ();
@@ -151,6 +172,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void PostStartStatus ()
{
MyListener listener = new MyListener ();
@@ -172,6 +196,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void StartListenMoreThan5 ()
{
var port = NetworkHelpers.FindFreePort ();

View File

@@ -17,6 +17,9 @@ namespace MonoTests.System.Net.Sockets {
[TestFixture]
public class UdpClientTest {
[Test] // .ctor ()
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor1 ()
{
MyUdpClient client;
@@ -42,6 +45,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor2 ()
{
MyUdpClient client;
@@ -87,6 +93,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor2_Family_Invalid ()
{
try {
@@ -113,6 +122,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor3 ()
{
Socket s;
@@ -162,6 +174,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor3_Port_OutOfRange ()
{
try {
@@ -188,6 +203,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (IPEndPoint)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor4 ()
{
Socket s;
@@ -220,6 +238,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (IPEndPoint)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor4_LocalEP_Null ()
{
try {
@@ -234,6 +255,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32, AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor5 ()
{
Socket s;
@@ -287,6 +311,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32, AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor5_Family_Invalid ()
{
try {
@@ -317,6 +344,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32, AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor5_Port_OutOfRange ()
{
try {
@@ -343,6 +373,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (String, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor6 ()
{
Socket s;
@@ -393,6 +426,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (String, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor6_HostName_Null ()
{
try {
@@ -407,6 +443,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (String, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor6_Port_OutOfRange ()
{
try {
@@ -433,6 +472,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void UdpClientBroadcastTest ()
{
UdpClient client = new UdpClient ();
@@ -446,6 +488,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup1_IPv4 ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -456,6 +501,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup1_IPv6 ()
{
if (!Socket.OSSupportsIPv6)
@@ -469,6 +517,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup1_MulticastAddr_Null ()
{
using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -485,6 +536,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup1_Socket_Closed ()
{
IPAddress mcast_addr = null;
@@ -527,6 +581,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (In32, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup2_IPv4 ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -549,6 +606,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (In32, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup2_IPv6 ()
{
if (!Socket.OSSupportsIPv6)
@@ -562,6 +622,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (Int32, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup2_MulticastAddr_Null ()
{
using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -578,6 +641,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (Int32, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup2_Socket_Closed ()
{
if (!Socket.OSSupportsIPv6)
@@ -623,6 +689,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup3_IPv4 ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -637,6 +706,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup3_IPv6 ()
{
if (!Socket.OSSupportsIPv6)
@@ -654,6 +726,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup3_MulticastAddr_Null ()
{
using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -670,6 +745,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup3_Socket_Closed ()
{
IPAddress mcast_addr = null;
@@ -712,6 +790,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_IPv4 ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -723,6 +804,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_IPv6 ()
{
if (!Socket.OSSupportsIPv6)
@@ -749,6 +833,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_LocalAddress_Null ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -767,6 +854,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_MulticastAddr_Null ()
{
using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -783,6 +873,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_Socket_Closed ()
{
IPAddress mcast_addr = null;
@@ -827,6 +920,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void CloseInReceive ()
{
UdpClient client = null;
@@ -867,6 +963,9 @@ namespace MonoTests.System.Net.Sockets {
// Test for bug 324033
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroupWithLocal ()
{
UdpClient client = new UdpClient (9001);
@@ -881,7 +980,11 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof(ArgumentNullException))]
#endif
public void BeginSendNull ()
{
UdpClient client = new UdpClient ();
@@ -904,6 +1007,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void BeginSend ()
{
UdpClient client = new UdpClient ();
@@ -958,6 +1064,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void BeginReceive ()
{
UdpClient client = new UdpClient (1237);
@@ -983,6 +1092,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Available ()
{
using (UdpClient client = new UdpClient (1238)) {
@@ -1017,6 +1129,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void EnableBroadcastDefault ()
{
UdpClient client = new UdpClient ();
@@ -1056,6 +1171,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void MulticastLoopbackDefault ()
{
UdpClient client = new UdpClient ();
@@ -1066,6 +1184,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // #6057
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ReceiveIPv6 ()
{
if (!Socket.OSSupportsIPv6)