{
internal static class Helpers
{
+ public const int PassingTestTimeoutMilliseconds = 60_000;
+
public static async Task RetryWithBackoff(Action action, int delayInMilliseconds = 10, int times = 10)
{
// Guards against delay growing to an exceptionally large value. No special technical significance to
}
}
}
+
+ public static void DumpAllProcesses()
+ {
+ Process[] all = Process.GetProcesses();
+ foreach (Process p in all)
+ {
+ Console.WriteLine("{0,8} {1}", p.Id, p.ProcessName);
+ p.Dispose();
+ }
+ }
}
}
{
// In this test, we kill a process in a way the Process instance
// is not aware the process has terminated when we invoke Process.Kill.
-
+ DateTime start = DateTime.UtcNow;
using (Process nonChildProcess = CreateNonChildProcess())
{
// Kill the process.
// process still exists, wait some time.
await Task.Delay(100);
}
+
+ DateTime now = DateTime.UtcNow;
+ if (start.Ticks + (Helpers.PassingTestTimeoutMilliseconds * 10_000) <= now.Ticks)
+ {
+ Console.WriteLine("{0} Failed to kill process {1} started at {2}", now, nonChildProcess.Id, start);
+ Helpers.DumpAllProcesses();
+
+ Assert.True(false, "test timed out");
+ }
}
// Call Process.Kill.