diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs index a02cc15c3a6626..832772b27a101f 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs @@ -878,9 +878,11 @@ public unsafe void TestTotalProcessorTimeMacOs() void AssertTime(TimeSpan managed, TimeSpan native, string label) { + const double ToleranceInMicroseconds = 20; + double differenceUs = (managed - native).TotalMicroseconds; Assert.True( - managed >= native, - $"Time '{label}' returned by managed API ({managed}) should be greated or equal to the time returned by native API ({native})."); + differenceUs >= -ToleranceInMicroseconds, + $"Time '{label}' returned by managed API ({managed}) should be greater or equal to the time returned by native API ({native}) within a tolerance of {ToleranceInMicroseconds} μs."); } }