From abf20421c238a297860efca00f090fa3016ba278 Mon Sep 17 00:00:00 2001 From: Julio Barba Date: Tue, 27 Nov 2018 11:17:40 -0500 Subject: [PATCH] Fix flaky test on Raspberry Pi --- src/Test/L0/ProcessInvokerL0.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Test/L0/ProcessInvokerL0.cs b/src/Test/L0/ProcessInvokerL0.cs index cab1475f5f..c6eeda60dc 100644 --- a/src/Test/L0/ProcessInvokerL0.cs +++ b/src/Test/L0/ProcessInvokerL0.cs @@ -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