You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
@@ -1,14 +1,3 @@
|
||||
kernel32.dll!ClearCommBreak
|
||||
kernel32.dll!ClearCommError
|
||||
kernel32.dll!CreateFileW
|
||||
kernel32.dll!EscapeCommFunction
|
||||
kernel32.dll!GetCommModemStatus
|
||||
kernel32.dll!GetCommProperties
|
||||
kernel32.dll!GetCommState
|
||||
kernel32.dll!PurgeComm
|
||||
kernel32.dll!SetCommBreak
|
||||
kernel32.dll!SetCommMask
|
||||
kernel32.dll!SetCommState
|
||||
kernel32.dll!SetCommTimeouts
|
||||
kernel32.dll!SetupComm
|
||||
kernel32.dll!WaitCommEvent
|
||||
## need to create a uap config that uses CreateFileFromApp, then remove this baseline ##
|
||||
# https://github.com/dotnet/corefx/issues/21025
|
||||
kernel32.dll!CreateFileW
|
||||
@@ -4,39 +4,28 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.IO.PortsTests;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Legacy.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace System.IO.Ports.Tests
|
||||
{
|
||||
[ActiveIssue("https://github.com/dotnet/corefx/issues/20588", TargetFrameworkMonikers.Uap)] // fails in both Uap and UapAot
|
||||
public class GetPortNames : PortsTest
|
||||
{
|
||||
#region Test Cases
|
||||
|
||||
/// <summary>
|
||||
/// Check that all ports either open correctly or fail with UnauthorizedAccessException (which implies they're already open)
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[ActiveIssue("https://github.com/dotnet/corefx/issues/20588 - GetPortNames() has registry dependency.", TargetFrameworkMonikers.UapAot)]
|
||||
private void OpenEveryPortName()
|
||||
{
|
||||
string[] portNames = SerialPort.GetPortNames();
|
||||
|
||||
for (int i = 0; i < portNames.Length; ++i)
|
||||
foreach (string portName in SerialPort.GetPortNames())
|
||||
{
|
||||
Debug.WriteLine("Opening port " + portNames[i]);
|
||||
bool portExists = false;
|
||||
foreach (string str in PortHelper.GetPorts())
|
||||
{
|
||||
if (str == portNames[i])
|
||||
{
|
||||
portExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!portExists)
|
||||
{
|
||||
Debug.WriteLine("Real Port does not exist. Ignore the output from SerialPort.GetPortNames()");
|
||||
continue;
|
||||
}
|
||||
using (SerialPort serialPort = new SerialPort(portNames[i]))
|
||||
Debug.WriteLine("Opening port " + portName);
|
||||
using (SerialPort serialPort = new SerialPort(portName))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -46,7 +35,49 @@ namespace System.IO.Ports.Tests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that SerialPort.GetPortNames finds every port that the test helpers have found.
|
||||
/// (On Windows, the latter uses a different technique to SerialPort to find ports).
|
||||
/// </summary>
|
||||
[Fact]
|
||||
private void AllHelperPortsAreInGetPortNames()
|
||||
{
|
||||
string[] serialPortNames = SerialPort.GetPortNames();
|
||||
foreach (string helperPortName in PortHelper.GetPorts())
|
||||
{
|
||||
Assert.True(serialPortNames.Contains(helperPortName),
|
||||
$"{helperPortName} is not present in SerialPort.GetPortNames result\r\n{PortInformationString}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that the test helpers have found every port that SerialPort.GetPortNames has found
|
||||
/// This catches regressions in the test helpers, eg GH #18928 / #20668
|
||||
/// </summary>
|
||||
[Fact]
|
||||
private void AllGetPortNamesAreInHelperPorts()
|
||||
{
|
||||
string[] helperPortNames = PortHelper.GetPorts();
|
||||
foreach (string serialPortName in SerialPort.GetPortNames())
|
||||
{
|
||||
Assert.True(helperPortNames.Contains(serialPortName),
|
||||
$"{serialPortName} is not present in PortHelper.GetPorts result\r\n{PortInformationString}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
static string PortInformationString
|
||||
{
|
||||
get
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("PortHelper Ports: " + string.Join(",", PortHelper.GetPorts()));
|
||||
sb.AppendLine("SerialPort Ports: " + string.Join(",", SerialPort.GetPortNames()));
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace System.IO.Ports.Tests
|
||||
public class OpenDevices : PortsTest
|
||||
{
|
||||
[Fact]
|
||||
[ActiveIssue(21156, TargetFrameworkMonikers.Uap)]
|
||||
public void OpenDevices01()
|
||||
{
|
||||
DosDevices dosDevices = new DosDevices();
|
||||
|
||||
@@ -436,7 +436,7 @@ namespace System.IO.Ports.Tests
|
||||
5000, "Err_91818aheid BytesToRead");
|
||||
|
||||
// We expect this to fail, because it can't read a surrogate
|
||||
Assert.Throws<ArgumentException>(() => com1.ReadChar());
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => com1.ReadChar());
|
||||
|
||||
int result = com1.Read(charRcvBuffer, 0, 2);
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace System.IO.Ports.Tests
|
||||
public void Filename()
|
||||
{
|
||||
string portName;
|
||||
string fileName = portName = "PortNameEqualToFileName.txt";
|
||||
string fileName = portName = GetTestFilePath();
|
||||
FileStream testFile = File.Open(fileName, FileMode.Create);
|
||||
ASCIIEncoding asciiEncd = new ASCIIEncoding();
|
||||
string testStr = "Hello World";
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace System.IO.Ports.Tests
|
||||
{
|
||||
string portName;
|
||||
int baudRate = 9600;
|
||||
string fileName = portName = "PortNameEqualToFileName.txt";
|
||||
string fileName = portName = GetTestFilePath();
|
||||
FileStream testFile = File.Open(fileName, FileMode.Create);
|
||||
ASCIIEncoding asciiEncd = new ASCIIEncoding();
|
||||
string testStr = "Hello World";
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace System.IO.Ports.Tests
|
||||
string portName;
|
||||
int baudRate = 9600;
|
||||
int parity = (int)Parity.Space;
|
||||
string fileName = portName = "PortNameEqualToFileName.txt";
|
||||
string fileName = portName = GetTestFilePath();
|
||||
FileStream testFile = File.Open(fileName, FileMode.Create);
|
||||
ASCIIEncoding asciiEncd = new ASCIIEncoding();
|
||||
string testStr = "Hello World";
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace System.IO.Ports.Tests
|
||||
int baudRate = 9600;
|
||||
int parity = (int)Parity.Space;
|
||||
int dataBits = 8;
|
||||
string fileName = portName = "PortNameEqualToFileName.txt";
|
||||
string fileName = portName = GetTestFilePath();
|
||||
FileStream testFile = File.Open(fileName, FileMode.Create);
|
||||
ASCIIEncoding asciiEncd = new ASCIIEncoding();
|
||||
string testStr = "Hello World";
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace System.IO.Ports.Tests
|
||||
int parity = (int)Parity.Space;
|
||||
int dataBits = 8;
|
||||
int stopBits = (int)StopBits.One;
|
||||
string fileName = portName = "PortNameEqualToFileName.txt";
|
||||
string fileName = portName = GetTestFilePath();
|
||||
FileStream testFile = File.Open(fileName, FileMode.Create);
|
||||
ASCIIEncoding asciiEncd = new ASCIIEncoding();
|
||||
string testStr = "Hello World";
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Legacy.Support
|
||||
{
|
||||
@@ -19,6 +20,11 @@ namespace Legacy.Support
|
||||
|
||||
public static string[] GetPorts()
|
||||
{
|
||||
if (PlatformDetection.IsWinRT)
|
||||
{
|
||||
return new string[0]; // we are waiting for a Win32 new QueryDosDevice API since the current doesn't work for Uap https://github.com/dotnet/corefx/issues/21156
|
||||
}
|
||||
|
||||
List<string> ports = new List<string>();
|
||||
int returnSize = 0;
|
||||
int maxSize = 1000000;
|
||||
@@ -61,9 +67,10 @@ namespace Legacy.Support
|
||||
|
||||
if (retval != null)
|
||||
{
|
||||
var serialRegex = new Regex(@"^COM\d{1,3}$");
|
||||
foreach (string str in retval)
|
||||
{
|
||||
if (str.StartsWith("COM"))
|
||||
if (serialRegex.IsMatch(str))
|
||||
{
|
||||
ports.Add(str);
|
||||
Debug.WriteLine("Installed serial ports :" + str);
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.IO;
|
||||
using Legacy.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace System.IO.PortsTests
|
||||
{
|
||||
public class PortsTest
|
||||
public class PortsTest : FileCleanupTestBase
|
||||
{
|
||||
public static bool HasOneSerialPort => TCSupport.SufficientHardwareRequirements(TCSupport.SerialPortRequirements.OneSerialPort);
|
||||
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
<ProjectGuid>{4259DCE9-3480-40BB-B08A-64A2D446264B}</ProjectGuid>
|
||||
<TestCategories>InnerLoop;OuterLoop</TestCategories>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the options -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
|
||||
<!-- Default configurations to help VS understand the options -->
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="SerialPort\BaseStream.cs" />
|
||||
@@ -116,9 +118,9 @@
|
||||
<Compile Include="Support\TCSupport.cs" />
|
||||
<Compile Include="Support\PortsTest.cs" />
|
||||
<Compile Include="Support\TestEventHandler.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
|
||||
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
|
||||
<Link>CommonTest\System\PlatformDetection.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Legacy\Manual\" />
|
||||
|
||||
Reference in New Issue
Block a user