Skip to content

Commit

Permalink
Fix flaky test on Raspberry Pi
Browse files Browse the repository at this point in the history
  • Loading branch information
Julio Barba committed Nov 27, 2018
1 parent ebe1991 commit abf2042
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Test/L0/ProcessInvokerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,18 @@ public async Task TestCancel()
Assert.True(!execTask.IsFaulted);
Assert.True(execTask.IsCanceled);
watch.Stop();
var elapsedSeconds = watch.ElapsedMilliseconds / 1000;
//if cancellation fails, then execution time is more than 10 seconds
Assert.True(elapsedSeconds < SecondsToRun / 2, $"cancellation failed, because task took too long to run. {elapsedSeconds}");
long elapsedSeconds = watch.ElapsedMilliseconds / 1000;

#if ARM
// if cancellation fails, then execution time is more than 15 seconds
// longer time to compensate for a slower ARM environment (e.g. Raspberry Pi)
long expectedSeconds = (SecondsToRun * 3) / 4;
#else
// if cancellation fails, then execution time is more than 10 seconds
long expectedSeconds = SecondsToRun / 2;
#endif

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

0 comments on commit abf2042

Please sign in to comment.