Skip to content

Commit

Permalink
[tests] Better support running on arm64-v8a devices (#8492)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pjcollins authored Nov 10, 2023
1 parent 5daf102 commit 1331aa2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ());
Expand Down Expand Up @@ -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 ();
Expand Down Expand Up @@ -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)))
Expand Down
6 changes: 3 additions & 3 deletions tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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 = () => @"<?xml version='1.0' encoding='utf-8'?>
<configuration>
Expand Down Expand Up @@ -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.");
Expand Down
18 changes: 9 additions & 9 deletions tests/MSBuildDeviceIntegration/Tests/InstallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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 ("<application ", "<application android:debuggable=\"true\" ");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis (DeviceAbi);
}
using (var builder = CreateApkBuilder ()) {
Assert.IsTrue (builder.Build (proj));
Expand Down Expand Up @@ -97,7 +97,7 @@ public void ChangeKeystoreRedeploy ()
var proj = new XamarinAndroidApplicationProject () {
PackageName = "com.xamarin.keytest"
};
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis (DeviceAbi);
using (var builder = CreateApkBuilder ()) {
// Use the default debug.keystore XA generates
Assert.IsTrue (builder.Install (proj), "first install should succeed.");
Expand Down Expand Up @@ -128,7 +128,7 @@ public void SwitchConfigurationsShouldRedeploy ()
};
// Set debuggable=true to allow run-as command usage with a release build
proj.AndroidManifest = proj.AndroidManifest.Replace ("<application ", "<application android:debuggable=\"true\" ");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis (DeviceAbi);
proj.SetProperty ("AndroidPackageFormat", "apk");
using (var builder = CreateApkBuilder ()) {
Assert.IsTrue (builder.Build (proj));
Expand Down Expand Up @@ -177,7 +177,7 @@ public void InstallWithoutSharedRuntime ()
proj.SetProperty (proj.ReleaseProperties, "EmbedAssembliesIntoApk", "false");
proj.SetProperty (proj.ReleaseProperties, "AndroidPackageFormat", "apk");

var abis = new [] { "armeabi-v7a", "x86", "x86_64" };
var abis = new [] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" };
proj.SetAndroidSupportedAbis (abis);
using (var builder = CreateApkBuilder ()) {
if (RunAdbCommand ("shell pm list packages Mono.Android.DebugRuntime").Trim ().Length != 0)
Expand Down Expand Up @@ -254,7 +254,7 @@ public void ToggleFastDev ()

//Now toggle FastDev to OFF
proj.EmbedAssembliesIntoApk = true;
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis (DeviceAbi);

Assert.IsTrue (builder.Install (proj), "Second install should have succeeded.");

Expand Down Expand Up @@ -286,7 +286,7 @@ public void ToggleDebugReleaseWithSigning ([Values ("aab", "apk")] string packag
proj.SetProperty (proj.ReleaseProperties, "AndroidKeyStore", "True");
proj.SetProperty (proj.ReleaseProperties, "AndroidSigningKeyStore", "test.keystore");
proj.SetProperty (proj.ReleaseProperties, "AndroidSigningKeyAlias", "mykey");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis (DeviceAbi);
proj.SetProperty (proj.ReleaseProperties, "AndroidPackageFormat", packageFormat);
proj.SetProperty ("AndroidUseApkSigner", "true");
proj.OtherBuildItems.Add (new BuildItem (BuildActions.None, "test.keystore") {
Expand Down Expand Up @@ -322,7 +322,7 @@ public void LoggingPropsShouldCreateOverrideDirForRelease ()
};
// Set debuggable=true to allow run-as command usage with a release build
proj.AndroidManifest = proj.AndroidManifest.Replace ("<application ", "<application android:debuggable=\"true\" ");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis (DeviceAbi);

using (var builder = CreateApkBuilder ()) {
Assert.IsTrue (builder.Install (proj), "Install should have succeeded.");
Expand Down Expand Up @@ -416,7 +416,7 @@ public void TestAndroidStoreKey (bool useApkSigner, bool isRelease, string packa
proj.SetProperty ("AndroidSigningStorePass", password);
proj.SetProperty ("AndroidSigningKeyPass", password);
}
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis (DeviceAbi);
proj.SetProperty ("AndroidKeyStore", androidKeyStore);
proj.SetProperty ("AndroidSigningKeyStore", "test.keystore");
proj.SetProperty ("AndroidSigningKeyAlias", "mykey");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected override void OnCreate (Bundle bundle)
}
}
}";
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis (DeviceAbi);
proj.SetProperty ("EmbedAssembliesIntoApk", embedAssemblies.ToString ());
proj.SetDefaultTargetDevice ();
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void SystemApplicationCanInstall ()
WebContent = "https://github.com/aosp-mirror/platform_build/raw/master/target/product/security/platform.x509.pem"
});
proj.AndroidManifest = proj.AndroidManifest.Replace ("<manifest ", "<manifest android:sharedUserId=\"android.uid.system\" ");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis (DeviceAbi);


proj.SetDefaultTargetDevice ();
Expand Down

0 comments on commit 1331aa2

Please sign in to comment.