From a427688048282a9251c814442c20ffa8c2f1b424 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Wed, 9 Aug 2023 12:27:09 -0400 Subject: [PATCH] [tests] Remove the last set of ignored MSBuild tests (#8246) Fixes: https://github.com/xamarin/xamarin-android/issues/7777 The last set of ignored test categories have been removed or migrated to existing tests: * Test configurations related to AotMode=Hybrid and AotMode=Full have been removed. * BuildTest.CheckSequencePointGeneration has been removed due to it relying on mono symbol output. * EnvironmentContentTests.CheckBuildIdIsUnique has been removed due to it relying on mono symbol output. * PackagingTest.CheckManagedSymbolsArchive has been removed due to it relying on mono symbol output. * InstallAndRunTests.MonoSymbolicateAndroidStackTrace has been removed due to it relying on mono symbol output. * InstallAndRunTests.MonoSymbolicateNetStandardStackTrace has been removed due to it relying on mono symbol output. * EmbeddedDSOTests.BinariesExist removed as it is implicitly covered by tests that validate .apk contents. * EmbeddedDSOTests.EnvironmentFileContents removed as it is covered by BuildTest.CheckAssemblyCounts. * EmbeddedDSOTests.DSOPageAlignment assert moved to PackagingTest.EmbeddedDSOs. * EmbeddedDSOTests.DSOCompressionMode and EmbeddedDSOTests.AndroidManifestHasFlag removed as they are covered by PackagingTest.EmbeddedDSOs. --- build-tools/automation/azure-pipelines.yaml | 2 +- .../yaml-templates/build-windows.yaml | 2 +- .../yaml-templates/run-msbuild-tests.yaml | 12 +- .../run-sliced-nunit-tests.yaml | 30 +- .../stage-msbuild-emulator-tests.yaml | 2 +- .../yaml-templates/stage-msbuild-tests.yaml | 2 - .../automation/yaml-templates/variables.yaml | 6 +- .../Xamarin.Android.Build.Tests/AotTests.cs | 58 +--- .../BuildTest.TestCaseSource.cs | 59 ---- .../Xamarin.Android.Build.Tests/BuildTest.cs | 58 ---- .../EmbeddedDSOTests.cs | 292 ------------------ .../EnvironmentContentTests.cs | 52 ---- .../IncrementalBuildTest.cs | 26 -- .../PackagingTest.cs | 36 +-- .../Utilities/BaseTest.cs | 67 +++- .../Tests/InstallAndRunTests.cs | 115 ------- 16 files changed, 94 insertions(+), 725 deletions(-) delete mode 100644 src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EmbeddedDSOTests.cs diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index cbe71e524d5..f1213c08282 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -273,7 +273,7 @@ stages: parameters: testRunTitle: Xamarin.Android.Build.Tests - Linux .NET 6 Smoke Tests testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll - dotNetTestExtraArgs: --filter "TestCategory = SmokeTests $(DotNetNUnitCategories)" + dotNetTestExtraArgs: --filter "TestCategory = SmokeTests" testResultsFile: TestResult-NETSmokeMSBuildTests-Linux-$(XA.Build.Configuration).xml - template: yaml-templates/upload-results.yaml diff --git a/build-tools/automation/yaml-templates/build-windows.yaml b/build-tools/automation/yaml-templates/build-windows.yaml index 485ab749bdf..ea65a643e0d 100644 --- a/build-tools/automation/yaml-templates/build-windows.yaml +++ b/build-tools/automation/yaml-templates/build-windows.yaml @@ -96,7 +96,7 @@ stages: testRunTitle: Smoke MSBuild Tests - Windows Dotnet Build testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\$(DotNetStableTargetFramework)\Xamarin.Android.Build.Tests.dll testResultsFile: TestResult-SmokeMSBuildTests-WinDotnetBuild-$(XA.Build.Configuration).xml - dotNetTestExtraArgs: --filter "TestCategory = SmokeTests $(DotNetNUnitCategories)" + dotNetTestExtraArgs: --filter "TestCategory = SmokeTests" - template: upload-results.yaml parameters: diff --git a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml index 908049e9c47..6d5193a5f87 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml @@ -1,9 +1,9 @@ parameters: - testOS: # 'macOS' or 'Windows' - jobName: # Name of the job - jobDisplayName: # Display name of the job - agentCount: # Number of build agents to run in parallel - testFilter: # Filter used to select tests (NUnit test selection language, not dotnet test filter language) + testOS: '' # 'macOS' or 'Windows' + jobName: '' # Name of the job + jobDisplayName: '' # Display name of the job + agentCount: 1 # Number of build agents to run in parallel + testFilter: '' # Filter used to select tests (NUnit test selection language, not dotnet test filter language) xaSourcePath: $(System.DefaultWorkingDirectory) repositoryAlias: 'self' commit: '' @@ -48,7 +48,7 @@ jobs: - template: run-sliced-nunit-tests.yaml parameters: testAssembly: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll - testFilter: ${{ parameters.testFilter }} $(ExcludedNUnitCategories) + testFilter: ${{ parameters.testFilter }} testRunTitle: Xamarin.Android.Build.Tests - ${{ parameters.testOS }} retryFailedTests: false xaSourcePath: ${{ parameters.xaSourcePath }} diff --git a/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml b/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml index 6e9f8cc1d64..45bd0beb9fd 100644 --- a/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml +++ b/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml @@ -1,20 +1,28 @@ parameters: - testAssembly: # NUnit test assembly to run - testFilter: # Filter used to select tests (NUnit test selection language, not dotnet test filter language) - testRunTitle: # Title of the test run + testAssembly: '' # NUnit test assembly to run + testFilter: '' # Filter used to select tests (NUnit test selection language, not dotnet test filter language) + testRunTitle: '' # Title of the test run xaSourcePath: $(System.DefaultWorkingDirectory) retryFailedTests: true # Retry failed tests once steps: -- pwsh: | - dotnet-test-slicer ` - slice ` - --test-assembly="${{ parameters.testAssembly }}" ` - --test-filter="${{ parameters.testFilter }}" ` - --slice-number=$(System.JobPositionInPhase) ` - --total-slices=$(System.TotalJobsInPhase) ` +- ${{if parameters.testFilter}}: + - pwsh: >- + dotnet-test-slicer slice + --test-assembly="${{ parameters.testAssembly }}" + --test-filter="${{ parameters.testFilter }}" + --slice-number=$(System.JobPositionInPhase) + --total-slices=$(System.TotalJobsInPhase) --outfile="${{ parameters.testAssembly }}.runsettings" - displayName: Slice unit tests + displayName: Slice unit tests with filter +- ${{ else }}: + - pwsh: >- + dotnet-test-slicer slice + --test-assembly="${{ parameters.testAssembly }}" + --slice-number=$(System.JobPositionInPhase) + --total-slices=$(System.TotalJobsInPhase) + --outfile="${{ parameters.testAssembly }}.runsettings" + displayName: Slice unit tests - ${{ if eq(parameters.retryFailedTests, 'false') }}: # If we aren't using auto-retry logic, then this is just a simple template call diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index 202d6fd696a..88657721c3f 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -57,7 +57,7 @@ stages: - template: run-sliced-nunit-tests.yaml parameters: testAssembly: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll - testFilter: cat != TimeZoneInfo & cat != Localization $(ExcludedNUnitCategories) + testFilter: $(ExcludedNightlyNUnitCategories) testRunTitle: MSBuildDeviceIntegration On Device - macOS - ${{ if ne(parameters.usesCleanImages, true) }}: diff --git a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml index 6c9eaf929d7..5d9129c367a 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml @@ -22,7 +22,6 @@ stages: jobName: mac_msbuild_tests jobDisplayName: macOS > Tests > MSBuild agentCount: 10 - testFilter: cat != Dummy # This is because $(ExcludedNUnitCategories) gets appended which starts with '&' xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} @@ -34,7 +33,6 @@ stages: jobName: win_msbuild_tests jobDisplayName: Windows > Tests > MSBuild agentCount: 6 - testFilter: cat != Dummy # This is because $(ExcludedNUnitCategories) gets appended which starts with '&' xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} diff --git a/build-tools/automation/yaml-templates/variables.yaml b/build-tools/automation/yaml-templates/variables.yaml index 41c64201b08..e416520230a 100644 --- a/build-tools/automation/yaml-templates/variables.yaml +++ b/build-tools/automation/yaml-templates/variables.yaml @@ -48,9 +48,7 @@ variables: value: false - name: IsRelOrTargetingRel value: $[or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), startsWith(variables['System.PullRequest.TargetBranch'], 'release/'))] -- name: DotNetNUnitCategories - value: '& TestCategory != DotNetIgnore & TestCategory != HybridAOT & TestCategory != MkBundle & TestCategory != MonoSymbolicate & TestCategory != StaticProject & TestCategory != SystemApplication' - name: DefaultTestSdkPlatforms # Comma-separated SDK Platform(s) to install on test agents (no spaces) value: 33,34 -- name: ExcludedNUnitCategories - value: '& cat != DotNetIgnore & cat != HybridAOT & cat != MkBundle & cat != MonoSymbolicate & cat != StaticProject & cat != SystemApplication' +- name: ExcludedNightlyNUnitCategories + value: 'cat != SystemApplication & cat != TimeZoneInfo & cat != Localization' diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs index db5da19d657..20d2a2282f5 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs @@ -363,67 +363,13 @@ public static void Foo () { sb.Dispose (); } - [Test] - [Category ("HybridAOT")] - public void HybridAOT ([Values ("armeabi-v7a;arm64-v8a", "armeabi-v7a", "arm64-v8a")] string abis) - { - // There's no point in testing all of the ABIs with and without assembly blobs, let's test just one of them this way - bool usesAssemblyBlobs = String.Compare ("arm64-v8a", abis, StringComparison.Ordinal) == 0; - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - AotAssemblies = true, - }; - proj.SetProperty ("AndroidAotMode", "Hybrid"); - // So we can use Mono.Cecil to open assemblies directly - proj.SetProperty ("AndroidEnableAssemblyCompression", "False"); - proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ()); - proj.SetAndroidSupportedAbis (abis); - - using (var b = CreateApkBuilder ()) { - - if (abis == "armeabi-v7a") { - proj.SetProperty ("_AndroidAotModeValidateAbi", "False"); - b.Build (proj); - proj.SetProperty ("_AndroidAotModeValidateAbi", () => null); - } - - if (abis.Contains ("armeabi-v7a")) { - b.ThrowOnBuildFailure = false; - Assert.IsFalse (b.Build (proj), "Build should have failed."); - string error = b.LastBuildOutput - .SkipWhile (x => !x.StartsWith ("Build FAILED.", StringComparison.Ordinal)) - .FirstOrDefault (x => x.Contains ("error XA1025:")); - Assert.IsNotNull (error, "Build should have failed with XA1025."); - return; - } - - b.Build (proj); - - var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - FileAssert.Exists (apk); - var helper = new ArchiveAssemblyHelper (apk, usesAssemblyBlobs); - Assert.IsTrue (helper.Exists ($"assemblies/{proj.ProjectName}.dll"), $"{proj.ProjectName}.dll should exist in apk!"); - - using (var stream = helper.ReadEntry ($"assemblies/{proj.ProjectName}.dll")) { - stream.Position = 0; - using (var assembly = AssemblyDefinition.ReadAssembly (stream)) { - var type = assembly.MainModule.GetType ($"{proj.ProjectName}.MainActivity"); - var method = type.Methods.First (m => m.Name == "OnCreate"); - Assert.LessOrEqual (method.Body.Instructions.Count, 1, "OnCreate should have stripped method bodies!"); - } - } - } - } - [Test] [Category ("LLVM")] - public void NoSymbolsArgShouldReduceAppSize ([Values ("", "Hybrid")] string androidAotMode, [Values (false, true)] bool skipDebugSymbols) + public void NoSymbolsArgShouldReduceAppSize ([Values (false, true)] bool skipDebugSymbols) { if (IsWindows) Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625"); - AssertAotModeSupported (androidAotMode); - var proj = new XamarinAndroidApplicationProject () { IsRelease = true, AotAssemblies = true, @@ -431,8 +377,6 @@ public void NoSymbolsArgShouldReduceAppSize ([Values ("", "Hybrid")] string andr var supportedAbi = "arm64-v8a"; proj.SetAndroidSupportedAbis (supportedAbi); proj.SetProperty ("EnableLLVM", true.ToString ()); - if (!string.IsNullOrEmpty (androidAotMode)) - proj.SetProperty ("AndroidAotMode", androidAotMode); var xaAssemblySize = 0; var xaAssemblySizeNoSymbol = 0; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs index 29a390c9835..ba570cce8ca 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs @@ -148,65 +148,6 @@ public partial class BuildTest : BaseTest /* expectedResult */ CommercialBuildAvailable ? "debug" : "release", }, }; - - static object [] SequencePointChecks () => new object [] { - new object[] { - /* isRelease */ true, - /* monoSymbolArchive */ true , - /* aotAssemblies */ false, - /* debugSymbols */ true, - /* expectedRuntime */ "release", - /* usesAssemblyBlobs */ false, - }, - new object[] { - /* isRelease */ true, - /* monoSymbolArchive */ true , - /* aotAssemblies */ true, - /* debugSymbols */ true, - /* expectedRuntime */ "release", - /* usesAssemblyBlobs */ false, - }, - new object[] { - /* isRelease */ true, - /* monoSymbolArchive */ false , - /* aotAssemblies */ false, - /* debugSymbols */ true, - /* expectedRuntime */ "release", - /* usesAssemblyBlobs */ false, - }, - new object[] { - /* isRelease */ true, - /* monoSymbolArchive */ false , - /* aotAssemblies */ false, - /* debugSymbols */ true, - /* expectedRuntime */ "release", - /* usesAssemblyBlobs */ true, - }, - new object[] { - /* isRelease */ true, - /* monoSymbolArchive */ false , - /* aotAssemblies */ true, - /* debugSymbols */ false, - /* expectedRuntime */ "release", - /* usesAssemblyBlobs */ false, - }, - new object[] { - /* isRelease */ true, - /* monoSymbolArchive */ true , - /* aotAssemblies */ true, - /* debugSymbols */ false, - /* expectedRuntime */ "release", - /* usesAssemblyBlobs */ false, - }, - new object[] { - /* isRelease */ true, - /* monoSymbolArchive */ true , - /* aotAssemblies */ true, - /* debugSymbols */ false, - /* expectedRuntime */ "release", - /* usesAssemblyBlobs */ true, - }, - }; #pragma warning restore 414 } } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index 1ea69378427..0d4182e2003 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -355,64 +355,6 @@ public void CheckWhichRuntimeIsIncluded (string supportedAbi, bool debugSymbols, } } - [Test] - [Category ("AOT"), Category ("MonoSymbolicate")] - [TestCaseSource (nameof (SequencePointChecks))] - public void CheckSequencePointGeneration (bool isRelease, bool monoSymbolArchive, bool aotAssemblies, - bool debugSymbols, string expectedRuntime, bool usesAssemblyBlobs) - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = isRelease, - AotAssemblies = aotAssemblies - }; - var abis = new [] { "armeabi-v7a", "x86" }; - proj.SetAndroidSupportedAbis (abis); - proj.SetProperty (proj.ActiveConfigurationProperties, "MonoSymbolArchive", monoSymbolArchive); - proj.SetProperty (proj.ActiveConfigurationProperties, "DebugSymbols", debugSymbols); - proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ()); - using (var b = CreateApkBuilder ()) { - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - var apk = Path.Combine (Root, b.ProjectDirectory, - proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - var msymarchive = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, proj.PackageName + ".apk.mSYM"); - var helper = new ArchiveAssemblyHelper (apk, usesAssemblyBlobs); - if (aotAssemblies) { - foreach (var abi in abis) { - var assemblies = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, - "aot", abi, "libaot-UnnamedProject.dll.so"); - var shouldExist = monoSymbolArchive && debugSymbols; - var symbolicateFile = Directory.GetFiles (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, - "aot", abi), "UnnamedProject.dll.msym", SearchOption.AllDirectories).FirstOrDefault (); - if (shouldExist) - Assert.IsNotNull (symbolicateFile, "UnnamedProject.dll.msym should exist"); - else - Assert.IsNull (symbolicateFile, "{0} should not exist", symbolicateFile); - if (shouldExist) { - var foundMsyms = Directory.GetFiles (Path.Combine (msymarchive), "UnnamedProject.dll.msym", SearchOption.AllDirectories).Any (); - Assert.IsTrue (foundMsyms, "UnnamedProject.dll.msym should exist in the archive {0}", msymarchive); - } - Assert.IsTrue (File.Exists (assemblies), "{0} libaot-UnnamedProject.dll.so does not exist", abi); - Assert.IsTrue (helper.Exists ($"lib/{abi}/libaot-UnnamedProject.dll.so"), - $"lib/{0}/libaot-UnnamedProject.dll.so should be in the {proj.PackageName}-Signed.apk", abi); - Assert.IsTrue (helper.Exists ("assemblies/UnnamedProject.dll"), - $"UnnamedProject.dll should be in the {proj.PackageName}-Signed.apk"); - } - } - var runtimeInfo = b.GetSupportedRuntimes (); - foreach (var abi in abis) { - var runtime = runtimeInfo.FirstOrDefault (x => x.Abi == abi && x.Runtime == expectedRuntime); - Assert.IsNotNull (runtime, "Could not find the expected runtime."); - var inApk = ZipHelper.ReadFileFromZip (apk, String.Format ("lib/{0}/{1}", abi, runtime.Name)); - var inApkRuntime = runtimeInfo.FirstOrDefault (x => x.Abi == abi && x.Size == inApk.Length); - Assert.IsNotNull (inApkRuntime, "Could not find the actual runtime used."); - Assert.AreEqual (runtime.Size, inApkRuntime.Size, "expected {0} got {1}", expectedRuntime, inApkRuntime.Runtime); - } - - b.Clean (proj); - Assert.IsTrue (!Directory.Exists (msymarchive), "{0} should have been deleted on Clean", msymarchive); - } - } - [Test] public void CheckItemMetadata ([Values (true, false)] bool isRelease) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EmbeddedDSOTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EmbeddedDSOTests.cs deleted file mode 100644 index 714f88a9449..00000000000 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EmbeddedDSOTests.cs +++ /dev/null @@ -1,292 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Xml; -using System.Xml.XPath; - -using Microsoft.Build.Framework; -using NUnit.Framework; -using Xamarin.Android.Build.Tests; -using Xamarin.ProjectTools; -using Xamarin.Tools.Zip; - -namespace Xamarin.Android.Build.Tests -{ - [Category ("StaticProject")] // TODO: enable for .NET 5 - [Parallelizable (ParallelScope.Children)] - public class EmbeddedDSOTests : BaseTest - { - sealed class LocalBuilder : ProjectBuilder - { - public LocalBuilder (string projectDir) : base (projectDir) - { - BuildingInsideVisualStudio = false; - } - - public bool Build (string projectOrSolution, string target, string [] parameters = null, Dictionary environmentVariables = null) - { - return BuildInternal (projectOrSolution, target, parameters, environmentVariables); - } - } - - const string ProjectName = "EmbeddedDSO"; - const string ProjectAssemblyName = "Xamarin.Android.EmbeddedDSO_Test"; - - static readonly string TestProjectRootDirectory; - static readonly string TestOutputDir; - - static readonly List produced_binaries = new List { - $"{ProjectAssemblyName}.dll", - $"{ProjectAssemblyName}-Signed.apk", - $"{ProjectAssemblyName}.apk", - }; - - static readonly List log_files = new List { - "process.log", - "msbuild.binlog", - }; - - string testProjectPath; - string androidSdkDir; - - static EmbeddedDSOTests () - { - TestProjectRootDirectory = Path.GetFullPath (Path.Combine (XABuildPaths.TopDirectory, "tests", "EmbeddedDSOs", "EmbeddedDSO")); - TestOutputDir = Path.Combine (XABuildPaths.TestOutputDirectory, "temp", "EmbeddedDSO"); - - produced_binaries = new List { - $"{ProjectAssemblyName}.dll", - $"{ProjectAssemblyName}-Signed.apk", - $"{ProjectAssemblyName}.apk", - }; - } - - [OneTimeSetUp] - public void BuildProject () - { - testProjectPath = PrepareProject (ProjectName); - string projectPath = Path.Combine (testProjectPath, $"{ProjectName}.csproj"); - LocalBuilder builder = GetBuilder ("EmbeddedDSO", testProjectPath); - string targetAbis = Xamarin.Android.Tools.XABuildConfig.SupportedABIs.Replace (";", ":"); - bool success = builder.Build (projectPath, "SignAndroidPackage", new [] { - "UnitTestsMode=true", - $"Configuration={XABuildPaths.Configuration}", - $"AndroidSupportedTargetJitAbis=\"{targetAbis}\"", - }); - - Assert.That (success, Is.True, "Should have been built"); - - androidSdkDir = AndroidSdkResolver.GetAndroidSdkPath (); - } - - [OneTimeTearDown] - public void CleanUp () - { - if (TestContext.CurrentContext.Result.FailCount == 0) { - FileSystemUtils.SetDirectoryWriteable (TestOutputDir); - Directory.Delete (TestOutputDir, recursive: true); - } - } - - [Test] - public void BinariesExist () - { - foreach (string binary in produced_binaries) { - string fp = Path.Combine (testProjectPath, "bin", XABuildPaths.Configuration, binary); - - Assert.That (new FileInfo (fp), Does.Exist, $"File {fp} should exist"); - } - } - - [Test] - public void DSOPageAlignment () - { - var zipAlignPath = Path.Combine (GetPathToZipAlign (), IsWindows ? "zipalign.exe" : "zipalign"); - Assert.That (new FileInfo (zipAlignPath), Does.Exist, $"ZipAlign not found at {zipAlignPath}"); - - string apk = Path.Combine (testProjectPath, "bin", XABuildPaths.Configuration, $"{ProjectAssemblyName}-Signed.apk"); - Assert.That (new FileInfo (apk), Does.Exist, $"File {apk} should exist"); - Assert.That (RunCommand (zipAlignPath, $"-c -v -p 4 {apk}"), Is.True, $"{ProjectAssemblyName}-Signed.apk does not contain page-aligned .so files"); - } - - [Test] - public void EnvironmentFileContents () - { - string intermediateOutputDir = Path.Combine (testProjectPath, "obj", XABuildPaths.Configuration); - List envFiles = EnvironmentHelper.GatherEnvironmentFiles (intermediateOutputDir, Xamarin.Android.Tools.XABuildConfig.SupportedABIs, true); - EnvironmentHelper.ApplicationConfig app_config = EnvironmentHelper.ReadApplicationConfig (envFiles); - Assert.That (app_config, Is.Not.Null, "application_config must be present in the environment files"); - } - - [Test] - public void DSOCompressionMode () - { - string apk = Path.Combine (testProjectPath, "bin", XABuildPaths.Configuration, $"{ProjectAssemblyName}-Signed.apk"); - Assert.That (new FileInfo (apk), Does.Exist, $"File {apk} should exist"); - - var bad_dsos = new List (); - using (ZipArchive zip = ZipArchive.Open (apk, FileMode.Open)) { - Assert.That (zip, Is.Not.Null, $"{apk} couldn't be opened as a zip archive"); - - foreach (ZipEntry entry in zip) { - if (!entry.FullName.EndsWith (".so", StringComparison.Ordinal)) - continue; - - if (entry.CompressionMethod == CompressionMethod.Store) - continue; - - bad_dsos.Add (entry.FullName); - } - } - - Assert.That (bad_dsos.Count == 0, Is.True, $"Some DSO entries in {apk} are compressed ({BadDsosString ()})"); - - string BadDsosString () - { - return String.Join ("; ", bad_dsos); - } - } - - [Test] - public void AndroidManifestHasFlag () - { - const string AndroidNS = "http://schemas.android.com/apk/res/android"; - - string manifest = Path.Combine (testProjectPath, "obj", XABuildPaths.Configuration, "android", "manifest", "AndroidManifest.xml"); - Assert.That (new FileInfo (manifest), Does.Exist, $"File {manifest} should exist"); - - using (var reader = XmlReader.Create (manifest, new XmlReaderSettings { XmlResolver = null })) { - var doc = new XPathDocument (reader); - XPathNavigator nav = doc.CreateNavigator (); - - var manager = new XmlNamespaceManager (nav.NameTable); - manager.AddNamespace ("android", AndroidNS); - - XPathNavigator application = nav.SelectSingleNode ("//manifest/application"); - Assert.That (application, Is.Not.Null, $"Manifest {manifest} does not contain the `application` node"); - - string attr = application.GetAttribute ("extractNativeLibs", AndroidNS)?.Trim (); - Assert.That (String.IsNullOrEmpty (attr), Is.False, $"Manifest {manifest} `application` node does not contain the `extractNativeLibs` attribute"); - Assert.That (String.Compare ("false", attr, StringComparison.OrdinalIgnoreCase), Is.EqualTo (0), $"Manifest {manifest} `application` node's `extractNativeLibs` attribute is not set to `false`"); - } - } - - bool RunCommand (string command, string arguments) - { - var psi = new ProcessStartInfo () { - FileName = command, - Arguments = arguments, - UseShellExecute = false, - RedirectStandardInput = false, - RedirectStandardOutput = true, - RedirectStandardError = true, - CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden, - }; - - var stderr_completed = new ManualResetEvent (false); - var stdout_completed = new ManualResetEvent (false); - - var p = new Process () { - StartInfo = psi, - }; - - p.ErrorDataReceived += (sender, e) => { - if (e.Data == null) - stderr_completed.Set (); - else - Console.WriteLine (e.Data); - }; - - p.OutputDataReceived += (sender, e) => { - if (e.Data == null) - stdout_completed.Set (); - else - Console.WriteLine (e.Data); - }; - - using (p) { - p.StartInfo = psi; - p.Start (); - p.BeginOutputReadLine (); - p.BeginErrorReadLine (); - - bool success = p.WaitForExit (60000); - - // We need to call the parameter-less WaitForExit only if any of the standard - // streams have been redirected (see - // https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.waitforexit?view=netframework-4.7.2#System_Diagnostics_Process_WaitForExit) - // - p.WaitForExit (); - stderr_completed.WaitOne (TimeSpan.FromSeconds (60)); - stdout_completed.WaitOne (TimeSpan.FromSeconds (60)); - - if (!success || p.ExitCode != 0) { - Console.Error.WriteLine ($"Process `{command} {arguments}` exited with value {p.ExitCode}."); - return false; - } - - return true; - } - } - - string PrepareProject (string testName) - { - string tempRoot = Path.Combine (TestOutputDir, $"{testName}.build", XABuildPaths.Configuration); - string temporaryProjectPath = Path.Combine (tempRoot, "project"); - - var ignore = new HashSet { - Path.Combine (TestProjectRootDirectory, "bin"), - Path.Combine (TestProjectRootDirectory, "obj"), - }; - - CopyRecursively (TestProjectRootDirectory, temporaryProjectPath, ignore); - return temporaryProjectPath; - } - - void CopyRecursively (string fromDir, string toDir, HashSet ignoreDirs) - { - if (String.IsNullOrEmpty (fromDir)) - throw new ArgumentException ($"{nameof (fromDir)} is must have a non-empty value"); - if (String.IsNullOrEmpty (toDir)) - throw new ArgumentException ($"{nameof (toDir)} is must have a non-empty value"); - - if (ignoreDirs.Contains (fromDir)) - return; - - var fdi = new DirectoryInfo (fromDir); - if (!fdi.Exists) - throw new InvalidOperationException ($"Source directory '{fromDir}' does not exist"); - - if (Directory.Exists (toDir)) - Directory.Delete (toDir, true); - - foreach (FileSystemInfo fsi in fdi.EnumerateFileSystemInfos ("*", SearchOption.TopDirectoryOnly)) { - if (fsi is FileInfo finfo) - CopyFile (fsi.FullName, Path.Combine (toDir, finfo.Name)); - else - CopyRecursively (fsi.FullName, Path.Combine (toDir, fsi.Name), ignoreDirs); - } - } - - void CopyFile (string from, string to) - { - string dir = Path.GetDirectoryName (to); - if (!Directory.Exists (dir)) - Directory.CreateDirectory (dir); - File.Copy (from, to, true); - } - - LocalBuilder GetBuilder (string baseLogFileName, string projectDir) - { - return new LocalBuilder (projectDir) { - BuildLogFile = $"{baseLogFileName}.log" - }; - } - } -} diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs index 99608f4f796..ae84afb2b04 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs @@ -140,58 +140,6 @@ public void CheckConcurrentGC () } } - [Test] - [Category ("MonoSymbolicate")] - public void CheckBuildIdIsUnique ([Values ("apk", "aab")] string packageFormat) - { - const string supportedAbis = "armeabi-v7a;x86"; - - Dictionary buildIds = new Dictionary (); - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - }; - proj.SetProperty (proj.ReleaseProperties, "MonoSymbolArchive", "True"); - proj.SetProperty (proj.ReleaseProperties, "DebugSymbols", "true"); - proj.SetProperty (proj.ReleaseProperties, "DebugType", "Portable"); - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, "true"); - proj.SetProperty (proj.ReleaseProperties, "AndroidPackageFormat", packageFormat); - proj.SetAndroidSupportedAbis (supportedAbis); - using (var b = CreateApkBuilder ()) { - b.ThrowOnBuildFailure = false; - Assert.IsTrue (b.Build (proj), "first build failed"); - var outputPath = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath); - var archivePath = Path.Combine (outputPath, $"{proj.PackageName}.{packageFormat}.mSYM"); - var allFilesInArchive = Directory.GetFiles (archivePath, "*", SearchOption.AllDirectories); - string extension = "dll"; - Assert.IsTrue (allFilesInArchive.Any (x => Path.GetFileName (x) == $"{proj.ProjectName}.{extension}"), $"{proj.ProjectName}.{extension} should exist in {archivePath}"); - extension = "pdb"; - Assert.IsTrue (allFilesInArchive.Any (x => Path.GetFileName (x) == $"{proj.ProjectName}.{extension}"), $"{proj.ProjectName}.{extension} should exist in {archivePath}"); - - string intermediateOutputDir = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); - List envFiles = EnvironmentHelper.GatherEnvironmentFiles (intermediateOutputDir, supportedAbis, true); - Dictionary envvars = EnvironmentHelper.ReadEnvironmentVariables (envFiles); - Assert.IsTrue (envvars.Count > 0, $"No environment variables defined"); - - string buildID; - Assert.IsTrue (envvars.TryGetValue ("XAMARIN_BUILD_ID", out buildID), "The environment should contain a XAMARIN_BUILD_ID"); - buildIds.Add ("all", buildID); - - var msymDirectory = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}.{packageFormat}.mSYM"); - Assert.IsTrue (File.Exists (Path.Combine (msymDirectory, "manifest.xml")), "manifest.xml should exist in", msymDirectory); - var doc = XDocument.Load (Path.Combine (msymDirectory, "manifest.xml")); - - Assert.IsTrue (doc.Element ("mono-debug") - .Elements () - .Any (x => x.Name == "app-id" && x.Value == proj.PackageName), "app-id is has an incorrect value."); - var buildId = buildIds.First ().Value; - Assert.IsTrue (doc.Element ("mono-debug") - .Elements () - .Any (x => x.Name == "build-id" && x.Value == buildId), "build-id is has an incorrect value."); - - EnvironmentHelper.AssertValidEnvironmentSharedLibrary (intermediateOutputDir, AndroidSdkPath, AndroidNdkPath, supportedAbis); - } - } - [Test] public void CheckForInvalidHttpClientHandlerType () { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs index a0fc6191059..91649d560ef 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs @@ -1043,30 +1043,6 @@ void AssertAssemblyFilesInFileWrites (XamarinAndroidApplicationProject proj, Pro /* aotAssemblies */ false, /* expectedResult */ true, }, - new object[] { - /* supportedAbis */ "arm64-v8a", - /* androidAotMode */ "Full", // None, Normal, Hybrid, Full - /* aotAssemblies */ true, - /* expectedResult */ true, - }, - new object[] { - /* supportedAbis */ "arm64-v8a", - /* androidAotMode */ "Full", // None, Normal, Hybrid, Full - /* aotAssemblies */ false, - /* expectedResult */ true, - }, - new object[] { - /* supportedAbis */ "arm64-v8a", - /* androidAotMode */ "Hybrid", // None, Normal, Hybrid, Full - /* aotAssemblies */ true, - /* expectedResult */ true, - }, - new object[] { - /* supportedAbis */ "arm64-v8a", - /* androidAotMode */ "Hybrid", // None, Normal, Hybrid, Full - /* aotAssemblies */ false, - /* expectedResult */ true, - }, }; #pragma warning restore 414 @@ -1075,8 +1051,6 @@ void AssertAssemblyFilesInFileWrites (XamarinAndroidApplicationProject proj, Pro [TestCaseSource (nameof (AotChecks))] public void BuildIncrementalAot (string supportedAbis, string androidAotMode, bool aotAssemblies, bool expectedResult) { - AssertAotModeSupported (androidAotMode); - // Setup dependencies App A -> Lib B var path = Path.Combine ("temp", TestName); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs index 50c57583665..9e7facc32e7 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs @@ -15,38 +15,6 @@ namespace Xamarin.Android.Build.Tests [Parallelizable (ParallelScope.Children)] public class PackagingTest : BaseTest { -#pragma warning disable 414 - static object [] ManagedSymbolsArchiveSource = new object [] { - // isRelease, monoSymbolArchive, packageFormat, - new object[] { false , false , "apk" }, - new object[] { true , true , "apk" }, - new object[] { true , false , "apk" }, - new object[] { true , true , "aab" }, - }; -#pragma warning restore 414 - - [Test] - [Category ("MonoSymbolicate")] - [TestCaseSource (nameof(ManagedSymbolsArchiveSource))] - public void CheckManagedSymbolsArchive (bool isRelease, bool monoSymbolArchive, string packageFormat) - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = isRelease, - }; - proj.SetProperty (proj.ReleaseProperties, "MonoSymbolArchive", monoSymbolArchive); - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, "true"); - proj.SetProperty (proj.ReleaseProperties, "AndroidPackageFormat", packageFormat); - proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); - using (var b = CreateApkBuilder ()) { - b.ThrowOnBuildFailure = false; - Assert.IsTrue (b.Build (proj), "first build failed"); - var outputPath = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath); - var archivePath = Path.Combine (outputPath, $"{proj.PackageName}.{packageFormat}.mSYM"); - Assert.AreEqual (monoSymbolArchive, Directory.Exists (archivePath), - string.Format ("The msym archive {0} exist.", monoSymbolArchive ? "should" : "should not")); - } - } - [Test] public void CheckProguardMappingFileExists () { @@ -231,6 +199,10 @@ void AssertEmbeddedDSOs (string apk) { FileAssert.Exists (apk); + var zipAlignPath = Path.Combine (GetPathToZipAlign (), IsWindows ? "zipalign.exe" : "zipalign"); + Assert.That (new FileInfo (zipAlignPath), Does.Exist, $"ZipAlign not found at {zipAlignPath}"); + Assert.That (RunCommand (zipAlignPath, $"-c -v -p 4 {apk}"), Is.True, $"{apk} does not contain page-aligned .so files"); + using (var zip = ZipHelper.OpenZip (apk)) { foreach (var entry in zip) { if (entry.FullName.EndsWith (".so", StringComparison.Ordinal)) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs index e753a25b41b..f6e2af09cc3 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs @@ -82,14 +82,6 @@ protected static void AssertAaptSupported (bool useAapt2) } } - protected static void AssertAotModeSupported (string aotMode) - { - if (Builder.UseDotNet && !string.IsNullOrEmpty (aotMode) && - !string.Equals (aotMode, "Normal", StringComparison.OrdinalIgnoreCase)) { - Assert.Ignore ($"AotMode={aotMode} is not yet supported in .NET 6+"); - } - } - protected static void WaitFor(int milliseconds) { var pause = new ManualResetEvent(false); @@ -513,6 +505,65 @@ protected void AssertExtractNativeLibs (string manifest, bool extractNativeLibs) } } + protected bool RunCommand (string command, string arguments) + { + var psi = new ProcessStartInfo () { + FileName = command, + Arguments = arguments, + UseShellExecute = false, + RedirectStandardInput = false, + RedirectStandardOutput = true, + RedirectStandardError = true, + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden, + }; + + var stderr_completed = new ManualResetEvent (false); + var stdout_completed = new ManualResetEvent (false); + + var p = new Process () { + StartInfo = psi, + }; + + p.ErrorDataReceived += (sender, e) => { + if (e.Data == null) + stderr_completed.Set (); + else + Console.WriteLine (e.Data); + }; + + p.OutputDataReceived += (sender, e) => { + if (e.Data == null) + stdout_completed.Set (); + else + Console.WriteLine (e.Data); + }; + + using (p) { + p.StartInfo = psi; + p.Start (); + p.BeginOutputReadLine (); + p.BeginErrorReadLine (); + + bool success = p.WaitForExit (60000); + + // We need to call the parameter-less WaitForExit only if any of the standard + // streams have been redirected (see + // https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.waitforexit?view=netframework-4.7.2#System_Diagnostics_Process_WaitForExit) + // + p.WaitForExit (); + stderr_completed.WaitOne (TimeSpan.FromSeconds (60)); + stdout_completed.WaitOne (TimeSpan.FromSeconds (60)); + + if (!success || p.ExitCode != 0) { + Console.Error.WriteLine ($"Process `{command} {arguments}` exited with value {p.ExitCode}."); + return false; + } + + return true; + } + } + [SetUp] public void TestSetup () { diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index 2286d0fed22..fc60f88a1b7 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -164,53 +164,6 @@ void Reset () } } - Regex ObfuscatedStackRegex = new Regex ("in <.*>:0", RegexOptions.Compiled); - - void SymbolicateAndAssert (string symbolArchivePath, string logcatFilePath, IEnumerable expectedStackTraceContents) - { - // 09-22 14:21:07.064 12786 12786 I MonoDroid: at UnnamedProject.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00051] in :0 - Assert.IsTrue (ObfuscatedStackRegex.IsMatch (File.ReadAllText (logcatFilePath)), "Original logcat output did not contain obfuscated crash info."); - var monoSymbolicate = IsWindows ? Path.Combine (TestEnvironment.AndroidMSBuildDirectory, "mono-symbolicate.exe") : "mono-symbolicate"; - var symbolicatedOutput = RunProcess (monoSymbolicate, $"\"{symbolArchivePath}\" \"{logcatFilePath}\""); - File.WriteAllText (Path.Combine (Path.GetDirectoryName (logcatFilePath), "mono-symbol.log"), symbolicatedOutput); - Assert.IsFalse (ObfuscatedStackRegex.IsMatch (symbolicatedOutput), "Symbolicated logcat output did contain obfuscated crash info."); - foreach (string expectedString in expectedStackTraceContents) { - StringAssert.Contains (expectedString, symbolicatedOutput); - } - } - - [Test, Category ("MonoSymbolicate")] - public void MonoSymbolicateAndroidStackTrace () - { - proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - }; - proj.SetAndroidSupportedAbis ("armeabi-v7a", "arm64-v8a", "x86", "x86_64"); - proj.SetProperty (proj.ReleaseProperties, "MonoSymbolArchive", "True"); - proj.MainActivity = proj.DefaultMainActivity.Replace ("//${AFTER_ONCREATE}", -@" throw new Android.OS.RemoteException (""We've thrown an unhandled Android.OS.RemoteException!""); -"); - builder = CreateApkBuilder (); - Assert.IsTrue (builder.Install (proj), "Install should have succeeded."); - var archivePath = Path.Combine (Root, builder.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}.apk.mSYM"); - Assert.IsTrue (Directory.Exists (archivePath), $"Symbol archive path {archivePath} should exist."); - RunProjectAndAssert (proj, builder); - - var logcatPath = Path.Combine (Root, builder.ProjectDirectory, "crash-logcat.log"); - MonitorAdbLogcat ((line) => { - return line.Contains ($"Force finishing activity {proj.PackageName}"); - }, logcatPath, 30); - - var didParse = int.TryParse (proj.TargetSdkVersion, out int apiLevel); - Assert.IsTrue (didParse, $"Unable to parse {proj.TargetSdkVersion} as an int."); - SymbolicateAndAssert (archivePath, logcatPath, new string [] { - Path.Combine (Root, builder.ProjectDirectory, "MainActivity.cs:32"), - TestEnvironment.UseLocalBuildOutput - ? Path.Combine ("src", "Mono.Android", "obj", XABuildPaths.Configuration, "monoandroid10", $"android-{apiLevel}", "mcw", "Android.App.Activity.cs:") - : $"src/Mono.Android/obj/Release/monoandroid10/android-{apiLevel}/mcw/Android.App.Activity.cs:", - }) ; - } - [Test] [Category ("UsesDevice")] public void SmokeTestBuildAndRunWithSpecialCharacters () @@ -233,74 +186,6 @@ public void SmokeTestBuildAndRunWithSpecialCharacters () } } - [Test, Category ("MonoSymbolicate")] - public void MonoSymbolicateNetStandardStackTrace () - { - var lib = new DotNetStandard { - ProjectName = "Library1", - Sdk = "Microsoft.NET.Sdk", - TargetFramework = "netstandard2.0", - Sources = { - new BuildItem.Source ("Class1.cs") { - TextContent = () => @" -using System; -namespace Library1 { - public class Class1 { - string Data { get; set; } - public Class1(string data) { - Data = data; - } - - public string GetData() { - if (Data == null) - throw new NullReferenceException(); - return Data; - } - } -}", - }, - } - }; - - proj = new XamarinFormsAndroidApplicationProject () { - IsRelease = true, - References = { - new BuildItem ("ProjectReference", "..\\Library1\\Library1.csproj"), - }, - }; - proj.SetAndroidSupportedAbis ("armeabi-v7a", "arm64-v8a", "x86", "x86_64"); - proj.SetProperty (proj.ReleaseProperties, "MonoSymbolArchive", "True"); - proj.MainActivity = proj.DefaultMainActivity.Replace ("//${AFTER_FORMS_INIT}", -@" var cl = new Library1.Class1(null); - cl.GetData(); -"); - var rootPath = Path.Combine (Root, "temp", TestName); - using (var lb = CreateDllBuilder (Path.Combine (Path.Combine (Root, "temp", TestName), lib.ProjectName))) { - Assert.IsTrue (lb.Build (lib), "Library build should have succeeded."); - - builder = CreateApkBuilder (Path.Combine (rootPath, proj.ProjectName)); - Assert.IsTrue (builder.Install (proj), "Install should have succeeded."); - var archivePath = Path.Combine (Root, builder.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}.apk.mSYM"); - Assert.IsTrue (Directory.Exists (archivePath), $"Symbol archive path {archivePath} should exist."); - RunProjectAndAssert (proj, builder); - - var logcatPath = Path.Combine (Root, builder.ProjectDirectory, "crash-logcat.log"); - MonitorAdbLogcat ((line) => { - return line.Contains ($"Force finishing activity {proj.PackageName}"); - }, logcatPath, 30); - - var didParse = int.TryParse (proj.TargetSdkVersion, out int apiLevel); - Assert.IsTrue (didParse, $"Unable to parse {proj.TargetSdkVersion} as an int."); - SymbolicateAndAssert (archivePath, logcatPath, new string [] { - Path.Combine (Root, lb.ProjectDirectory, "Class1.cs:12"), - Path.Combine (Root, builder.ProjectDirectory, "MainActivity.cs:23"), - TestEnvironment.UseLocalBuildOutput - ? Path.Combine ("src", "Mono.Android", "obj", XABuildPaths.Configuration, "monoandroid10", $"android-{apiLevel}", "mcw", "Android.App.Activity.cs:") - : $"src/Mono.Android/obj/Release/monoandroid10/android-{apiLevel}/mcw/Android.App.Activity.cs:", - }); - } - } - [Test] public void CustomLinkDescriptionPreserve ([Values (AndroidLinkMode.SdkOnly, AndroidLinkMode.Full)] AndroidLinkMode linkMode) {