From 374917fb6f09cf7445f6b4b430bc8cc807bf0012 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Mar 2022 21:42:02 -0500 Subject: [PATCH] tweak platform tests for CPU time to avoid bogus failures on windows --- unittest/utils/test_platform.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/unittest/utils/test_platform.cpp b/unittest/utils/test_platform.cpp index 37e749b9be..a809b61458 100644 --- a/unittest/utils/test_platform.cpp +++ b/unittest/utils/test_platform.cpp @@ -21,7 +21,7 @@ TEST(Platform, clock) // spend some time computing pi constexpr double known_pi = 3.141592653589793238462643; - constexpr int n = 10000000; + constexpr int n = 100000000; constexpr double h = 1.0 / (double)n; double my_pi = 0.0, x; for (int i = 0; i < n; ++i) { @@ -34,7 +34,8 @@ TEST(Platform, clock) ASSERT_NEAR(my_pi, known_pi, 1e-12); ASSERT_GT(wt_used, 1e-4); - ASSERT_GT(ct_used, 1e-4); + // windows sometimes incorrectly reports used CPU time as 0.0 + if (ct_used != 0.0) ASSERT_GT(ct_used, 1e-4); } TEST(Platform, putenv_unsetenv)