Skip to content

Commit

Permalink
Capture dump on timeout (#5602)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingosse authored May 23, 2024
1 parent 5946a8d commit 9efea18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ public void Run(MockDatadogAgent agent)
PrintTestInfo();
}

public bool WaitForExitOrCaptureDump(Process process, int milliseconds)
{
var success = process.WaitForExit(milliseconds);

if (!success)
{
process.GetAllThreadsStack(_testBaseOutputDir, _output);
process.TakeMemoryDump(_testBaseOutputDir, _output);
}

return success;
}

public ProcessHelper LaunchProcess(MockDatadogAgent agent = null)
{
var (executor, arguments) = BuildTestCommandLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ public void RedirectCrashHandler(string appName, string framework, string appAss
var runner = new TestApplicationRunner(appName, framework, appAssembly, _output, enableTracer: true, commandLine: "--scenario 7");

runner.Environment.SetVariable("COMPlus_DbgMiniDumpType", string.Empty);

RegisterCrashHandler(runner);

using var processHelper = runner.LaunchProcess();

processHelper.Process.WaitForExit(milliseconds: 30_000).Should().BeTrue();
runner.WaitForExitOrCaptureDump(processHelper.Process, milliseconds: 30_000).Should().BeTrue();
processHelper.Drain();
processHelper.ErrorOutput.Should().Contain("Unhandled exception. System.InvalidOperationException: Task failed successfully");
processHelper.StandardOutput.Should().MatchRegex(@"createdump [\w\.\/]+createdump \d+")
Expand All @@ -111,7 +111,7 @@ public void DontRedirectCrashHandlerIfPathNotSet(string appName, string framewor

using var processHelper = runner.LaunchProcess();

processHelper.Process.WaitForExit(milliseconds: 30_000).Should().BeTrue();
runner.WaitForExitOrCaptureDump(processHelper.Process, milliseconds: 30_000).Should().BeTrue();
processHelper.Drain();
processHelper.ErrorOutput.Should().Contain("Unhandled exception. System.InvalidOperationException: Task failed successfully");
processHelper.StandardOutput.Should().NotMatchRegex(@"createdump [\w\.\/]+createdump \d+")
Expand Down

0 comments on commit 9efea18

Please sign in to comment.