Skip to content

Commit 4caf064

Browse files
authored
[Tests] Add more logging for runtime test timeouts (dotnet#109998)
* Add more logs * Flush writers and format active process listing * Temporarily force timeout * Revert "Temporarily force timeout" This reverts commit 9a775c2.
1 parent 2a77961 commit 4caf064

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ public static bool TryPrintStackTraceFromDmp(string dmpFile, TextWriter outputWr
642642
// The children are sorted in the order they should be dumped
643643
static unsafe IEnumerable<Process> FindChildProcessesByName(Process process, string childName)
644644
{
645+
Console.WriteLine($"Finding all child processes of '{process.ProcessName}' (ID: {process.Id}) with name '{childName}'");
646+
645647
var children = new Stack<Process>();
646648
Queue<Process> childrenToCheck = new Queue<Process>();
647649
HashSet<int> seen = new HashSet<int>();
@@ -656,6 +658,7 @@ static unsafe IEnumerable<Process> FindChildProcessesByName(Process process, str
656658
if (seen.Contains(child.Id))
657659
continue;
658660

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

661664
foreach (var grandchild in child.GetChildren())
@@ -784,9 +787,19 @@ public int RunTest(string executable, string outputFile, string errorFile, strin
784787
outputWriter.WriteLine("\ncmdLine:{0} Timed Out (timeout in milliseconds: {1}{2}{3}, start: {4}, end: {5})",
785788
executable, timeout, (environmentVar != null) ? " from variable " : "", (environmentVar != null) ? TIMEOUT_ENVIRONMENT_VAR : "",
786789
startTime.ToString(), endTime.ToString());
790+
outputWriter.Flush();
787791
errorWriter.WriteLine("\ncmdLine:{0} Timed Out (timeout in milliseconds: {1}{2}{3}, start: {4}, end: {5})",
788792
executable, timeout, (environmentVar != null) ? " from variable " : "", (environmentVar != null) ? TIMEOUT_ENVIRONMENT_VAR : "",
789793
startTime.ToString(), endTime.ToString());
794+
errorWriter.Flush();
795+
796+
Console.WriteLine("Collecting diagnostic information...");
797+
Console.WriteLine("Snapshot of processes currently running:");
798+
Console.WriteLine($"\t{"ID",-6} ProcessName");
799+
foreach (var activeProcess in Process.GetProcesses())
800+
{
801+
Console.WriteLine($"\t{activeProcess.Id,-6} {activeProcess.ProcessName}");
802+
}
790803

791804
if (collectCrashDumps)
792805
{

src/tests/Loader/binding/tracing/BinderTracingTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ private static bool RunSingleTest(MethodInfo method)
189189

190190
private static bool RunTestInSeparateProcess(MethodInfo method)
191191
{
192-
var startInfo = new ProcessStartInfo(Process.GetCurrentProcess().MainModule.FileName, new[] { Assembly.GetExecutingAssembly().Location, method.Name })
192+
string subprocessName = Process.GetCurrentProcess().MainModule.FileName;
193+
var startInfo = new ProcessStartInfo(subprocessName, new[] { Assembly.GetExecutingAssembly().Location, method.Name })
193194
{
194195
UseShellExecute = false,
195196
RedirectStandardOutput = true,
@@ -199,7 +200,7 @@ private static bool RunTestInSeparateProcess(MethodInfo method)
199200
Console.WriteLine($"[{DateTime.Now:T}] Launching process for {method.Name}...");
200201
using (Process p = Process.Start(startInfo))
201202
{
202-
Console.WriteLine($"Started subprocess {p.Id} for {method.Name}...");
203+
Console.WriteLine($"Started subprocess '{subprocessName}' with PID {p.Id} for {method.Name}...");
203204
p.OutputDataReceived += (_, args) => Console.WriteLine(args.Data);
204205
p.BeginOutputReadLine();
205206

0 commit comments

Comments
 (0)