From 21885b4418c4f7c3419c8e135f6fa918444115e2 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Tue, 3 Nov 2020 17:40:22 -0500 Subject: [PATCH] Add wiggle room to MonitoringIsEnabled test --- .../System.Runtime.Extensions/tests/System/AppDomainTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.Extensions/tests/System/AppDomainTests.cs b/src/libraries/System.Runtime.Extensions/tests/System/AppDomainTests.cs index 438816856c8df8..0d29fc0f5b8933 100644 --- a/src/libraries/System.Runtime.Extensions/tests/System/AppDomainTests.cs +++ b/src/libraries/System.Runtime.Extensions/tests/System/AppDomainTests.cs @@ -391,8 +391,10 @@ public void MonitoringIsEnabled() using (Process p = Process.GetCurrentProcess()) { TimeSpan processTime = p.UserProcessorTime; + Assert.InRange(processTime, TimeSpan.Zero, TimeSpan.MaxValue); + TimeSpan monitoringTime = AppDomain.CurrentDomain.MonitoringTotalProcessorTime; - Assert.InRange(monitoringTime, processTime, TimeSpan.MaxValue); + Assert.InRange(monitoringTime, processTime * 0.95, TimeSpan.MaxValue); // *0.95 for a bit of wiggle room due to precision differences with employed timing mechanisms } GC.KeepAlive(o);