Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -18,12 +18,14 @@ using Microsoft.CSharp;
using NUnit.Framework;
using System.Text;
using System.Linq;
using MonoTests.Helpers;
namespace MonoTests.Microsoft.CSharp
{
[TestFixture]
public class CSharpCodeProviderTest
{
private TempDirectory _tempDirectory;
private string _tempDir;
private CodeDomProvider _codeProvider;
@@ -38,13 +40,14 @@ namespace MonoTests.Microsoft.CSharp
public void SetUp ()
{
_codeProvider = new CSharpCodeProvider ();
_tempDir = CreateTempDirectory ();
_tempDirectory = new TempDirectory ();
_tempDir = _tempDirectory.Path;
}
[TearDown]
public void TearDown ()
{
RemoveDirectory (_tempDir);
_tempDirectory.Dispose ();
}
[Test]
@@ -430,8 +433,6 @@ namespace MonoTests.Microsoft.CSharp
// verify we don't cleanup files in temp directory too agressively
string[] tempFiles = Directory.GetFiles (_tempDir);
Assert.AreEqual (2, tempFiles.Length, "#C1");
Assert.AreEqual (tempFile, tempFiles[0], "#C2");
Assert.AreEqual (outputAssembly, tempFiles [1], "#C3");
}
[Test]
@@ -601,37 +602,6 @@ namespace MonoTests.Microsoft.CSharp
Assert.IsTrue (results.Output.Cast<string>().ToArray ()[1].Contains ("Trigger Some Warning"));
}
private static string CreateTempDirectory ()
{
// create a uniquely named zero-byte file
string tempFile = Path.GetTempFileName ();
// remove the temporary file
File.Delete (tempFile);
// create a directory named after the unique temporary file
Directory.CreateDirectory (tempFile);
// return the path to the temporary directory
return tempFile;
}
private static void RemoveDirectory (string path)
{
try {
if (Directory.Exists (path)) {
string[] directoryNames = Directory.GetDirectories (path);
foreach (string directoryName in directoryNames) {
RemoveDirectory (directoryName);
}
string[] fileNames = Directory.GetFiles (path);
foreach (string fileName in fileNames) {
File.Delete (fileName);
}
Directory.Delete (path, true);
}
} catch (Exception ex) {
throw new AssertionException ("Unable to cleanup '" + path + "'.", ex);
}
}
private static void AssertCompileResults (CompilerResults results, bool allowWarnings)
{
foreach (CompilerError compilerError in results.Errors) {

View File

@@ -37,12 +37,15 @@ using System.Reflection;
using System.Security;
using System.Security.Permissions;
using MonoTests.Helpers;
namespace MonoCasTests.System.CodeDom.Compiler {
[TestFixture]
[Category ("CAS")]
public class TempFileCollectionCas {
private TempDirectory _temp;
private string temp;
private string[] array;
@@ -50,7 +53,8 @@ namespace MonoCasTests.System.CodeDom.Compiler {
public void FixtureSetUp ()
{
// at full trust
temp = Path.GetTempPath ();
_temp = new TempDirectory ();
temp = _temp.Path;
array = new string[1];
}

View File

@@ -16,7 +16,7 @@ using System.ComponentModel.Design;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
#if !MOBILE && !MONOMAC && !XAMMAC_4_5
#if !MOBILE && !XAMMAC_4_5
using System.Drawing.Design;
#endif
using NUnit.Framework;
@@ -1053,7 +1053,7 @@ namespace MonoTests.System.ComponentModel
return attr;
return null;
}
#if !MOBILE && !MONOMAC && !XAMMAC_4_5
#if !MOBILE && !XAMMAC_4_5
class GetEditor_test
{
[Editor (typeof (UIEditor), typeof (UITypeEditor))]

View File

@@ -16,7 +16,7 @@ namespace MonoTests.System.ComponentModel
[TestFixture]
public class ToolboxItemAttributeTests
{
#if !MOBILE && !MONOMAC && !XAMMAC_4_5
#if !MOBILE && !XAMMAC_4_5
[Test]
public void DefaultType ()
{

View File

@@ -42,6 +42,8 @@ using System.Collections.Specialized;
using NUnit.Framework;
using CategoryAttribute = NUnit.Framework.CategoryAttribute;
using MonoTests.Helpers;
namespace MonoTests.System.Configuration {
class ProviderPoker : LocalFileSettingsProvider {
public override void Initialize (string name,
@@ -164,14 +166,15 @@ namespace MonoTests.System.Configuration {
[TestFixture]
public class ApplicationSettingsBaseTest
{
TempDirectory _tempDir;
string tempDir;
[TestFixtureSetUp]
public void FixtureSetup ()
{
// Use random temp directory to store settings files of tests.
tempDir = Path.Combine (Path.GetTempPath (), Path.GetRandomFileName ());
Directory.CreateDirectory (tempDir);
_tempDir = new TempDirectory ();
tempDir = _tempDir.Path;
var localAppData = Path.Combine (tempDir, "LocalAppData");
Directory.CreateDirectory (localAppData);
var appData = Path.Combine (tempDir, "AppData");
@@ -186,7 +189,7 @@ namespace MonoTests.System.Configuration {
{
Environment.SetEnvironmentVariable ("XDG_DATA_HOME", null);
Environment.SetEnvironmentVariable ("XDG_CONFIG_HOME", null);
Directory.Delete (tempDir, true);
_tempDir.Dispose ();
}
[Test]

View File

@@ -34,24 +34,25 @@ using System.Configuration;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.Configuration {
[TestFixture]
public class ConfigXmlDocumentTest {
private TempDirectory _tempFolder;
private string tempFolder;
[SetUp]
public void SetUp ()
{
tempFolder = Path.Combine (Path.GetTempPath (), this.GetType ().FullName);
if (!Directory.Exists (tempFolder))
Directory.CreateDirectory (tempFolder);
_tempFolder = new TempDirectory ();
tempFolder = _tempFolder.Path;
}
[TearDown]
public void TearDown ()
{
if (Directory.Exists (tempFolder))
Directory.Delete (tempFolder, true);
_tempFolder.Dispose ();
}
[Test]

View File

@@ -33,27 +33,27 @@ using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.Configuration
{
[TestFixture]
public class ConfigurationExceptionTest
{
private TempDirectory temp;
private string foldername;
[SetUp]
public void SetUp ()
{
foldername = Path.Combine (Path.GetTempPath (),
this.GetType ().FullName);
if (!Directory.Exists (foldername))
Directory.CreateDirectory (foldername);
temp = new TempDirectory ();
foldername = temp.Path;
}
[TearDown]
public void TearDown ()
{
if (Directory.Exists (foldername))
Directory.Delete (foldername, true);
temp.Dispose ();
}
[Test] // ctor ()

View File

@@ -1 +1 @@
3b03dd8aaab8765848719d0193ce3b2db80cbf51
f267064ee781eb165c8c29287dd6727d299f854c

View File

@@ -1 +1 @@
815bbb85c45d0c4fe36d4a49819a0384e4816a60
3ef13ae74aa49716d04d5617b2ba227b69e584df

View File

@@ -11,7 +11,7 @@
// (C) 2003 Martin Willemoes Hansen
//
#if !MOBILE && !MONOMAC
#if !MOBILE && !XAMMAC_4_5
using NUnit.Framework;
using System;

View File

@@ -12,6 +12,8 @@ using NUnit.Framework;
using System;
using System.IO;
using MonoTests.Helpers;
namespace MonoTests.System.IO
{
[TestFixture]
@@ -54,7 +56,9 @@ namespace MonoTests.System.IO
[ExpectedException (typeof (ArgumentNullException))]
public void CheckCtor4 ()
{
FileSystemWatcher fw = new FileSystemWatcher (Path.GetTempPath (), null);
using (var tmp = new TempDirectory ()) {
FileSystemWatcher fw = new FileSystemWatcher (tmp.Path, null);
}
}
[Test]
@@ -62,8 +66,12 @@ namespace MonoTests.System.IO
// [ExpectedException (typeof (ArgumentException))]
public void CheckCtor5 ()
{
FileSystemWatcher fw = new FileSystemWatcher (Path.GetTempPath (), "invalidpath|");
fw = new FileSystemWatcher (Path.GetTempPath (), "*");
using (var tmp1 = new TempDirectory ()) {
using (var tmp2 = new TempDirectory ()) {
FileSystemWatcher fw = new FileSystemWatcher (tmp1.Path, "invalidpath|");
fw = new FileSystemWatcher (tmp2.Path, "*");
}
}
}
[Test]
@@ -71,8 +79,10 @@ namespace MonoTests.System.IO
[ExpectedException (typeof (ArgumentException))]
public void CheckInvalidPath ()
{
FileSystemWatcher fw = new FileSystemWatcher (Path.GetTempPath (), "invalidpath|");
fw.Path = "invalidpath|";
using (var tmp = new TempDirectory ()) {
FileSystemWatcher fw = new FileSystemWatcher (tmp.Path, "invalidpath|");
fw.Path = "invalidpath|";
}
}
[Test]
@@ -80,8 +90,10 @@ namespace MonoTests.System.IO
[ExpectedException (typeof (ArgumentException))]
public void CheckPathWildcard ()
{
FileSystemWatcher fw = new FileSystemWatcher (Path.GetTempPath (), "*");
fw.Path = "*";
using (var tmp = new TempDirectory ()) {
FileSystemWatcher fw = new FileSystemWatcher (tmp.Path, "*");
fw.Path = "*";
}
}
}
}

View File

@@ -29,7 +29,7 @@
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
#if !MOBILE && !MONOMAC
#if !MOBILE && !XAMMAC_4_5
using System;
using System.Configuration;

View File

@@ -7,7 +7,7 @@
// (C) 2005 Novell
//
#if !MOBILE && !MONOMAC
#if !MOBILE && !XAMMAC_4_5
using System.Net.Configuration;

View File

@@ -29,7 +29,7 @@
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
#if !MOBILE && !MONOMAC
#if !MOBILE && !XAMMAC_4_5
using System;
using System.Configuration;

View File

@@ -13,6 +13,8 @@ using System.Net.Mail;
using System.Net.Mime;
using System.Threading;
using MonoTests.Helpers;
namespace MonoTests.System.Net.Mail
{
[TestFixture]
@@ -20,23 +22,21 @@ namespace MonoTests.System.Net.Mail
{
SmtpClient _smtp;
SmtpClient smtp { get { return _smtp ?? (_smtp = new SmtpClient ()); } }
TempDirectory _tempFolder;
string tempFolder;
[SetUp]
public void GetReady ()
{
tempFolder = Path.Combine (Path.GetTempPath (), this.GetType ().FullName);
if (Directory.Exists (tempFolder))
Directory.Delete (tempFolder, true);
Directory.CreateDirectory (tempFolder);
_tempFolder = new TempDirectory ();
tempFolder = _tempFolder.Path;
}
[TearDown]
public void TearDown ()
{
_smtp = null;
if (Directory.Exists (tempFolder))
Directory.Delete (tempFolder, true);
_tempFolder.Dispose ();
}
[Test]

View File

@@ -71,11 +71,9 @@ public class SslStreamTest {
void AuthenticateClientAndServer (bool server, bool client)
{
IPEndPoint endPoint = new IPEndPoint (IPAddress.Parse ("127.0.0.1"), NetworkHelpers.FindFreePort ());
ClientServerState state = new ClientServerState ();
state.Client = new TcpClient ();
state.Listener = new TcpListener (endPoint);
state.Listener.Start ();
state.Listener = NetworkHelpers.CreateAndStartTcpListener (IPAddress.Loopback, out IPEndPoint endPoint);
state.ServerAuthenticated = new AutoResetEvent (false);
state.ClientAuthenticated = new AutoResetEvent (false);
state.ServerIOException = !server;

View File

@@ -1 +1 @@
d1209d2ba5d747700e869242a8d4de875920eb4f
14976edb39c9c0643ba059f92078e0e93a0eb567

View File

@@ -38,8 +38,7 @@ namespace MonoTests.System.Net.Sockets
Socket lSock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
var port = NetworkHelpers.FindFreePort ();
lSock.Bind(new IPEndPoint(IPAddress.Any, port));
lSock.Bind(IPAddress.Any, out int port);
lSock.Listen(-1);
@@ -84,9 +83,10 @@ namespace MonoTests.System.Net.Sockets
#endif
public void CloseTest ()
{
var port = NetworkHelpers.FindFreePort ();
IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, port);
using (SocketResponder sr = new SocketResponder (localEP, s => CloseRequestHandler (s))) {
var port = 0;
IPEndPoint localEP;
using (SocketResponder sr = new SocketResponder (out localEP, s => CloseRequestHandler (s))) {
port = localEP.Port;
TcpClient tcpClient = new TcpClient (IPAddress.Loopback.ToString (), port);
NetworkStream ns = tcpClient.GetStream ();
Assert.IsNotNull (ns, "#A1");

View File

@@ -28,10 +28,8 @@ namespace MonoTests.System.Net.Sockets
#endif
public void TcpListener ()
{
var port = NetworkHelpers.FindFreePort ();
// listen with a new listener (IPv4 is the default)
TcpListener inListener = new TcpListener (port);
inListener.Start();
TcpListener inListener = NetworkHelpers.CreateAndStartTcpListener (out int port);
// connect to it from a new socket
@@ -130,7 +128,7 @@ namespace MonoTests.System.Net.Sockets
class MyListener : TcpListener
{
public MyListener ()
: base (IPAddress.Loopback, NetworkHelpers.FindFreePort ())
: base (IPAddress.Loopback, 0)
{
}
@@ -204,8 +202,7 @@ namespace MonoTests.System.Net.Sockets
#endif
public void StartListenMoreThan5 ()
{
var port = NetworkHelpers.FindFreePort ();
TcpListener listen = new TcpListener (IPAddress.Loopback, port);
TcpListener listen = new TcpListener (IPAddress.Loopback, 0);
listen.Start (6);
listen.Stop ();
@@ -229,10 +226,7 @@ namespace MonoTests.System.Net.Sockets
#endif
public void EndAcceptTcpClient ()
{
var port = NetworkHelpers.FindFreePort ();
var listenerSocket = new TcpListener (IPAddress.Any, port);
listenerSocket.Start ();
var listenerSocket = NetworkHelpers.CreateAndStartTcpListener (IPAddress.Any, out int port);
listenerSocket.BeginAcceptTcpClient (new AsyncCallback (l => {
listenerSocket.EndAcceptTcpClient (l);
}), null);

View File

@@ -885,7 +885,7 @@ namespace MonoTests.System.Net.Sockets {
#endif
public void CloseInReceive ()
{
UdpClient client = new UdpClient (NetworkHelpers.FindFreePort ());
UdpClient client = new UdpClient (0);
ManualResetEvent ready = new ManualResetEvent (false);
bool got_exc = false;
@@ -1024,8 +1024,8 @@ namespace MonoTests.System.Net.Sockets {
#endif
public void BeginReceive ()
{
var port = NetworkHelpers.FindFreePort ();
UdpClient client = new UdpClient (port);
UdpClient client = new UdpClient (0);
var port = ((IPEndPoint) client.Client.LocalEndPoint).Port;
BRCalledBack.Reset ();
@@ -1053,8 +1053,8 @@ namespace MonoTests.System.Net.Sockets {
#endif
public void Available ()
{
var port = NetworkHelpers.FindFreePort ();
using (UdpClient client = new UdpClient (port)) {
using (UdpClient client = new UdpClient (0)) {
var port = ((IPEndPoint) client.Client.LocalEndPoint).Port;
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, port);
byte[] bytes = new byte[] {10, 11, 12, 13};
@@ -1149,10 +1149,9 @@ namespace MonoTests.System.Net.Sockets {
if (!Socket.OSSupportsIPv6)
Assert.Ignore ("IPv6 not enabled.");
int port1 = NetworkHelpers.FindFreePort ();
int port2 = NetworkHelpers.FindFreePort ();
using(var udpClient = new UdpClient (port1, AddressFamily.InterNetworkV6))
using(var udpClient2 = new UdpClient (port2, AddressFamily.InterNetworkV6))
using(var udpClient = new UdpClient (0, AddressFamily.InterNetworkV6)) {
var port1 = ((IPEndPoint) udpClient.Client.LocalEndPoint).Port;
using(var udpClient2 = new UdpClient (0, AddressFamily.InterNetworkV6))
{
var dataSent = new byte [] {1,2,3};
udpClient2.SendAsync (dataSent, dataSent.Length, "::1", port1);
@@ -1162,6 +1161,7 @@ namespace MonoTests.System.Net.Sockets {
Assert.AreEqual (dataSent.Length, data.Length);
}
}
}
/* No test for Ttl default as it is platform dependent */

Some files were not shown because too many files have changed in this diff Show More