From 55090e67045ad1442036127e3f8a1b41b3e6f3fa Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 18 May 2022 19:02:11 -0700 Subject: [PATCH] Run host tests with dotnet test and enable crash/hang dumps (#69340) --- eng/pipelines/installer/jobs/base-job.yml | 2 +- .../jobs/steps/upload-job-artifacts.yml | 36 +++++++++++++++++-- src/installer/tests/Directory.Build.props | 6 +++- .../NativeHosting/ApplicationExecution.cs | 2 +- .../NativeHosting/GetFunctionPointer.cs | 2 +- .../LoadAssemblyAndGetFunctionPointer.cs | 2 +- src/installer/tests/TestUtils/Command.cs | 7 ++++ 7 files changed, 50 insertions(+), 7 deletions(-) diff --git a/eng/pipelines/installer/jobs/base-job.yml b/eng/pipelines/installer/jobs/base-job.yml index 3e23c2007d071..91adf49a85b3c 100644 --- a/eng/pipelines/installer/jobs/base-job.yml +++ b/eng/pipelines/installer/jobs/base-job.yml @@ -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 }} diff --git a/eng/pipelines/installer/jobs/steps/upload-job-artifacts.yml b/eng/pipelines/installer/jobs/steps/upload-job-artifacts.yml index ad01864d59483..6029ba0057197 100644 --- a/eng/pipelines/installer/jobs/steps/upload-job-artifacts.yml +++ b/eng/pipelines/installer/jobs/steps/upload-job-artifacts.yml @@ -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: diff --git a/src/installer/tests/Directory.Build.props b/src/installer/tests/Directory.Build.props index c72ac9f6b67eb..1db6d7ecfa76f 100644 --- a/src/installer/tests/Directory.Build.props +++ b/src/installer/tests/Directory.Build.props @@ -10,7 +10,11 @@ $(ArtifactsObjDir)ExtraNupkgsForTestRestore\ $(TargetArchitecture) $(NetCoreAppToolCurrent) - -notrait category=failing -verbose + --filter category!=failing -v detailed + + $(TestRunnerAdditionalArguments) --blame-crash-dump-type full + $(TestRunnerAdditionalArguments) --blame-hang-timeout 5m --blame-hang-dump-type full + true false diff --git a/src/installer/tests/HostActivation.Tests/NativeHosting/ApplicationExecution.cs b/src/installer/tests/HostActivation.Tests/NativeHosting/ApplicationExecution.cs index cec6b1030e7c7..72899d11b29c2 100644 --- a/src/installer/tests/HostActivation.Tests/NativeHosting/ApplicationExecution.cs +++ b/src/installer/tests/HostActivation.Tests/NativeHosting/ApplicationExecution.cs @@ -52,7 +52,7 @@ public void RunApp_UnhandledException() }; sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot) - .Execute() + .Execute(fExpectedToFail: true) .Should().Fail() .And.InitializeContextForApp(project.AppDll) .And.ExecuteApplicationWithException(sharedState.NativeHostPath, project.AppDll); diff --git a/src/installer/tests/HostActivation.Tests/NativeHosting/GetFunctionPointer.cs b/src/installer/tests/HostActivation.Tests/NativeHosting/GetFunctionPointer.cs index 1f741d696e29f..2f3661e618c3d 100644 --- a/src/installer/tests/HostActivation.Tests/NativeHosting/GetFunctionPointer.cs +++ b/src/installer/tests/HostActivation.Tests/NativeHosting/GetFunctionPointer.cs @@ -204,7 +204,7 @@ public void CallDelegateOnApplicationContext_UnhandledException() }; sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot) - .Execute() + .Execute(fExpectedToFail: true) .Should().Fail() .And.InitializeContextForApp(appProject.AppDll) .And.ExecuteFunctionPointerWithException(entryPoint, 1); diff --git a/src/installer/tests/HostActivation.Tests/NativeHosting/LoadAssemblyAndGetFunctionPointer.cs b/src/installer/tests/HostActivation.Tests/NativeHosting/LoadAssemblyAndGetFunctionPointer.cs index f329de2229c29..083c3c9a0b01f 100644 --- a/src/installer/tests/HostActivation.Tests/NativeHosting/LoadAssemblyAndGetFunctionPointer.cs +++ b/src/installer/tests/HostActivation.Tests/NativeHosting/LoadAssemblyAndGetFunctionPointer.cs @@ -223,7 +223,7 @@ public void CallDelegateOnComponentContext_UnhandledException() }; sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot) - .Execute() + .Execute(fExpectedToFail: true) .Should().Fail() .And.InitializeContextForConfig(componentProject.RuntimeConfigJson) .And.ExecuteComponentEntryPointWithException(entryPoint, 1); diff --git a/src/installer/tests/TestUtils/Command.cs b/src/installer/tests/TestUtils/Command.cs index 726b2ed65da9e..e32d17c9c6665 100644 --- a/src/installer/tests/TestUtils/Command.cs +++ b/src/installer/tests/TestUtils/Command.cs @@ -250,6 +250,13 @@ public CommandResult WaitForExit(bool fExpectedToFail, int timeoutMilliseconds = 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); }