diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2022-10-19 00:53:54 +0300 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2022-10-19 00:53:54 +0300 |
commit | af5b37cd54cfdd15f14f854eafc34ed9c346ddde (patch) | |
tree | 04427f843f5bfc2de972817ba8eb8127ed30e301 | |
parent | c672e901c8819a22123da5c0cb7295d914e70627 (diff) | |
parent | c35dae276d7b684200166dfab58fefaebf55b9a7 (diff) |
Merge in 'release/6.0' changes
5 files changed, 95 insertions, 1 deletions
diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs index db93bcd06c4..a0a95604795 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs @@ -14,7 +14,7 @@ namespace System // do it in a way that failures don't cascade. // - private static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); + public static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); public static bool IsOpenSUSE => IsDistroAndVersion("opensuse"); public static bool IsUbuntu => IsDistroAndVersion("ubuntu"); public static bool IsDebian => IsDistroAndVersion("debian"); @@ -32,6 +32,7 @@ namespace System public static bool IsSLES => IsDistroAndVersion("sles"); public static bool IsTizen => IsDistroAndVersion("tizen"); public static bool IsFedora => IsDistroAndVersion("fedora"); + public static bool IsLinuxBionic => IsBionic(); // OSX family public static bool IsOSXLike => IsOSX || IsiOS || IstvOS || IsMacCatalyst; @@ -171,6 +172,21 @@ namespace System } } + /// <summary> + /// Assume that Android environment variables but Linux OS mean Android libc + /// </summary> + private static bool IsBionic() + { + if (IsLinux) + { + if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("ANDROID_STORAGE"))) + { + return true; + } + } + return false; + } + private static DistroInfo GetDistroInfo() { DistroInfo result = new DistroInfo(); diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index f8e0a06b7d2..54963a9de9b 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -49,6 +49,7 @@ namespace System public static bool IsArmOrArm64Process => IsArmProcess || IsArm64Process; public static bool IsNotArmNorArm64Process => !IsArmOrArm64Process; public static bool IsX86Process => RuntimeInformation.ProcessArchitecture == Architecture.X86; + public static bool IsX64Process => RuntimeInformation.ProcessArchitecture == Architecture.X64; public static bool IsArgIteratorSupported => IsMonoRuntime || (IsWindows && IsNotArmProcess); public static bool IsArgIteratorNotSupported => !IsArgIteratorSupported; public static bool Is32BitProcess => IntPtr.Size == 4; diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c index 234517d8c1f..af1a4a59454 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c @@ -525,6 +525,7 @@ void GlobalizationNative_InitICUFunctions(void* icuuc, void* icuin, const char* ValidateICUDataCanLoad(); InitializeVariableMaxAndTopPointers(symbolVersion); + InitializeUColClonePointers(symbolVersion); } #undef PER_FUNCTION_BLOCK diff --git a/src/libraries/System.Globalization/tests/IcuAppLocal/IcuAppLocal.Tests.csproj b/src/libraries/System.Globalization/tests/IcuAppLocal/IcuAppLocal.Tests.csproj new file mode 100644 index 00000000000..2030aa49789 --- /dev/null +++ b/src/libraries/System.Globalization/tests/IcuAppLocal/IcuAppLocal.Tests.csproj @@ -0,0 +1,25 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks> + <TestRuntime>true</TestRuntime> + <IncludeRemoteExecutor>true</IncludeRemoteExecutor> + </PropertyGroup> + <ItemGroup> + <Compile Include="IcuAppLocal.cs" /> + </ItemGroup> + + <ItemGroup> + <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" /> + + <!-- + We define this switch dynamically during the runtime using RemoteExecutor. + The reason is, if we enable ICU app-local here, this test will compile and run + on all supported OSs even the ICU NuGet package not have native bits support such OSs. + Note, it doesn't matter if we have test case conditioned to not run on such OSs, because + the test has to start running first before filtering the test cases and the globalization + code will run and fail fast at that time. + + <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" /> + --> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/src/libraries/System.Globalization/tests/IcuAppLocal/IcuAppLocal.cs b/src/libraries/System.Globalization/tests/IcuAppLocal/IcuAppLocal.cs new file mode 100644 index 00000000000..aa0a0df938c --- /dev/null +++ b/src/libraries/System.Globalization/tests/IcuAppLocal/IcuAppLocal.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.DotNet.RemoteExecutor; +using System.Diagnostics; +using System.Reflection; +using Xunit; + +namespace System.Globalization.Tests +{ + public class IcuAppLocalTests + { + private static bool SupportsIcuPackageDownload => RemoteExecutor.IsSupported && + ((PlatformDetection.IsWindows && !PlatformDetection.IsArmProcess) || + (PlatformDetection.IsLinux && (PlatformDetection.IsX64Process || PlatformDetection.IsArm64Process) && + !PlatformDetection.IsAlpine && !PlatformDetection.IsLinuxBionic)); + + + [ConditionalFact(nameof(SupportsIcuPackageDownload))] + public void TestIcuAppLocal() + { + // We define this switch dynamically during the runtime using RemoteExecutor. + // The reason is, if we enable ICU app-local here, this test will compile and run + // on all supported OSs even the ICU NuGet package not have native bits support such OSs. + // Note, it doesn't matter if we have test case conditioned to not run on such OSs, because + // the test has to start running first before filtering the test cases and the globalization + // code will run and fail fast at that time. + + ProcessStartInfo psi = new ProcessStartInfo(); + psi.Environment.Add("DOTNET_SYSTEM_GLOBALIZATION_APPLOCALICU", "68.2.0.9"); + + RemoteExecutor.Invoke(() => + { + // Ensure initializing globalization code before checking the ICU version. + CultureInfo ci = CultureInfo.GetCultureInfo("en-US"); + + Type? interopGlobalization = Type.GetType("Interop+Globalization, System.Private.CoreLib"); + Assert.NotNull(interopGlobalization); + + MethodInfo? methodInfo = interopGlobalization.GetMethod("GetICUVersion", BindingFlags.NonPublic | BindingFlags.Static); + Assert.NotNull(methodInfo); + + // Assert the ICU version 0x44020009 is 68.2.0.9 + Assert.Equal(0x44020009, (int)methodInfo.Invoke(null, null)); + + // Now call globalization API to ensure the binding working without any problem. + Assert.Equal(-1, ci.CompareInfo.Compare("sample\u0000", "Sample\u0000", CompareOptions.IgnoreSymbols)); + }, new RemoteInvokeOptions { StartInfo = psi }).Dispose(); + } + } +} |