You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.69
Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
parent
d8f8abd549
commit
e2950ec768
@ -176,10 +176,10 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Win32.Primitives" />
|
||||
<Reference Include="System.Collections" />
|
||||
<Reference Include="System.Diagnostics.Contracts" />
|
||||
<Reference Include="System.Diagnostics.Debug" />
|
||||
<Reference Include="System.Diagnostics.Tracing" />
|
||||
<Reference Include="System.Globalization" />
|
||||
<Reference Include="System.Memory" />
|
||||
<Reference Include="System.Net.Primitives" />
|
||||
<Reference Include="System.Resources.ResourceManager" />
|
||||
<Reference Include="System.Runtime" />
|
||||
|
@ -207,7 +207,7 @@ namespace System.Net
|
||||
error = Interop.Sys.GetNameInfo(
|
||||
rawAddress,
|
||||
unchecked((uint)addressBuffer.Length),
|
||||
addr.AddressFamily == AddressFamily.InterNetworkV6,
|
||||
addr.AddressFamily == AddressFamily.InterNetworkV6 ? (byte)1 : (byte)0,
|
||||
buffer,
|
||||
Interop.Sys.NI_MAXHOST,
|
||||
null,
|
||||
|
@ -13,23 +13,17 @@ namespace System.Net.NameResolution.Tests
|
||||
public class GetHostAddressesTest
|
||||
{
|
||||
[Fact]
|
||||
public void Dns_GetHostAddressesAsync_HostString_Ok()
|
||||
{
|
||||
TestGetHostAddressesAsync(() => Dns.GetHostAddressesAsync(TestSettings.LocalHost));
|
||||
}
|
||||
public Task Dns_GetHostAddressesAsync_HostString_Ok() => TestGetHostAddressesAsync(() => Dns.GetHostAddressesAsync(TestSettings.LocalHost));
|
||||
|
||||
[Fact]
|
||||
public void Dns_GetHostAddressesAsync_IPString_Ok()
|
||||
{
|
||||
TestGetHostAddressesAsync(() => Dns.GetHostAddressesAsync(TestSettings.LocalIPString));
|
||||
}
|
||||
|
||||
private static void TestGetHostAddressesAsync(Func<Task<IPAddress[]>> getHostAddressesFunc)
|
||||
public Task Dns_GetHostAddressesAsync_IPString_Ok() => TestGetHostAddressesAsync(() => Dns.GetHostAddressesAsync(TestSettings.LocalIPString));
|
||||
|
||||
private static async Task TestGetHostAddressesAsync(Func<Task<IPAddress[]>> getHostAddressesFunc)
|
||||
{
|
||||
Task<IPAddress[]> hostEntryTask1 = getHostAddressesFunc();
|
||||
Task<IPAddress[]> hostEntryTask2 = getHostAddressesFunc();
|
||||
|
||||
Task.WaitAll(hostEntryTask1, hostEntryTask2);
|
||||
await TestSettings.WhenAllOrAnyFailedWithTimeout(hostEntryTask1, hostEntryTask2);
|
||||
|
||||
IPAddress[] list1 = hostEntryTask1.Result;
|
||||
IPAddress[] list2 = hostEntryTask2.Result;
|
||||
|
@ -17,37 +17,28 @@ namespace System.Net.NameResolution.Tests
|
||||
{
|
||||
IPAddress localIPAddress = await TestSettings.GetLocalIPAddress();
|
||||
|
||||
TestGetHostEntryAsync(() => Dns.GetHostEntryAsync(localIPAddress));
|
||||
await TestGetHostEntryAsync(() => Dns.GetHostEntryAsync(localIPAddress));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(TestSettings.LocalHost)]
|
||||
public void Dns_GetHostEntry_HostString_Ok(string hostName)
|
||||
{
|
||||
TestGetHostEntryAsync(() => Task.FromResult(Dns.GetHostEntry(hostName)));
|
||||
}
|
||||
public Task Dns_GetHostEntry_HostString_Ok(string hostName) => TestGetHostEntryAsync(() => Task.FromResult(Dns.GetHostEntry(hostName)));
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(TestSettings.LocalHost)]
|
||||
public void Dns_GetHostEntryAsync_HostString_Ok(string hostName)
|
||||
{
|
||||
TestGetHostEntryAsync(() => Dns.GetHostEntryAsync(hostName));
|
||||
}
|
||||
public Task Dns_GetHostEntryAsync_HostString_Ok(string hostName) => TestGetHostEntryAsync(() => Dns.GetHostEntryAsync(hostName));
|
||||
|
||||
[Fact]
|
||||
public void Dns_GetHostEntryAsync_IPString_Ok()
|
||||
{
|
||||
TestGetHostEntryAsync(() => Dns.GetHostEntryAsync(TestSettings.LocalIPString));
|
||||
}
|
||||
public Task Dns_GetHostEntryAsync_IPString_Ok() => TestGetHostEntryAsync(() => Dns.GetHostEntryAsync(TestSettings.LocalIPString));
|
||||
|
||||
private static void TestGetHostEntryAsync(Func<Task<IPHostEntry>> getHostEntryFunc)
|
||||
private static async Task TestGetHostEntryAsync(Func<Task<IPHostEntry>> getHostEntryFunc)
|
||||
{
|
||||
Task<IPHostEntry> hostEntryTask1 = getHostEntryFunc();
|
||||
Task<IPHostEntry> hostEntryTask2 = getHostEntryFunc();
|
||||
|
||||
Task.WaitAll(hostEntryTask1, hostEntryTask2);
|
||||
await TestSettings.WhenAllOrAnyFailedWithTimeout(hostEntryTask1, hostEntryTask2);
|
||||
|
||||
IPAddress[] list1 = hostEntryTask1.Result.AddressList;
|
||||
IPAddress[] list2 = hostEntryTask2.Result.AddressList;
|
||||
@ -63,16 +54,10 @@ namespace System.Net.NameResolution.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Dns_GetHostEntryAsync_NullStringHost_Fail()
|
||||
{
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => Dns.GetHostEntryAsync((string)null));
|
||||
}
|
||||
public Task Dns_GetHostEntryAsync_NullStringHost_Fail() => Assert.ThrowsAsync<ArgumentNullException>(() => Dns.GetHostEntryAsync((string)null));
|
||||
|
||||
[Fact]
|
||||
public async Task Dns_GetHostEntryAsync_NullIPAddressHost_Fail()
|
||||
{
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => Dns.GetHostEntryAsync((IPAddress)null));
|
||||
}
|
||||
public Task Dns_GetHostEntryAsync_NullIPAddressHost_Fail() => Assert.ThrowsAsync<ArgumentNullException>(() => Dns.GetHostEntryAsync((IPAddress)null));
|
||||
|
||||
public static IEnumerable<object[]> GetInvalidAddresses()
|
||||
{
|
||||
|
@ -17,6 +17,10 @@
|
||||
<Compile Include="GetHostAddressesTest.cs" />
|
||||
<Compile Include="LoggingTest.cs" />
|
||||
<Compile Include="TestSettings.cs" />
|
||||
<!-- Common test files -->
|
||||
<Compile Include="$(CommonTestPath)\System\Threading\Tasks\TaskTimeoutExtensions.cs">
|
||||
<Link>Common\System\Threading\Tasks\TaskTimeoutExtensions.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -17,6 +17,9 @@ namespace System.Net.NameResolution.Tests
|
||||
|
||||
public const string LocalIPString = "127.0.0.1";
|
||||
|
||||
// Timeout values in milliseconds.
|
||||
public const int PassingTestTimeout = 30_000;
|
||||
|
||||
public static Task<IPAddress> GetLocalIPAddress()
|
||||
{
|
||||
return ResolveHost(TestSettings.LocalHost, TestSettings.AddressFamily);
|
||||
@ -33,6 +36,8 @@ namespace System.Net.NameResolution.Tests
|
||||
}
|
||||
}
|
||||
|
||||
public static Task WhenAllOrAnyFailedWithTimeout(params Task[] tasks) => tasks.WhenAllOrAnyFailed(PassingTestTimeout);
|
||||
|
||||
private static async Task<IPAddress> ResolveHost(string host, AddressFamily family)
|
||||
{
|
||||
var hostEntry = await Dns.GetHostEntryAsync(host);
|
||||
|
Reference in New Issue
Block a user