未验证 提交 643e08da 编写于 作者: R Radek Zikmund 提交者: GitHub

Fix ping tests on OSX (#65508)

Test against both IPv4 and IPv6 addresses when pinging using "localhost" hostname
上级 5ab9fadc
......@@ -43,10 +43,7 @@ public PingTest(ITestOutputHelper output)
_output = output;
}
private void PingResultValidator(PingReply pingReply, IPAddress localIpAddress)
{
PingResultValidator(pingReply, new IPAddress[] { localIpAddress }, _output);
}
private void PingResultValidator(PingReply pingReply, IPAddress localIpAddress) => PingResultValidator(pingReply, new IPAddress[] { localIpAddress }, _output);
private void PingResultValidator(PingReply pingReply, IPAddress[] localIpAddresses) => PingResultValidator(pingReply, localIpAddresses, null);
......@@ -396,65 +393,61 @@ public async Task SendPingAsyncWithHostAndTimeout()
}
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/64963", TestPlatforms.OSX)]
public void SendPingWithHostAndTimeoutAndBuffer()
{
IPAddress localIpAddress = TestSettings.GetLocalIPAddress();
byte[] buffer = GetPingPayload(localIpAddress.AddressFamily);
IPAddress[] localIpAddresses = TestSettings.GetLocalIPAddresses();
byte[] buffer = GetPingPayload(localIpAddresses[0].AddressFamily);
SendBatchPing(
(ping) => ping.Send(TestSettings.LocalHost, TestSettings.PingTimeout, buffer),
(pingReply) =>
{
PingResultValidator(pingReply, localIpAddress);
PingResultValidator(pingReply, localIpAddresses);
Assert.Equal(buffer, pingReply.Buffer);
});
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/64963", TestPlatforms.OSX)]
public async Task SendPingAsyncWithHostAndTimeoutAndBuffer()
{
IPAddress localIpAddress = await TestSettings.GetLocalIPAddressAsync();
byte[] buffer = GetPingPayload(localIpAddress.AddressFamily);
IPAddress[] localIpAddresses = await TestSettings.GetLocalIPAddressesAsync();
byte[] buffer = GetPingPayload(localIpAddresses[0].AddressFamily);
await SendBatchPingAsync(
(ping) => ping.SendPingAsync(TestSettings.LocalHost, TestSettings.PingTimeout, buffer),
(pingReply) =>
{
PingResultValidator(pingReply, localIpAddress);
PingResultValidator(pingReply, localIpAddresses);
Assert.Equal(buffer, pingReply.Buffer);
});
}
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/64963", TestPlatforms.OSX)]
public void SendPingWithHostAndTimeoutAndBufferAndPingOptions()
{
IPAddress localIpAddress = TestSettings.GetLocalIPAddress();
byte[] buffer = GetPingPayload(localIpAddress.AddressFamily);
IPAddress[] localIpAddresses = TestSettings.GetLocalIPAddresses();
byte[] buffer = GetPingPayload(localIpAddresses[0].AddressFamily);
SendBatchPing(
(ping) => ping.Send(TestSettings.LocalHost, TestSettings.PingTimeout, buffer, new PingOptions()),
(pingReply) =>
{
PingResultValidator(pingReply, localIpAddress);
PingResultValidator(pingReply, localIpAddresses);
Assert.Equal(buffer, pingReply.Buffer);
});
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/64963", TestPlatforms.OSX)]
public async Task SendPingAsyncWithHostAndTimeoutAndBufferAndPingOptions()
{
IPAddress localIpAddress = await TestSettings.GetLocalIPAddressAsync();
byte[] buffer = GetPingPayload(localIpAddress.AddressFamily);
IPAddress[] localIpAddresses = await TestSettings.GetLocalIPAddressesAsync();
byte[] buffer = GetPingPayload(localIpAddresses[0].AddressFamily);
await SendBatchPingAsync(
(ping) => ping.SendPingAsync(TestSettings.LocalHost, TestSettings.PingTimeout, buffer, new PingOptions()),
(pingReply) =>
{
PingResultValidator(pingReply, localIpAddress);
PingResultValidator(pingReply, localIpAddresses);
Assert.Equal(buffer, pingReply.Buffer);
});
......@@ -651,7 +644,6 @@ public void CanBeFinalized()
public async Task SendPingAsyncWithHostAndTtlAndFragmentPingOptions(bool fragment)
{
IPAddress[] localIpAddresses = await TestSettings.GetLocalIPAddressesAsync();
byte[] buffer = GetPingPayload(localIpAddresses[0].AddressFamily);
PingOptions options = new PingOptions();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册