From: Michal Strehovský Date: Fri, 29 Jul 2022 04:11:34 +0000 (+0900) Subject: Get more libraries tests running with NativeAOT (#72917) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~7459 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d1e1af62e26ec040c452548fc0221249ac086d0;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Get more libraries tests running with NativeAOT (#72917) * MetadataLoadContext tests need more work for single file testing in general. Filed a separate issue. * S.R.Intrinsics is now clean. Running it on NativeAOT found good JIT bugs (#72081, #72158). Promoting to a smoke test. * S.Drawing.Primitives was testing DataContractSerializer for whatever reason. Marked that as aggresive trimming incompatible. This wouldn't be covered by #72910. * Made S.R.InteropServices.ComDisabled fully pass by fixing exceptions we throw. * A couple tests won't ever make sense to run on NativeAOT so removed them from triage area. --- diff --git a/eng/pipelines/runtime-extra-platforms-other.yml b/eng/pipelines/runtime-extra-platforms-other.yml index c201d11..a3b0116 100644 --- a/eng/pipelines/runtime-extra-platforms-other.yml +++ b/eng/pipelines/runtime-extra-platforms-other.yml @@ -91,7 +91,7 @@ jobs: isSingleFile: true nameSuffix: NativeAOT_Libs_Passing buildArgs: -s clr.aot+libs+libs.tests -c $(_BuildConfig) /p:TestNativeAot=true /p:ArchiveTests=true - timeoutInMinutes: 180 + timeoutInMinutes: 240 # extra steps, run tests extraStepsTemplate: /eng/pipelines/libraries/helix.yml extraStepsParameters: diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs index 319f48a..3e68bc3 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs @@ -614,7 +614,7 @@ namespace System.Runtime.InteropServices { if (s_globalInstanceForMarshalling == null) { - throw new InvalidOperationException(SR.InvalidOperation_ComInteropRequireComWrapperInstance); + throw new NotSupportedException(SR.InvalidOperation_ComInteropRequireComWrapperInstance); } return s_globalInstanceForMarshalling.GetOrCreateComInterfaceForObject(instance, CreateComInterfaceFlags.None); @@ -640,7 +640,7 @@ namespace System.Runtime.InteropServices { if (s_globalInstanceForMarshalling == null) { - throw new InvalidOperationException(SR.InvalidOperation_ComInteropRequireComWrapperInstance); + throw new NotSupportedException(SR.InvalidOperation_ComInteropRequireComWrapperInstance); } return s_globalInstanceForMarshalling.GetOrCreateObjectForComInstance(externalComObject, CreateObjectFlags.Unwrap); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs index 1266693..37a2728 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Com.cs @@ -28,14 +28,14 @@ namespace System.Runtime.InteropServices [EditorBrowsable(EditorBrowsableState.Never)] public static IntPtr CreateAggregatedObject(IntPtr pOuter, object o) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [RequiresUnreferencedCode("Built-in COM support is not trim compatible", Url = "https://aka.ms/dotnet-illink/com")] [SupportedOSPlatform("windows")] public static object BindToMoniker(string monikerName) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } public static void CleanupUnusedObjectsInCurrentContext() @@ -45,32 +45,32 @@ namespace System.Runtime.InteropServices [SupportedOSPlatform("windows")] public static IntPtr CreateAggregatedObject(IntPtr pOuter, T o) where T : notnull { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] [EditorBrowsable(EditorBrowsableState.Never)] public static object? CreateWrapperOfType(object? o, Type t) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] public static TWrapper CreateWrapperOfType(T? o) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] public static void ChangeWrapperHandleStrength(object otp, bool fIsWeak) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] public static int FinalReleaseComObject(object o) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] @@ -94,7 +94,7 @@ namespace System.Runtime.InteropServices [EditorBrowsable(EditorBrowsableState.Never)] public static IntPtr GetComInterfaceForObject(object o, Type T, CustomQueryInterfaceMode mode) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] @@ -106,7 +106,7 @@ namespace System.Runtime.InteropServices [SupportedOSPlatform("windows")] public static object? GetComObjectData(object obj, object key) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] @@ -302,7 +302,7 @@ namespace System.Runtime.InteropServices [SupportedOSPlatform("windows")] public static object GetTypedObjectForIUnknown(IntPtr pUnk, Type t) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] @@ -364,33 +364,33 @@ namespace System.Runtime.InteropServices [EditorBrowsable(EditorBrowsableState.Never)] public static T GetObjectForNativeVariant(IntPtr pSrcNativeVariant) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] [EditorBrowsable(EditorBrowsableState.Never)] public static object?[] GetObjectsForNativeVariants(IntPtr aSrcNativeVariant, int cVars) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] [EditorBrowsable(EditorBrowsableState.Never)] public static T[] GetObjectsForNativeVariants(IntPtr aSrcNativeVariant, int cVars) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] public static int GetStartComSlot(Type t) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] public static int GetEndComSlot(Type t) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } internal static Type? GetTypeFromCLSID(Guid clsid, string? server, bool throwOnError) @@ -401,13 +401,13 @@ namespace System.Runtime.InteropServices [SupportedOSPlatform("windows")] public static string GetTypeInfoName(ITypeInfo typeInfo) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] public static object GetUniqueObjectForIUnknown(IntPtr unknown) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } public static bool IsComObject(object o) @@ -432,13 +432,13 @@ namespace System.Runtime.InteropServices [SupportedOSPlatform("windows")] public static int ReleaseComObject(object o) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } [SupportedOSPlatform("windows")] public static bool SetComObjectData(object obj, object key, object? data) { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + throw new NotSupportedException(SR.PlatformNotSupported_ComInterop); } } } diff --git a/src/libraries/System.Drawing.Primitives/tests/ColorTests.cs b/src/libraries/System.Drawing.Primitives/tests/ColorTests.cs index 956dcb7..c1267aa 100644 --- a/src/libraries/System.Drawing.Primitives/tests/ColorTests.cs +++ b/src/libraries/System.Drawing.Primitives/tests/ColorTests.cs @@ -492,7 +492,7 @@ namespace System.Drawing.Primitives.Tests Assert.Equal(!expected, right != left); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))] public void DebuggerAttributesAreValid() { DebuggerAttributes.ValidateDebuggerDisplayReferences(Color.Aquamarine); diff --git a/src/libraries/System.Drawing.Primitives/tests/DataContractSerializerTests.cs b/src/libraries/System.Drawing.Primitives/tests/DataContractSerializerTests.cs index 037e05a..b1c96b1 100644 --- a/src/libraries/System.Drawing.Primitives/tests/DataContractSerializerTests.cs +++ b/src/libraries/System.Drawing.Primitives/tests/DataContractSerializerTests.cs @@ -12,6 +12,7 @@ using System.Drawing; namespace System.Drawing.Primitives.Tests { + [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] public class DataContractSerializerTests { [Fact] diff --git a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.ComDisabled.UnitTests/System/Runtime/InteropServices/Marshal/MarshalComDisabledTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.ComDisabled.UnitTests/System/Runtime/InteropServices/Marshal/MarshalComDisabledTests.cs index 57a5887..fafcc5a 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.ComDisabled.UnitTests/System/Runtime/InteropServices/Marshal/MarshalComDisabledTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.ComDisabled.UnitTests/System/Runtime/InteropServices/Marshal/MarshalComDisabledTests.cs @@ -10,6 +10,7 @@ namespace System.Runtime.InteropServices.Tests public partial class MarshalComDisabledTests { [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/72914", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void GetTypeFromCLSID_ThrowsNotSupportedException() { Assert.Throws(() => Marshal.GetTypeFromCLSID(Guid.Empty)); @@ -67,12 +68,14 @@ namespace System.Runtime.InteropServices.Tests } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/72911", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void GetNativeVariantForObject_ThrowsNotSupportedException() { Assert.Throws(() => Marshal.GetNativeVariantForObject(99, IntPtr.Zero)); } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/72911", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void GetNativeVariantForObject_T_ThrowsNotSupportedException() { Assert.Throws(() => Marshal.GetNativeVariantForObject(99, IntPtr.Zero)); @@ -81,6 +84,7 @@ namespace System.Runtime.InteropServices.Tests public struct NativeVariant{} [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/72911", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void GetObjectForNativeVariant_ThrowsNotSupportedException() { NativeVariant variant = new NativeVariant(); @@ -100,6 +104,7 @@ namespace System.Runtime.InteropServices.Tests public struct NativeVariant_T{} [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/72911", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void GetObjectForNativeVariant_T_ThrowsNotSupportedException() { NativeVariant_T variant = new NativeVariant_T(); diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index af3c4a5..c5c2a96 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -414,12 +414,23 @@ + + + + + + + + + + + + - @@ -477,7 +488,6 @@ - @@ -524,7 +534,6 @@ - @@ -538,7 +547,6 @@ - @@ -546,10 +554,7 @@ - - - @@ -564,12 +569,6 @@ - - - - - - @@ -585,6 +584,7 @@ + diff --git a/src/tests/nativeaot/SmokeTests/ComWrappers/ComWrappers.cs b/src/tests/nativeaot/SmokeTests/ComWrappers/ComWrappers.cs index b62eca4..1d56b5b 100644 --- a/src/tests/nativeaot/SmokeTests/ComWrappers/ComWrappers.cs +++ b/src/tests/nativeaot/SmokeTests/ComWrappers/ComWrappers.cs @@ -83,7 +83,7 @@ namespace ComWrappersTests CaptureComPointer(target); throw new Exception("Cannot work without ComWrappers.RegisterForMarshalling called"); } - catch (InvalidOperationException) + catch (NotSupportedException) { } }