From 94ce85409a7adf52af7d3964bdd8bfcf46114522 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 13 Mar 2025 16:11:36 -0500 Subject: [PATCH 01/11] [coreclr] run Mono.Android-Tests This is WIP. --- .../automation/yaml-templates/stage-package-tests.yaml | 10 ++++++++++ build-tools/scripts/TestApkFeeds.props | 8 ++++++++ build-tools/scripts/TestApks.targets | 2 +- samples/NativeAOT/NativeAOT.csproj | 7 +------ .../Mono.Android-Tests/Mono.Android.NET-Tests.csproj | 3 +++ .../NUnitInstrumentation.cs | 4 ++++ 6 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 build-tools/scripts/TestApkFeeds.props diff --git a/build-tools/automation/yaml-templates/stage-package-tests.yaml b/build-tools/automation/yaml-templates/stage-package-tests.yaml index d4fcdecd5ba..b858b9a2a94 100644 --- a/build-tools/automation/yaml-templates/stage-package-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-package-tests.yaml @@ -198,6 +198,16 @@ stages: artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab artifactFolder: $(DotNetTargetFramework)-AotLlvm + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml + parameters: + configuration: $(XA.Build.Configuration) + testName: Mono.Android.NET_Tests-CoreCLR + project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj + testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)CoreCLR.xml + extraBuildArgs: -p:TestsFlavor=CoreCLR -p:UseMonoRuntime=false -p:AndroidEnableMarshalMethods=false + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab + artifactFolder: $(DotNetTargetFramework)-CoreCLR + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml parameters: configuration: $(XA.Build.Configuration) diff --git a/build-tools/scripts/TestApkFeeds.props b/build-tools/scripts/TestApkFeeds.props new file mode 100644 index 00000000000..d219c15332e --- /dev/null +++ b/build-tools/scripts/TestApkFeeds.props @@ -0,0 +1,8 @@ + + + + <_NuGetFolderOnCI>$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\nuget-unsigned + $(_NuGetFolderOnCI) + <_FastDeploymentDiagnosticLogging>true + + diff --git a/build-tools/scripts/TestApks.targets b/build-tools/scripts/TestApks.targets index 091089c0a0e..fa028e8c3bb 100644 --- a/build-tools/scripts/TestApks.targets +++ b/build-tools/scripts/TestApks.targets @@ -18,7 +18,7 @@ - android-arm64;android-x86;android-x64; + android-arm64;android-x86;android-x64; 29 arm64-v8a x86_64 diff --git a/samples/NativeAOT/NativeAOT.csproj b/samples/NativeAOT/NativeAOT.csproj index 8b9148c5a88..ef3e78dab5d 100644 --- a/samples/NativeAOT/NativeAOT.csproj +++ b/samples/NativeAOT/NativeAOT.csproj @@ -13,11 +13,6 @@ true - - - <_NuGetFolderOnCI>..\..\bin\Build$(Configuration)\nuget-unsigned - $(_NuGetFolderOnCI) - <_FastDeploymentDiagnosticLogging>true - + \ No newline at end of file diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj index 8690e4b8e10..6d42f4b5d04 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj @@ -1,6 +1,7 @@ + $(DotNetAndroidTargetFramework) @@ -22,6 +23,8 @@ IL2037 true + $(DefineConstants);CORECLR + $(DefineConstants);NATIVEAOT DotNetIgnore + + $(ExcludeCategories):CoreCLRIgnore $(ExcludeCategories):LLVMIgnore $(ExcludeCategories):InetAccess:NetworkInterfaces From c9ec62d1b7cf12792707a7ec45ac11d3a426e326 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 23 Apr 2025 16:20:41 -0500 Subject: [PATCH 03/11] Ignore SSLTest Context: https://github.com/dotnet/android/issues/10069 TODO comments --- .../Mono.Android-Tests/Java.Interop/JnienvTest.cs | 2 +- .../Mono.Android-Tests/Mono.Android.NET-Tests.csproj | 4 ++-- .../Mono.Android-Tests/System.Net/SslTest.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs index 8ba38903f32..45f4b74f1b8 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs @@ -251,7 +251,7 @@ public void CreateTypeWithExportedMethods () } [Test] - [Category ("CoreCLRIgnore")] //TODO: Fix this test for CoreCLR + [Category ("CoreCLRIgnore")] //TODO: https://github.com/dotnet/android/issues/10069 public void ActivatedDirectObjectSubclassesShouldBeRegistered () { if (Build.VERSION.SdkInt <= BuildVersionCodes.GingerbreadMr1) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj index 938780a1581..f1dbc95e75c 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj @@ -32,8 +32,8 @@ NetworkInterfaces excluded: https://github.com/dotnet/runtime/issues/75155 --> DotNetIgnore - - $(ExcludeCategories):CoreCLRIgnore + + $(ExcludeCategories):CoreCLRIgnore:SSL $(ExcludeCategories):LLVMIgnore $(ExcludeCategories):InetAccess:NetworkInterfaces diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/System.Net/SslTest.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/System.Net/SslTest.cs index ba104387632..fb497006bf3 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/System.Net/SslTest.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/System.Net/SslTest.cs @@ -9,8 +9,8 @@ using NUnit.Framework; namespace System.NetTests { - - [TestFixture, Category ("InetAccess")] + // TODO: https://github.com/dotnet/android/issues/10069 + [TestFixture, Category ("InetAccess"), Category ("SSL")] public class SslTest { bool ShouldIgnoreException (WebException wex) From 1cb5cfbcdd189c81d76c1fbe39a980fb4bc6b0c5 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 23 Apr 2025 16:31:27 -0500 Subject: [PATCH 04/11] Ignore a few more tests --- .../Mono.Android-Tests/Mono.Android.NET-Tests.csproj | 2 +- .../Xamarin.Android.Net/AndroidClientHandlerTests.cs | 1 + .../AndroidMessageHandlerNegotiateAuthenticationTests.cs | 2 +- .../Xamarin.Android.Net/AndroidMessageHandlerTests.cs | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj index f1dbc95e75c..7c7d68b60d3 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj @@ -33,7 +33,7 @@ --> DotNetIgnore - $(ExcludeCategories):CoreCLRIgnore:SSL + $(ExcludeCategories):CoreCLRIgnore:SSL:NTLM $(ExcludeCategories):LLVMIgnore $(ExcludeCategories):InetAccess:NetworkInterfaces diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs index effae7a832b..a41040b9223 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs @@ -46,6 +46,7 @@ namespace Xamarin.Android.NetTests { [Category("InetAccess")] + [Category ("SSL")] // TODO: https://github.com/dotnet/android/issues/10069 public abstract class HttpClientHandlerTestBase { protected abstract HttpMessageHandler CreateHandler (); diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerNegotiateAuthenticationTests.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerNegotiateAuthenticationTests.cs index f767c456cb9..8be6bef6896 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerNegotiateAuthenticationTests.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerNegotiateAuthenticationTests.cs @@ -13,7 +13,7 @@ namespace Xamarin.Android.NetTests { // Important: We expect the Negotiate authentication feature to be enabled in all of these tests because we set $(AndroidUseNegotiateAuthentication)=true // in the Mono.Android.NET-Tests.csproj file. [TestFixture] - [Category ("InetAccess")] + [Category ("InetAccess"), Category ("NTLM")] // TODO: https://github.com/dotnet/android/issues/10069 public sealed class AndroidMessageHandlerNegotiateAuthenticationTests { // Negotiate authentication is available for Android since .NET 7 diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerTests.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerTests.cs index 5b4dceaa775..bd3b6088bfc 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerTests.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerTests.cs @@ -14,6 +14,7 @@ namespace Xamarin.Android.NetTests { [TestFixture] + [Category ("SSL")] // TODO: https://github.com/dotnet/android/issues/10069 public class AndroidMessageHandlerTests : AndroidHandlerTestBase { protected override HttpMessageHandler CreateHandler () From 3c5a1636368169bfbeb01542bfcd42c5a395fe4e Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 23 Apr 2025 16:40:14 -0500 Subject: [PATCH 05/11] `TestApkFeeds.props` no longer needed --- build-tools/scripts/TestApkFeeds.props | 8 -------- samples/NativeAOT/NativeAOT.csproj | 3 --- .../Mono.Android-Tests/Mono.Android.NET-Tests.csproj | 1 - 3 files changed, 12 deletions(-) delete mode 100644 build-tools/scripts/TestApkFeeds.props diff --git a/build-tools/scripts/TestApkFeeds.props b/build-tools/scripts/TestApkFeeds.props deleted file mode 100644 index d219c15332e..00000000000 --- a/build-tools/scripts/TestApkFeeds.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - <_NuGetFolderOnCI>$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\nuget-unsigned - $(_NuGetFolderOnCI) - <_FastDeploymentDiagnosticLogging>true - - diff --git a/samples/NativeAOT/NativeAOT.csproj b/samples/NativeAOT/NativeAOT.csproj index ef3e78dab5d..d16ef4b8056 100644 --- a/samples/NativeAOT/NativeAOT.csproj +++ b/samples/NativeAOT/NativeAOT.csproj @@ -12,7 +12,4 @@ true - - - \ No newline at end of file diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj index 7c7d68b60d3..66b0d98b58c 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj @@ -1,7 +1,6 @@ - $(DotNetAndroidTargetFramework) From a0c3433c8133b449f0d6aa5b127fdefdb79e8761 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 24 Apr 2025 08:23:06 -0500 Subject: [PATCH 06/11] Ignore `CreateTypeWithExportedMethods()` --- .../Java.Interop/JnienvTest.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs index 45f4b74f1b8..d3e6359e01d 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs @@ -239,14 +239,16 @@ public void SetField_PermitNullValues () } [Test] - public void CreateTypeWithExportedMethods () + [Category ("CoreCLRIgnore")] //TODO: https://github.com/dotnet/android/issues/10069 + public void CreateTypeWithExportedMethods() { - using (var e = new ContainsExportedMethods ()) { - e.Exported (); - Assert.AreEqual (1, e.Count); - IntPtr m = JNIEnv.GetMethodID (e.Class.Handle, "Exported", "()V"); - JNIEnv.CallVoidMethod (e.Handle, m); - Assert.AreEqual (2, e.Count); + using (var e = new ContainsExportedMethods()) + { + e.Exported(); + Assert.AreEqual(1, e.Count); + IntPtr m = JNIEnv.GetMethodID(e.Class.Handle, "Exported", "()V"); + JNIEnv.CallVoidMethod(e.Handle, m); + Assert.AreEqual(2, e.Count); } } From c51ee69c5ccefe6d3320fb0953da0e07c1f30c30 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 24 Apr 2025 08:23:46 -0500 Subject: [PATCH 07/11] Undo changes --- samples/NativeAOT/NativeAOT.csproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/samples/NativeAOT/NativeAOT.csproj b/samples/NativeAOT/NativeAOT.csproj index d16ef4b8056..8b9148c5a88 100644 --- a/samples/NativeAOT/NativeAOT.csproj +++ b/samples/NativeAOT/NativeAOT.csproj @@ -12,4 +12,12 @@ true + + + + <_NuGetFolderOnCI>..\..\bin\Build$(Configuration)\nuget-unsigned + $(_NuGetFolderOnCI) + <_FastDeploymentDiagnosticLogging>true + + \ No newline at end of file From 7205ed0147446a73035f20838fee0e6a65eb3294 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 24 Apr 2025 08:24:11 -0500 Subject: [PATCH 08/11] Update JnienvTest.cs --- .../Mono.Android-Tests/Java.Interop/JnienvTest.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs index d3e6359e01d..f7c93e8cd84 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs @@ -240,15 +240,14 @@ public void SetField_PermitNullValues () [Test] [Category ("CoreCLRIgnore")] //TODO: https://github.com/dotnet/android/issues/10069 - public void CreateTypeWithExportedMethods() + public void CreateTypeWithExportedMethods () { - using (var e = new ContainsExportedMethods()) - { - e.Exported(); - Assert.AreEqual(1, e.Count); - IntPtr m = JNIEnv.GetMethodID(e.Class.Handle, "Exported", "()V"); - JNIEnv.CallVoidMethod(e.Handle, m); - Assert.AreEqual(2, e.Count); + using (var e = new ContainsExportedMethods ()) { + e.Exported (); + Assert.AreEqual (1, e.Count); + IntPtr m = JNIEnv.GetMethodID (e.Class.Handle, "Exported", "()V"); + JNIEnv.CallVoidMethod (e.Handle, m); + Assert.AreEqual (2, e.Count); } } From 492d177d45e2ea6847859b67edfff975a27e080d Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 24 Apr 2025 10:20:06 -0500 Subject: [PATCH 09/11] GCBridge, RuntimeConfig categories --- .../Mono.Android-Tests/Java.Interop/JnienvTest.cs | 2 +- .../Mono.Android-Tests/Mono.Android.NET-Tests.csproj | 2 +- .../Mono.Android-Tests/System/AppContextTests.cs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs index f7c93e8cd84..e28317387d4 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs @@ -428,7 +428,7 @@ public void ManagedToJavaTypeMapping () Assert.AreEqual (null, m, "`JnienvTest` does *not* subclass Java.Lang.Object, it should *not* be in the typemap!"); } - [Test] + [Test, Category ("GCBridge")] public void DoNotLeakWeakReferences () { GC.Collect (); diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj index 66b0d98b58c..b56fdfa8857 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj @@ -32,7 +32,7 @@ --> DotNetIgnore - $(ExcludeCategories):CoreCLRIgnore:SSL:NTLM + $(ExcludeCategories):CoreCLRIgnore:SSL:NTLM:GCBridge:RuntimeConfig $(ExcludeCategories):LLVMIgnore $(ExcludeCategories):InetAccess:NetworkInterfaces diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/System/AppContextTests.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/System/AppContextTests.cs index 8b086b5011a..4cfd9856eed 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/System/AppContextTests.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/System/AppContextTests.cs @@ -6,6 +6,7 @@ namespace SystemTests { [TestFixture] + [Category ("RuntimeConfig")] //TODO: https://github.com/dotnet/android/issues/10069 public class AppContextTests { static readonly object [] GetDataSource = new object [] { From 179991bdf7b0884a541b8cf419693140c21d6f3c Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 24 Apr 2025 10:34:26 -0500 Subject: [PATCH 10/11] Ignore InnerExceptionIsSet --- .../Mono.Android-Tests/System/ExceptionTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/System/ExceptionTest.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/System/ExceptionTest.cs index 017308edf7c..96cf8a921fd 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/System/ExceptionTest.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/System/ExceptionTest.cs @@ -29,6 +29,7 @@ static Java.Lang.Throwable CreateJavaProxyThrowable (Exception e) } [Test] + [Category ("CoreCLRIgnore")] //TODO: https://github.com/dotnet/android/issues/10069 [RequiresUnreferencedCode ("Tests trimming unsafe features")] public void InnerExceptionIsSet () { From 17b9f10236cb2c7ab7e502989b0f1676fa5404e7 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 24 Apr 2025 10:37:36 -0500 Subject: [PATCH 11/11] Ignore JnienvCreateInstance_RegistersMultipleInstances --- .../Mono.Android-Tests/Java.Lang/ObjectTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Lang/ObjectTest.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Lang/ObjectTest.cs index e6a051b170a..1d656e434a9 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Lang/ObjectTest.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Lang/ObjectTest.cs @@ -66,6 +66,7 @@ static MethodInfo MakeGenericMethod (MethodInfo method, Type type) => } [Test] + [Category ("CoreCLRIgnore")] //TODO: https://github.com/dotnet/android/issues/10069 public void JnienvCreateInstance_RegistersMultipleInstances () { using (var adapter = new CreateInstance_OverrideAbsListView_Adapter (Application.Context)) {