Imported Upstream version 5.16.0.100

Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-08-07 15:19:03 +00:00
parent 0a9828183b
commit 7d7f676260
4419 changed files with 170950 additions and 90273 deletions

View File

@ -29,9 +29,6 @@
<Compile Include="$(CommonPath)\System\Net\ByteOrder.cs">
<Link>Common\System\Net\ByteOrder.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\IntPtrHelper.cs">
<Link>Common\System\Net\IntPtrHelper.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Net\IPAddressParserStatics.cs">
<Link>Common\System\Net\IPAddressParserStatics.cs</Link>
</Compile>

View File

@ -312,7 +312,7 @@ namespace System.Net.NetworkInformation
// Only copy the data if we succeed w/ the ping operation.
rtt = reply.RoundTripTime;
buffer = new byte[sendSize];
Marshal.Copy(IntPtrHelper.Add(dataPtr, 36), buffer, 0, sendSize);
Marshal.Copy(dataPtr + 36, buffer, 0, sendSize);
}
else
{

View File

@ -2,6 +2,7 @@
// 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.Collections.Generic;
using System.Diagnostics;
using System.Net.Sockets;
using System.Runtime.InteropServices;
@ -33,21 +34,59 @@ namespace System.Net.NetworkInformation.Tests
? UnixCommandLinePing.Ping4UtilityPath
: UnixCommandLinePing.Ping6UtilityPath;
ProcessStartInfo psi = new ProcessStartInfo(utilityPath, arguments);
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
Process p = Process.Start(psi);
var p = new Process();
p.StartInfo.FileName = utilityPath;
p.StartInfo.Arguments = arguments;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
var stdOutLines = new List<string>();
p.OutputDataReceived += new DataReceivedEventHandler(
delegate (object sendingProcess, DataReceivedEventArgs outputLine) { stdOutLines.Add(outputLine.Data); });
string pingOutput = p.StandardOutput.ReadToEnd();
Assert.True(p.WaitForExit(TestSettings.PingTimeout), "Ping process did not exit in " + TestSettings.PingTimeout + " ms.");
if (p.ExitCode == 1 || p.ExitCode == 2)
p.StartInfo.RedirectStandardError = true;
var stdErrLines = new List<string>();
p.ErrorDataReceived += new DataReceivedEventHandler(
delegate (object sendingProcess, DataReceivedEventArgs errorLine) { stdErrLines.Add(errorLine.Data); });
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
// There are multiple issues with ping6 in macOS 10.12 (Sierra), see https://github.com/dotnet/corefx/issues/26358.
bool isPing6OnMacSierra = utilityPath.Equals(UnixCommandLinePing.Ping6UtilityPath) &&
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) &&
!PlatformDetection.IsMacOsHighSierraOrHigher;
string pingOutput;
if (!p.WaitForExit(TestSettings.PingTimeout))
{
// Workaround known OSX bug in ping6 utility.
Assert.Equal(utilityPath, UnixCommandLinePing.Ping6UtilityPath);
Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.OSX));
return;
// Workaround known issues with ping6 in macOS 10.12
if (isPing6OnMacSierra)
return;
pingOutput = string.Join("\n", stdOutLines);
string stdErr = string.Join("\n", stdErrLines);
throw new Exception(
$"[{utilityPath} {arguments}] process did not exit in {TestSettings.PingTimeout} ms.\nStdOut:[{pingOutput}]\nStdErr:[{stdErr}]");
}
// Ensure standard output and error are flushed
p.WaitForExit();
pingOutput = string.Join("\n", stdOutLines);
var exitCode = p.ExitCode;
if (exitCode != 0)
{
// Workaround known issues with ping6 in macOS 10.12
if (isPing6OnMacSierra)
return;
string stdErr = string.Join("\n", stdErrLines);
throw new Exception(
$"[{utilityPath} {arguments}] process exit code is {exitCode}.\nStdOut:[{pingOutput}]\nStdErr:[{stdErr}]");
}
try
{
// Validate that the returned data size is correct.
@ -65,7 +104,9 @@ namespace System.Net.NetworkInformation.Tests
}
catch (Exception e)
{
throw new Exception($"Ping output was <{pingOutput}>", e);
string stdErr = string.Join("\n", stdErrLines);
throw new Exception(
$"Parse error for [{utilityPath} {arguments}] process exit code is {exitCode}.\nStdOut:[{pingOutput}]\nStdErr:[{stdErr}]", e);
}
}