Dump data in proc test (#86784)
authorDan Moseley <danmose@microsoft.com>
Fri, 26 May 2023 07:56:47 +0000 (02:56 -0500)
committerGitHub <noreply@github.com>
Fri, 26 May 2023 07:56:47 +0000 (09:56 +0200)
src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs

index 1f1c6f8..3936253 100644 (file)
@@ -907,7 +907,20 @@ namespace System.Diagnostics.Tests
 
             double cpuUsage = cpuTimeDiff / (timeDiff * Environment.ProcessorCount);
 
-            Assert.InRange(cpuUsage, 0, 1);
+            try
+            {
+                Assert.InRange(cpuUsage, 0, 1); // InRange is an inclusive test
+            }
+            catch (InRangeException)
+            {
+                string msg = $"Assertion failed. {cpuUsage} is not in range [0,1]. " +
+                             $"proc time before:{processorTimeBeforeSpin.TotalMilliseconds} " +
+                             $"proc time after:{processorTimeAfterSpin.TotalMilliseconds} " +
+                             $"timeDiff:{timeDiff} " +
+                             $"cpuTimeDiff:{cpuTimeDiff} " +
+                             $"Environment.ProcessorCount:{Environment.ProcessorCount}";
+                throw new XunitException(msg);
+            }
         }
 
         [Fact]