Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorJo Shields <joshield@microsoft.com>2021-05-04 12:23:26 +0300
committerGitHub <noreply@github.com>2021-05-04 12:23:26 +0300
commitbb4af41b62743cbdc5d751b91e95ea9352996c19 (patch)
tree24c0f1dbdc021ba4cb8d665e92e11bbb99ae0289 /mcs
parent90890344b2b2849860199823f14bc0958fe7ad8e (diff)
Azure Pipelines Windows CI (#20879)
* Disable EventLog tests on Windows if we're not running as admin * Disable a socket test that doesn't work on Win10 * Fix MetadataResolverTest on Windows in AzDO There's something running on localhost already that makes the test fail, use a different hostname instead. * Force ASCII encoding for console-output.cs * Use different way to compare output of test-console-output * Fix issue with symlink on PublishTestResults * Use Unicode encoding in Win32EventLog p/invokes, fixes eventlog tests on Win10 Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataResolverTest.cs6
-rw-r--r--mcs/class/System/System.Diagnostics/Win32EventLog.cs20
-rw-r--r--mcs/class/System/Test/System.Diagnostics/EventLogTest.cs69
-rwxr-xr-xmcs/class/System/Test/System.Net.Sockets/SocketTest.cs1
4 files changed, 69 insertions, 27 deletions
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataResolverTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataResolverTest.cs
index 348294ebded..47ae5b40209 100644
--- a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataResolverTest.cs
+++ b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataResolverTest.cs
@@ -245,7 +245,7 @@ namespace MonoTests.System.ServiceModel.Description
//TODO: Write test cases for the related overloads of Resolve
MetadataResolver.Resolve (
contracts,
- new EndpointAddress ("http://localhost"),
+ new EndpointAddress ("http://doesnotexist"),
new MetadataExchangeClient (new EndpointAddress (url)));
}
@@ -315,7 +315,7 @@ namespace MonoTests.System.ServiceModel.Description
List<ContractDescription> contracts = new List<ContractDescription> ();
contracts.Add (contract);
- MetadataResolver.Resolve (contracts, new EndpointAddress ("http://localhost"));
+ MetadataResolver.Resolve (contracts, new EndpointAddress ("http://doesnotexist"));
}
private void CheckIEchoServiceEndpoint (ServiceEndpointCollection endpoints)
@@ -347,7 +347,7 @@ namespace MonoTests.System.ServiceModel.Description
public void ResolveBadUri ()
{
MetadataResolver.Resolve (
- typeof (IEchoService), new EndpointAddress ("http://localhost"));
+ typeof (IEchoService), new EndpointAddress ("http://doesnotexist"));
}
[DataContract]
diff --git a/mcs/class/System/System.Diagnostics/Win32EventLog.cs b/mcs/class/System/System.Diagnostics/Win32EventLog.cs
index ac986545548..b5ca3ec090f 100644
--- a/mcs/class/System/System.Diagnostics/Win32EventLog.cs
+++ b/mcs/class/System/System.Diagnostics/Win32EventLog.cs
@@ -261,7 +261,7 @@ namespace System.Diagnostics
ReadEventLog (index, buffer, ref bytesRead, ref minBufferNeeded);
MemoryStream ms = new MemoryStream (buffer);
- BinaryReader br = new BinaryReader (ms);
+ BinaryReader br = new BinaryReader (ms, Encoding.Unicode);
// skip first 8 bytes
br.ReadBytes (8);
@@ -796,7 +796,7 @@ namespace System.Diagnostics
private class PInvoke
{
- [DllImport ("advapi32.dll", SetLastError=true)]
+ [DllImport ("advapi32.dll", CharSet = CharSet.Unicode, SetLastError=true)]
public static extern int ClearEventLog (IntPtr hEventLog, string lpBackupFileName);
[DllImport ("advapi32.dll", SetLastError=true)]
@@ -811,10 +811,10 @@ namespace System.Diagnostics
[DllImport ("kernel32", SetLastError=true)]
public static extern bool FreeLibrary (IntPtr hModule);
- [DllImport ("advapi32.dll", SetLastError=true)]
+ [DllImport ("advapi32.dll", CharSet = CharSet.Unicode, SetLastError=true)]
public static extern int GetNumberOfEventLogRecords (IntPtr hEventLog, ref int NumberOfRecords);
- [DllImport ("advapi32.dll", SetLastError=true)]
+ [DllImport ("advapi32.dll", CharSet = CharSet.Unicode, SetLastError=true)]
public static extern int GetOldestEventLogRecord (IntPtr hEventLog, ref int OldestRecord);
[DllImport ("kernel32", SetLastError=true)]
@@ -823,7 +823,7 @@ namespace System.Diagnostics
[DllImport ("kernel32", SetLastError=true)]
public static extern IntPtr LocalFree (IntPtr hMem);
- [DllImport ("advapi32.dll", SetLastError=true)]
+ [DllImport ("advapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "LookupAccountSidW", SetLastError=true)]
public static extern bool LookupAccountSid (
string lpSystemName,
[MarshalAs (UnmanagedType.LPArray)] byte [] Sid,
@@ -833,21 +833,21 @@ namespace System.Diagnostics
ref uint cchReferencedDomainName,
out SidNameUse peUse);
- [DllImport ("advapi32.dll", SetLastError = true)]
+ [DllImport ("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int NotifyChangeEventLog (IntPtr hEventLog, IntPtr hEvent);
- [DllImport ("advapi32.dll", SetLastError=true)]
+ [DllImport ("advapi32.dll", CharSet = CharSet.Unicode, SetLastError=true)]
public static extern IntPtr OpenEventLog (string machineName, string logName);
- [DllImport ("advapi32.dll", SetLastError=true)]
+ [DllImport ("advapi32.dll", CharSet = CharSet.Unicode, SetLastError=true)]
public static extern IntPtr RegisterEventSource (string machineName, string sourceName);
- [DllImport ("advapi32.dll", SetLastError=true)]
+ [DllImport ("advapi32.dll", CharSet = CharSet.Unicode, SetLastError=true)]
public static extern int ReportEvent (IntPtr hHandle, ushort wType,
ushort wCategory, uint dwEventID, IntPtr sid, ushort wNumStrings,
uint dwDataSize, string [] lpStrings, byte [] lpRawData);
- [DllImport ("advapi32.dll", SetLastError=true)]
+ [DllImport ("advapi32.dll", CharSet = CharSet.Unicode, SetLastError=true)]
public static extern int ReadEventLog (IntPtr hEventLog, ReadFlags dwReadFlags, int dwRecordOffset, byte [] buffer, int nNumberOfBytesToRead, ref int pnBytesRead, ref int pnMinNumberOfBytesNeeded);
public const int ERROR_INSUFFICIENT_BUFFER = 122;
diff --git a/mcs/class/System/Test/System.Diagnostics/EventLogTest.cs b/mcs/class/System/Test/System.Diagnostics/EventLogTest.cs
index f267064ee78..fcc32e1fca9 100644
--- a/mcs/class/System/Test/System.Diagnostics/EventLogTest.cs
+++ b/mcs/class/System/Test/System.Diagnostics/EventLogTest.cs
@@ -47,6 +47,9 @@ using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
+using System.Security;
+using System.Security.AccessControl;
+using System.Security.Principal;
using System.Threading;
using Microsoft.Win32;
@@ -71,11 +74,22 @@ namespace MonoTests.System.Diagnostics
private const string WIN32_IMPL = "win32";
private const string NULL_IMPL = "null";
+ private static bool IsAzurePipelines => Environment.GetEnvironmentVariable("TF_BUILD") != null;
+
[SetUp]
public void SetUp ()
{
if (Win32EventLogEnabled)
+ {
+ // EventLog requires admin permissions on Windows
+ WindowsIdentity identity = WindowsIdentity.GetCurrent ();
+ WindowsPrincipal principal = new WindowsPrincipal (identity);
+ if (!principal.IsInRole (WindowsBuiltInRole.Administrator)) {
+ Assert.Ignore ("Not running as Administrator");
+ }
+
return;
+ }
// determine temp directory for eventlog store
_temp = new TempDirectory ();
@@ -1201,7 +1215,7 @@ namespace MonoTests.System.Diagnostics
[Test]
public void CreateEventSource1_Log_InvalidCustomerLog ()
{
- if (EventLogImplType != NULL_IMPL)
+ if (EventLogImplType == NULL_IMPL)
// test cannot pass with NULL implementation
Assert.Ignore ("No EventLogImplType.");
@@ -1338,7 +1352,7 @@ namespace MonoTests.System.Diagnostics
[Test]
public void CreateEventSource1_Log_NotUnique ()
{
- if (EventLogImplType != NULL_IMPL)
+ if (EventLogImplType == NULL_IMPL)
// test cannot pass with NULL implementation
Assert.Ignore ("No EventLogImplType.");
@@ -1724,6 +1738,9 @@ namespace MonoTests.System.Diagnostics
Assert.IsTrue (ex.Message.IndexOf ("'.'") != -1, "#5");
Assert.IsNull (ex.InnerException, "#6");
Assert.IsNull (ex.ParamName, "#7");
+ } catch (SecurityException) {
+ if (IsAzurePipelines) Assert.Ignore ("Azure Pipelines fails with: Requested registry access is not allowed on.");
+ throw;
}
}
@@ -1860,6 +1877,9 @@ namespace MonoTests.System.Diagnostics
Assert.IsTrue (ex.Message.IndexOf ("'.'") != -1, "#5");
Assert.IsNull (ex.InnerException, "#6");
Assert.IsNull (ex.ParamName, "#7");
+ } catch (SecurityException) {
+ if (IsAzurePipelines) Assert.Ignore ("Azure Pipelines fails with: Requested registry access is not allowed.");
+ throw;
}
}
@@ -2781,9 +2801,15 @@ namespace MonoTests.System.Diagnostics
Assert.Ignore ("Event log 'monologother' should not exist.");
}
- using (RegistryKey sourceKey = FindSourceKeyByName ("monotempsource")) {
- if (sourceKey != null)
- Assert.Ignore ("Event log source 'monotempsource' should not exist.");
+ try {
+ using (RegistryKey sourceKey = FindSourceKeyByName ("monotempsource")) {
+ if (sourceKey != null)
+ Assert.Ignore ("Event log source 'monotempsource' should not exist.");
+ }
+ }
+ catch (SecurityException) {
+ if (IsAzurePipelines) Assert.Ignore ("Azure Pipelines fails with: Requested registry access is not allowed.");
+ throw;
}
Assert.IsFalse (EventLog.Exists ("monologtemp"), "#A1");
@@ -2849,9 +2875,14 @@ namespace MonoTests.System.Diagnostics
Assert.Ignore ("Event log 'monologother' should not exist.");
}
- using (RegistryKey sourceKey = FindSourceKeyByName ("monotempsource")) {
- if (sourceKey != null)
- Assert.Ignore ("Event log source 'monotempsource' should not exist.");
+ try {
+ using (RegistryKey sourceKey = FindSourceKeyByName ("monotempsource")) {
+ if (sourceKey != null)
+ Assert.Ignore ("Event log source 'monotempsource' should not exist.");
+ }
+ } catch (SecurityException) {
+ if (IsAzurePipelines) Assert.Ignore ("Azure Pipelines fails with: Requested registry access is not allowed.");
+ throw;
}
Assert.IsFalse (EventLog.Exists ("monologtemp", "."), "#A1");
@@ -3281,9 +3312,14 @@ namespace MonoTests.System.Diagnostics
Assert.Ignore ("Event log 'monologtemp' should not exist.");
}
- using (RegistryKey sourceKey = FindSourceKeyByName ("monotempsource")) {
- if (sourceKey != null)
- Assert.Ignore ("Event log source 'monotempsource' should not exist.");
+ try {
+ using (RegistryKey sourceKey = FindSourceKeyByName ("monotempsource")) {
+ if (sourceKey != null)
+ Assert.Ignore ("Event log source 'monotempsource' should not exist.");
+ }
+ } catch (SecurityException) {
+ if (IsAzurePipelines) Assert.Ignore ("Azure Pipelines fails with: Requested registry access is not allowed.");
+ throw;
}
Assert.IsFalse (EventLog.SourceExists ("monotempsource"), "#A1");
@@ -3354,9 +3390,14 @@ namespace MonoTests.System.Diagnostics
Assert.Ignore ("Event log 'monologtemp' should not exist.");
}
- using (RegistryKey sourceKey = FindSourceKeyByName ("monotempsource")) {
- if (sourceKey != null)
- Assert.Ignore ("Event log source 'monotempsource' should not exist.");
+ try {
+ using (RegistryKey sourceKey = FindSourceKeyByName ("monotempsource")) {
+ if (sourceKey != null)
+ Assert.Ignore ("Event log source 'monotempsource' should not exist.");
+ }
+ } catch (SecurityException) {
+ if (IsAzurePipelines) Assert.Ignore ("Azure Pipelines fails with: Requested registry access is not allowed.");
+ throw;
}
Assert.IsFalse (EventLog.SourceExists ("monotempsource", "."), "#1");
diff --git a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
index a54d54a9077..34537751155 100755
--- a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
+++ b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
@@ -3769,6 +3769,7 @@ namespace MonoTests.System.Net.Sockets
// Test case for https://bugzilla.novell.com/show_bug.cgi?id=443346
// See also https://bugzilla.xamarin.com/show_bug.cgi?id=52157
[Test]
+ [Category("NotOnWindows")] // doesn't work anymore in Win10
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif