From 1331aa215308b6c80e9348f80ccbcf57e639a27f Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Fri, 10 Nov 2023 15:31:47 -0500 Subject: [PATCH] [tests] Better support running on arm64-v8a devices (#8492) MSBuild device tests that specified a subset of supported ABIs can fail depending on your target device/emulator. These tests have been updated to use the default ABI of the attached device, which is determined during test setup. Tests which explicitly specify the full set of supported ABIs have been left unchanged. --- .../Tests/AotProfileTests.cs | 2 +- .../Tests/DebuggingTest.cs | 8 ++++---- .../Tests/InstallAndRunTests.cs | 6 +++--- .../Tests/InstallTests.cs | 18 +++++++++--------- .../Tests/MonoAndroidExportTest.cs | 2 +- .../Tests/SystemApplicationTests.cs | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs b/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs index b63b3f9d16c..bbc15d40d64 100644 --- a/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs @@ -31,7 +31,7 @@ public void BuildBasicApplicationAndAotProfileIt () IsRelease = true, AotAssemblies = false, }; - proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64"); + proj.SetAndroidSupportedAbis (DeviceAbi); // TODO: only needed in .NET 6+ // See https://github.com/dotnet/runtime/issues/56989 diff --git a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs index 04368461f3b..41e8638e3cb 100755 --- a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs @@ -59,7 +59,7 @@ public void ApplicationRunsWithoutDebugger ([Values (false, true)] bool isReleas IsRelease = isRelease, }; if (isRelease || !TestEnvironment.CommercialBuildAvailable) { - proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64"); + proj.SetAndroidSupportedAbis (DeviceAbi); } proj.SetDefaultTargetDevice (); if (isRelease) { @@ -91,7 +91,7 @@ public void ClassLibraryMainLauncherRuns ([Values (true, false)] bool preloadAss ProjectName = "MyApp", }; if (!TestEnvironment.CommercialBuildAvailable) { - app.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64"); + app.SetAndroidSupportedAbis (DeviceAbi); } app.SetDefaultTargetDevice (); app.SetProperty ("AndroidEnablePreloadAssemblies", preloadAssemblies.ToString ()); @@ -192,7 +192,7 @@ public void CustomApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, st IsRelease = false, AndroidFastDeploymentType = fastDevType, }; - proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64"); + proj.SetAndroidSupportedAbis (DeviceAbi); proj.SetProperty ("EmbedAssembliesIntoApk", embedAssemblies.ToString ()); proj.SetProperty ("AndroidPackageFormat", packageFormat); proj.SetDefaultTargetDevice (); @@ -434,7 +434,7 @@ public Foo () app.SetProperty ("AndroidPackageFormat", packageFormat); app.MainPage = app.MainPage.Replace ("InitializeComponent ();", "InitializeComponent (); new Foo ();"); app.AddReference (lib); - app.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64"); + app.SetAndroidSupportedAbis (DeviceAbi); app.SetProperty (KnownProperties._AndroidAllowDeltaInstall, allowDeltaInstall.ToString ()); app.SetDefaultTargetDevice (); using (var libBuilder = CreateDllBuilder (Path.Combine (path, lib.ProjectName))) diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index 84473a66f79..d6adcf7366d 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -173,7 +173,7 @@ public void SmokeTestBuildAndRunWithSpecialCharacters (string testName) ProjectName = testName, IsRelease = true, }; - proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64"); + proj.SetAndroidSupportedAbis (DeviceAbi); proj.SetDefaultTargetDevice (); using (var builder = CreateApkBuilder (Path.Combine (rootPath, proj.ProjectName))){ Assert.IsTrue (builder.Install (proj), "Install should have succeeded."); @@ -536,7 +536,7 @@ public void ResourceDesignerWithNuGetReference ([Values ("net8.0-android")] stri ProjectName = "App1", IsRelease = true, }; - proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64"); + proj.SetAndroidSupportedAbis (DeviceAbi); proj.OtherBuildItems.Add (new BuildItem ("None", "NuGet.config") { TextContent = () => @" @@ -684,7 +684,7 @@ public MyLayout (Android.Content.Context context, Android.Util.IAttributeSet att public void CheckXamarinFormsAppDeploysAndAButtonWorks () { var proj = new XamarinFormsAndroidApplicationProject (); - proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64"); + proj.SetAndroidSupportedAbis (DeviceAbi); var builder = CreateApkBuilder (); Assert.IsTrue (builder.Build (proj), "Build should have succeeded."); diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs index f84aaaf5328..f25d948b44c 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs @@ -37,7 +37,7 @@ public void ReInstallIfUserUninstalled ([Values (false, true)] bool isRelease) IsRelease = isRelease, }; if (isRelease) { - proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64"); + proj.SetAndroidSupportedAbis (DeviceAbi); } using (var builder = CreateApkBuilder ()) { Assert.IsTrue (builder.Build (proj)); @@ -67,7 +67,7 @@ public void InstallAndUnInstall ([Values (false, true)] bool isRelease) if (isRelease) { // Set debuggable=true to allow run-as command usage with a release build proj.AndroidManifest = proj.AndroidManifest.Replace ("