Skip to content

Commit

Permalink
Added debug trace
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanduplenskikh committed Jan 26, 2023
1 parent df73f63 commit 3aa7285
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Test/L0/ProcessInvokerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public async Task TestCancel()
processInvoker.Initialize(hc);
Stopwatch watch = Stopwatch.StartNew();
Task execTask;

trace.Info($"Before start executing elapsed ms: {watch.ElapsedMilliseconds}");

if (TestUtil.IsWindows())
{
execTask = processInvoker.ExecuteAsync("", "cmd", $"/c \"ping 127.0.0.1 -n {SecondsToRun} > nul\"", null, tokenSource.Token);
Expand All @@ -66,8 +69,15 @@ public async Task TestCancel()
execTask = processInvoker.ExecuteAsync("", "bash", $"-c \"sleep {SecondsToRun}s\"", null, tokenSource.Token);
}

trace.Info($"After start executing elapsed ms: {watch.ElapsedMilliseconds}");

await Task.Delay(500);

trace.Info($"After delay elapsed ms: {watch.ElapsedMilliseconds}");

tokenSource.Cancel();

trace.Info($"After cancelling elapsed ms: {watch.ElapsedMilliseconds}");
try
{
await execTask;
Expand All @@ -86,6 +96,8 @@ public async Task TestCancel()
// if cancellation fails, then execution time is more than 15 seconds
long expectedSeconds = (SecondsToRun * 3) / 4;

trace.Info($"Before assert elapsed ms: {watch.ElapsedMilliseconds}");

Assert.True(elapsedSeconds <= expectedSeconds, $"cancellation failed, because task took too long to run. {elapsedSeconds}");
}
}
Expand Down

0 comments on commit 3aa7285

Please sign in to comment.