You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@ -2,7 +2,8 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>4.1.0.0</AssemblyVersion>
|
||||
<AssemblyVersion>4.1.1.0</AssemblyVersion>
|
||||
<AssemblyKey>MSFT</AssemblyKey>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
<IsUAP>true</IsUAP>
|
||||
</PropertyGroup>
|
||||
|
6
external/corefx/src/System.Net.Ping/src/ILLinkTrim.xml
vendored
Normal file
6
external/corefx/src/System.Net.Ping/src/ILLinkTrim.xml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<linker>
|
||||
<assembly fullname="System.Net.Ping">
|
||||
<!-- NetEventSource isn't used by this assembly but tests check for its presence -->
|
||||
<type fullname="System.Net.NetEventSource" />
|
||||
</assembly>
|
||||
</linker>
|
@ -6,7 +6,6 @@
|
||||
<ProjectGuid>{85FD05E8-A4B1-4B89-ABED-33AFD200CABD}</ProjectGuid>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<!-- Help VS understand available configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
|
||||
|
@ -175,9 +175,9 @@ namespace System.Net.NetworkInformation
|
||||
else
|
||||
{
|
||||
cts.Cancel();
|
||||
if (p.ExitCode != 0)
|
||||
if (p.ExitCode == 1 || p.ExitCode == 2)
|
||||
{
|
||||
// This means no reply was received, although transmission may have been successful.
|
||||
// Throw timeout for known failure return codes from ping functions.
|
||||
return CreateTimedOutPingReply();
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ namespace System.Net.NetworkInformation
|
||||
pingTask.ContinueWith((t, state) =>
|
||||
{
|
||||
var asyncOp = (AsyncOperation)state;
|
||||
var e = new PingCompletedEventArgs(t.Status == TaskStatus.RanToCompletion ? t.Result : null, t.Exception, t.IsCanceled, asyncOp.UserSuppliedState);
|
||||
var e = new PingCompletedEventArgs(t.IsCompletedSuccessfully ? t.Result : null, t.Exception, t.IsCanceled, asyncOp.UserSuppliedState);
|
||||
SendOrPostCallback callback = _onPingCompletedDelegate ?? (_onPingCompletedDelegate = new SendOrPostCallback(o => { OnPingCompleted((PingCompletedEventArgs)o); }));
|
||||
asyncOp.PostOperationCompleted(callback, e);
|
||||
}, AsyncOperationManager.CreateOperation(userToken), CancellationToken.None, TaskContinuationOptions.DenyChildAttach, TaskScheduler.Default);
|
||||
|
@ -22,6 +22,7 @@ namespace System.Net.NetworkInformation
|
||||
protected PingException(SerializationInfo serializationInfo, StreamingContext streamingContext) :
|
||||
base(serializationInfo, streamingContext)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
{
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "NetEventSource is only part of .NET Core")]
|
||||
[ActiveIssue("https://github.com/dotnet/corefx/issues/20130", TargetFrameworkMonikers.Uap)]
|
||||
public void EventSource_ExistsWithCorrectId()
|
||||
{
|
||||
Type esType = typeof(Ping).Assembly.GetType("System.Net.NetEventSource", throwOnError: true, ignoreCase: false);
|
||||
|
@ -40,47 +40,48 @@ namespace System.Net.NetworkInformation.Tests
|
||||
Ping p = new Ping();
|
||||
|
||||
// Null address
|
||||
Assert.Throws<ArgumentNullException>("address", () => { p.SendPingAsync((IPAddress)null); });
|
||||
Assert.Throws<ArgumentNullException>("hostNameOrAddress", () => { p.SendPingAsync((string)null); });
|
||||
Assert.Throws<ArgumentNullException>("address", () => { p.SendAsync((IPAddress)null, null); });
|
||||
Assert.Throws<ArgumentNullException>("hostNameOrAddress", () => { p.SendAsync((string)null, null); });
|
||||
Assert.Throws<ArgumentNullException>("address", () => { p.Send((IPAddress)null); });
|
||||
Assert.Throws<ArgumentNullException>("hostNameOrAddress", () => { p.Send((string)null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("address", () => { p.SendPingAsync((IPAddress)null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("hostNameOrAddress", () => { p.SendPingAsync((string)null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("address", () => { p.SendAsync((IPAddress)null, null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("hostNameOrAddress", () => { p.SendAsync((string)null, null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("address", () => { p.Send((IPAddress)null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("hostNameOrAddress", () => { p.Send((string)null); });
|
||||
|
||||
// Invalid address
|
||||
Assert.Throws<ArgumentException>("address", () => { p.SendPingAsync(IPAddress.Any); });
|
||||
Assert.Throws<ArgumentException>("address", () => { p.SendPingAsync(IPAddress.IPv6Any); });
|
||||
Assert.Throws<ArgumentException>("address", () => { p.SendAsync(IPAddress.Any, null); });
|
||||
Assert.Throws<ArgumentException>("address", () => { p.SendAsync(IPAddress.IPv6Any, null); });
|
||||
Assert.Throws<ArgumentException>("address", () => { p.Send(IPAddress.Any); });
|
||||
Assert.Throws<ArgumentException>("address", () => { p.Send(IPAddress.IPv6Any); });
|
||||
AssertExtensions.Throws<ArgumentException>("address", () => { p.SendPingAsync(IPAddress.Any); });
|
||||
AssertExtensions.Throws<ArgumentException>("address", () => { p.SendPingAsync(IPAddress.IPv6Any); });
|
||||
AssertExtensions.Throws<ArgumentException>("address", () => { p.SendAsync(IPAddress.Any, null); });
|
||||
AssertExtensions.Throws<ArgumentException>("address", () => { p.SendAsync(IPAddress.IPv6Any, null); });
|
||||
AssertExtensions.Throws<ArgumentException>("address", () => { p.Send(IPAddress.Any); });
|
||||
AssertExtensions.Throws<ArgumentException>("address", () => { p.Send(IPAddress.IPv6Any); });
|
||||
|
||||
// Negative timeout
|
||||
Assert.Throws<ArgumentOutOfRangeException>("timeout", () => { p.SendPingAsync(localIpAddress, -1); });
|
||||
Assert.Throws<ArgumentOutOfRangeException>("timeout", () => { p.SendPingAsync(TestSettings.LocalHost, -1); });
|
||||
Assert.Throws<ArgumentOutOfRangeException>("timeout", () => { p.SendAsync(localIpAddress, -1, null); });
|
||||
Assert.Throws<ArgumentOutOfRangeException>("timeout", () => { p.SendAsync(TestSettings.LocalHost, -1, null); });
|
||||
Assert.Throws<ArgumentOutOfRangeException>("timeout", () => { p.Send(localIpAddress, -1); });
|
||||
Assert.Throws<ArgumentOutOfRangeException>("timeout", () => { p.Send(TestSettings.LocalHost, -1); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("timeout", () => { p.SendPingAsync(localIpAddress, -1); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("timeout", () => { p.SendPingAsync(TestSettings.LocalHost, -1); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("timeout", () => { p.SendAsync(localIpAddress, -1, null); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("timeout", () => { p.SendAsync(TestSettings.LocalHost, -1, null); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("timeout", () => { p.Send(localIpAddress, -1); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("timeout", () => { p.Send(TestSettings.LocalHost, -1); });
|
||||
|
||||
// Null byte[]
|
||||
Assert.Throws<ArgumentNullException>("buffer", () => { p.SendPingAsync(localIpAddress, 0, null); });
|
||||
Assert.Throws<ArgumentNullException>("buffer", () => { p.SendPingAsync(TestSettings.LocalHost, 0, null); });
|
||||
Assert.Throws<ArgumentNullException>("buffer", () => { p.SendAsync(localIpAddress, 0, null, null); });
|
||||
Assert.Throws<ArgumentNullException>("buffer", () => { p.SendAsync(TestSettings.LocalHost, 0, null, null); });
|
||||
Assert.Throws<ArgumentNullException>("buffer", () => { p.Send(localIpAddress, 0, null); });
|
||||
Assert.Throws<ArgumentNullException>("buffer", () => { p.Send(TestSettings.LocalHost, 0, null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("buffer", () => { p.SendPingAsync(localIpAddress, 0, null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("buffer", () => { p.SendPingAsync(TestSettings.LocalHost, 0, null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("buffer", () => { p.SendAsync(localIpAddress, 0, null, null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("buffer", () => { p.SendAsync(TestSettings.LocalHost, 0, null, null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("buffer", () => { p.Send(localIpAddress, 0, null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("buffer", () => { p.Send(TestSettings.LocalHost, 0, null); });
|
||||
|
||||
// Too large byte[]
|
||||
Assert.Throws<ArgumentException>("buffer", () => { p.SendPingAsync(localIpAddress, 1, new byte[65501]); });
|
||||
Assert.Throws<ArgumentException>("buffer", () => { p.SendPingAsync(TestSettings.LocalHost, 1, new byte[65501]); });
|
||||
Assert.Throws<ArgumentException>("buffer", () => { p.SendAsync(localIpAddress, 1, new byte[65501], null); });
|
||||
Assert.Throws<ArgumentException>("buffer", () => { p.SendAsync(TestSettings.LocalHost, 1, new byte[65501], null); });
|
||||
Assert.Throws<ArgumentException>("buffer", () => { p.Send(localIpAddress, 1, new byte[65501]); });
|
||||
Assert.Throws<ArgumentException>("buffer", () => { p.Send(TestSettings.LocalHost, 1, new byte[65501]); });
|
||||
AssertExtensions.Throws<ArgumentException>("buffer", () => { p.SendPingAsync(localIpAddress, 1, new byte[65501]); });
|
||||
AssertExtensions.Throws<ArgumentException>("buffer", () => { p.SendPingAsync(TestSettings.LocalHost, 1, new byte[65501]); });
|
||||
AssertExtensions.Throws<ArgumentException>("buffer", () => { p.SendAsync(localIpAddress, 1, new byte[65501], null); });
|
||||
AssertExtensions.Throws<ArgumentException>("buffer", () => { p.SendAsync(TestSettings.LocalHost, 1, new byte[65501], null); });
|
||||
AssertExtensions.Throws<ArgumentException>("buffer", () => { p.Send(localIpAddress, 1, new byte[65501]); });
|
||||
AssertExtensions.Throws<ArgumentException>("buffer", () => { p.Send(TestSettings.LocalHost, 1, new byte[65501]); });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithIPAddress()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -95,6 +96,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithIPAddress_AddressAsString()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -109,6 +111,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithIPAddressAndTimeout()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -123,6 +126,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // On Unix, Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply.
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[Fact]
|
||||
public async Task SendPingAsyncWithIPAddressAndTimeoutAndBuffer()
|
||||
{
|
||||
@ -167,6 +171,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // On Unix, Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply.
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[Fact]
|
||||
public async Task SendPingAsyncWithIPAddressAndTimeoutAndBufferAndPingOptions()
|
||||
{
|
||||
@ -212,6 +217,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithHost()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -226,6 +232,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public async Task SendPingAsyncWithHostAndTimeout()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -240,6 +247,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // On Unix, Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply.
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[Fact]
|
||||
public async Task SendPingAsyncWithHostAndTimeoutAndBuffer()
|
||||
{
|
||||
@ -284,6 +292,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // On Unix, Non-root pings cannot send arbitrary data in the buffer, and do not receive it back in the PingReply.
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
[Fact]
|
||||
public async Task SendPingAsyncWithHostAndTimeoutAndBufferAndPingOptions()
|
||||
{
|
||||
@ -328,6 +337,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public static async Task SendPings_ReuseInstance_Hostname()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -344,6 +354,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public static async Task Sends_ReuseInstance_Hostname()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -360,6 +371,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public static async Task SendAsyncs_ReuseInstance_Hostname()
|
||||
{
|
||||
IPAddress localIpAddress = await TestSettings.GetLocalIPAddress();
|
||||
@ -411,6 +423,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public static async Task Ping_DisposeAfterSend_Success()
|
||||
{
|
||||
Ping p = new Ping();
|
||||
@ -419,6 +432,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public static void Ping_DisposeMultipletimes_Success()
|
||||
{
|
||||
Ping p = new Ping();
|
||||
@ -427,6 +441,7 @@ namespace System.Net.NetworkInformation.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20130, TargetFrameworkMonikers.Uap)]
|
||||
public static void Ping_SendAfterDispose_ThrowsSynchronously()
|
||||
{
|
||||
Ping p = new Ping();
|
||||
|
@ -4,7 +4,6 @@
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{43CE20B7-389B-41BB-8390-447521DF3BD4}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<!-- Help VS understand available configurations -->
|
||||
<!-- Test APIs introduced after 1.0 -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Unix-Release|AnyCPU'" />
|
||||
@ -24,6 +23,9 @@
|
||||
<Compile Include="$(CommonPath)\System\Net\NetworkInformation\UnixCommandLinePing.cs">
|
||||
<Link>Common\System\Net\NetworkInformation\UnixCommandLinePing.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
|
||||
<Link>Common\System\AssertExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\Net\Capability.RawSocketPermissions.cs">
|
||||
<Link>Common\System\Net\Capability.RawSocketPermissions.cs</Link>
|
||||
</Compile>
|
||||
|
@ -36,21 +36,29 @@ namespace System.Net.NetworkInformation.Tests
|
||||
psi.RedirectStandardError = true;
|
||||
psi.RedirectStandardOutput = true;
|
||||
Process p = Process.Start(psi);
|
||||
Assert.True(p.WaitForExit(TestSettings.PingTimeout), "Ping process did not exit in " + TestSettings.PingTimeout + " ms.");
|
||||
|
||||
string pingOutput = p.StandardOutput.ReadToEnd();
|
||||
// Validate that the returned data size is correct.
|
||||
// It should be equal to the bytes we sent plus the size of the ICMP header.
|
||||
int receivedBytes = ParseReturnedPacketSize(pingOutput);
|
||||
int expected = Math.Max(16, payloadSize) + IcmpHeaderLengthInBytes;
|
||||
Assert.Equal(expected, receivedBytes);
|
||||
Assert.True(p.WaitForExit(TestSettings.PingTimeout), "Ping process did not exit in " + TestSettings.PingTimeout + " ms.");
|
||||
|
||||
// Validate that we only sent one ping with the "-c 1" argument.
|
||||
int numPingsSent = ParseNumPingsSent(pingOutput);
|
||||
Assert.Equal(1, numPingsSent);
|
||||
try
|
||||
{
|
||||
// Validate that the returned data size is correct.
|
||||
// It should be equal to the bytes we sent plus the size of the ICMP header.
|
||||
int receivedBytes = ParseReturnedPacketSize(pingOutput);
|
||||
int expected = Math.Max(16, payloadSize) + IcmpHeaderLengthInBytes;
|
||||
Assert.Equal(expected, receivedBytes);
|
||||
|
||||
long rtt = UnixCommandLinePing.ParseRoundTripTime(pingOutput);
|
||||
Assert.InRange(rtt, 0, long.MaxValue);
|
||||
// Validate that we only sent one ping with the "-c 1" argument.
|
||||
int numPingsSent = ParseNumPingsSent(pingOutput);
|
||||
Assert.Equal(1, numPingsSent);
|
||||
|
||||
long rtt = UnixCommandLinePing.ParseRoundTripTime(pingOutput);
|
||||
Assert.InRange(rtt, 0, long.MaxValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception($"Ping output was <{pingOutput}>", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static int ParseReturnedPacketSize(string pingOutput)
|
||||
|
Reference in New Issue
Block a user