Run host tests with dotnet test and enable crash/hang dumps (#69340)
authorElinor Fung <elfung@microsoft.com>
Thu, 19 May 2022 02:02:11 +0000 (19:02 -0700)
committerGitHub <noreply@github.com>
Thu, 19 May 2022 02:02:11 +0000 (19:02 -0700)
eng/pipelines/installer/jobs/base-job.yml
eng/pipelines/installer/jobs/steps/upload-job-artifacts.yml
src/installer/tests/Directory.Build.props
src/installer/tests/HostActivation.Tests/NativeHosting/ApplicationExecution.cs
src/installer/tests/HostActivation.Tests/NativeHosting/GetFunctionPointer.cs
src/installer/tests/HostActivation.Tests/NativeHosting/LoadAssemblyAndGetFunctionPointer.cs
src/installer/tests/TestUtils/Command.cs

index 3e23c20..91adf49 100644 (file)
@@ -472,7 +472,7 @@ jobs:
       name: ${{ coalesce(parameters.name, parameters.platform) }}
       runtimeFlavor: ${{ parameters.runtimeFlavor }}
       runtimeVariant: ${{ parameters.runtimeVariant }}
-      skipTests: $(SkipTests)
+      skipTests: ${{ variables.SkipTests }}
       isOfficialBuild: ${{ eq(parameters.isOfficialBuild, true) }}
       pgoType: ${{ parameters.pgoType }}
 
index ad01864..6029ba0 100644 (file)
@@ -15,14 +15,46 @@ steps:
 - task: PublishTestResults@2
   displayName: Publish Test Results
   inputs:
-    testResultsFormat: 'xUnit'
-    testResultsFiles: '*.xml'
+    testResultsFormat: 'VSTest'
+    testResultsFiles: '*.trx'
     searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)'
     mergeTestResults: true
     testRunTitle: Installer-${{ parameters.runtimeFlavor }}-${{ parameters.name }}-$(_BuildConfig)
   continueOnError: true
   condition: eq(variables.SkipTests, false)
 
+# Upload binaries and symbols on failure to allow debugging issues
+- ${{ if eq(parameters.skipTests, false) }}:
+  - task: CopyFiles@2
+    displayName: Prepare binaries to publish
+    inputs:
+      SourceFolder: '$(Build.SourcesDirectory)/artifacts/bin'
+      Contents: |
+        */corehost/**
+        */corehost_test/**
+      TargetFolder: '$(Build.StagingDirectory)/Binaries'
+    continueOnError: true
+    condition: failed()
+
+  - task: ArchiveFiles@2
+    displayName: Zip binaries
+    inputs:
+      rootFolderOrFile: '$(Build.StagingDirectory)/Binaries'
+      archiveFile: '$(Build.StagingDirectory)/corehost-bin-${{ parameters.name }}-$(_BuildConfig)$(archiveExtension)'
+      archiveType: $(archiveType)
+      tarCompression: $(tarCompression)
+      includeRootFolder: false
+    continueOnError: true
+    condition: failed()
+
+  - task: PublishBuildArtifacts@1
+    displayName: Publish binaries
+    inputs:
+      pathtoPublish: '$(Build.StagingDirectory)/corehost-bin-${{ parameters.name }}-$(_BuildConfig)$(archiveExtension)'
+      artifactName: Installer-Binaries-${{parameters.pgoType }}${{ parameters.runtimeFlavor }}-${{ parameters.runtimeVariant }}-${{ parameters.name }}-$(_BuildConfig)
+    continueOnError: true
+    condition: failed()
+
 - task: CopyFiles@2
   displayName: Prepare BuildLogs staging directory
   inputs:
index c72ac9f..1db6d7e 100644 (file)
     <InternalNupkgCacheDir>$(ArtifactsObjDir)ExtraNupkgsForTestRestore\</InternalNupkgCacheDir>
     <TestArchitectures>$(TargetArchitecture)</TestArchitectures>
     <TestInfraTargetFramework>$(NetCoreAppToolCurrent)</TestInfraTargetFramework>
-    <TestRunnerAdditionalArguments>-notrait category=failing -verbose</TestRunnerAdditionalArguments>
+    <TestRunnerAdditionalArguments>--filter category!=failing -v detailed</TestRunnerAdditionalArguments>
+    <!-- Enable crash and hang dumps -->
+    <TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --blame-crash-dump-type full</TestRunnerAdditionalArguments>
+    <TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --blame-hang-timeout 5m --blame-hang-dump-type full</TestRunnerAdditionalArguments>
+    <UseVSTestRunner>true</UseVSTestRunner>
     <RunAnalyzers>false</RunAnalyzers>
   </PropertyGroup>
 
index cec6b10..72899d1 100644 (file)
@@ -52,7 +52,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
             };
 
             sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
-                .Execute()
+                .Execute(fExpectedToFail: true)
                 .Should().Fail()
                 .And.InitializeContextForApp(project.AppDll)
                 .And.ExecuteApplicationWithException(sharedState.NativeHostPath, project.AppDll);
index 1f741d6..2f3661e 100644 (file)
@@ -204,7 +204,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
             };
 
             sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
-                .Execute()
+                .Execute(fExpectedToFail: true)
                 .Should().Fail()
                 .And.InitializeContextForApp(appProject.AppDll)
                 .And.ExecuteFunctionPointerWithException(entryPoint, 1);
index f329de2..083c3c9 100644 (file)
@@ -223,7 +223,7 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
             };
 
             sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
-                .Execute()
+                .Execute(fExpectedToFail: true)
                 .Should().Fail()
                 .And.InitializeContextForConfig(componentProject.RuntimeConfigJson)
                 .And.ExecuteComponentEntryPointWithException(entryPoint, 1);
index 726b2ed..e32d17c 100644 (file)
@@ -250,6 +250,13 @@ namespace Microsoft.DotNet.Cli.Build.Framework
 
         public CommandResult Execute(bool fExpectedToFail)
         {
+            // Clear out any enabling of dump creation if failure is expected
+            if (fExpectedToFail)
+            {
+                EnvironmentVariable("COMPlus_DbgEnableMiniDump", null);
+                EnvironmentVariable("DOTNET_DbgEnableMiniDump", null);
+            }
+
             Start();
             return WaitForExit(fExpectedToFail);
         }