Skip to content

Commit

Permalink
[Tests] Add more logging for runtime test timeouts (dotnet#109998)
Browse files Browse the repository at this point in the history
* Add more logs

* Flush writers and format active process listing

* Temporarily force timeout

* Revert "Temporarily force timeout"

This reverts commit 9a775c2.
  • Loading branch information
mdh1418 authored and mikelle-rogers committed Dec 4, 2024
1 parent d8f9576 commit 0173fec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,8 @@ public static bool TryPrintStackTraceFromDmp(string dmpFile, TextWriter outputWr
// The children are sorted in the order they should be dumped
static unsafe IEnumerable<Process> FindChildProcessesByName(Process process, string childName)
{
Console.WriteLine($"Finding all child processes of '{process.ProcessName}' (ID: {process.Id}) with name '{childName}'");

var children = new Stack<Process>();
Queue<Process> childrenToCheck = new Queue<Process>();
HashSet<int> seen = new HashSet<int>();
Expand All @@ -656,6 +658,7 @@ static unsafe IEnumerable<Process> FindChildProcessesByName(Process process, str
if (seen.Contains(child.Id))
continue;

Console.WriteLine($"Checking child process: '{child.ProcessName}' (ID: {child.Id})");
seen.Add(child.Id);

foreach (var grandchild in child.GetChildren())
Expand Down Expand Up @@ -784,9 +787,19 @@ public int RunTest(string executable, string outputFile, string errorFile, strin
outputWriter.WriteLine("\ncmdLine:{0} Timed Out (timeout in milliseconds: {1}{2}{3}, start: {4}, end: {5})",
executable, timeout, (environmentVar != null) ? " from variable " : "", (environmentVar != null) ? TIMEOUT_ENVIRONMENT_VAR : "",
startTime.ToString(), endTime.ToString());
outputWriter.Flush();
errorWriter.WriteLine("\ncmdLine:{0} Timed Out (timeout in milliseconds: {1}{2}{3}, start: {4}, end: {5})",
executable, timeout, (environmentVar != null) ? " from variable " : "", (environmentVar != null) ? TIMEOUT_ENVIRONMENT_VAR : "",
startTime.ToString(), endTime.ToString());
errorWriter.Flush();

Console.WriteLine("Collecting diagnostic information...");
Console.WriteLine("Snapshot of processes currently running:");
Console.WriteLine($"\t{"ID",-6} ProcessName");
foreach (var activeProcess in Process.GetProcesses())
{
Console.WriteLine($"\t{activeProcess.Id,-6} {activeProcess.ProcessName}");
}

if (collectCrashDumps)
{
Expand Down
5 changes: 3 additions & 2 deletions src/tests/Loader/binding/tracing/BinderTracingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ private static bool RunSingleTest(MethodInfo method)

private static bool RunTestInSeparateProcess(MethodInfo method)
{
var startInfo = new ProcessStartInfo(Process.GetCurrentProcess().MainModule.FileName, new[] { Assembly.GetExecutingAssembly().Location, method.Name })
string subprocessName = Process.GetCurrentProcess().MainModule.FileName;
var startInfo = new ProcessStartInfo(subprocessName, new[] { Assembly.GetExecutingAssembly().Location, method.Name })
{
UseShellExecute = false,
RedirectStandardOutput = true,
Expand All @@ -199,7 +200,7 @@ private static bool RunTestInSeparateProcess(MethodInfo method)
Console.WriteLine($"[{DateTime.Now:T}] Launching process for {method.Name}...");
using (Process p = Process.Start(startInfo))
{
Console.WriteLine($"Started subprocess {p.Id} for {method.Name}...");
Console.WriteLine($"Started subprocess '{subprocessName}' with PID {p.Id} for {method.Name}...");
p.OutputDataReceived += (_, args) => Console.WriteLine(args.Data);
p.BeginOutputReadLine();

Expand Down

0 comments on commit 0173fec

Please sign in to comment.