[Lldb-commits] [lldb] a5c4f96 - [lldb] Reenable test HostTest.GetProcessInfo with relaxed constraints. (#89637)

via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 25 15:05:49 PDT 2024


Author: Fred Grim
Date: 2024-04-25T15:05:45-07:00
New Revision: a5c4f969f4f2f15a4150229eebff769521759554

URL: https://github.com/llvm/llvm-project/commit/a5c4f969f4f2f15a4150229eebff769521759554
DIFF: https://github.com/llvm/llvm-project/commit/a5c4f969f4f2f15a4150229eebff769521759554.diff

LOG: [lldb] Reenable test HostTest.GetProcessInfo with relaxed constraints. (#89637)

@jimingham I am wondering if you are ok removing this test? It caused
failures in some of the build bots because the user time was less than a
microsecond. Alternatively we can increase the number of loops or maybe
I need some other approach? I had commented it out just to not impact
others

Added: 
    

Modified: 
    lldb/unittests/Host/linux/HostTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Host/linux/HostTest.cpp b/lldb/unittests/Host/linux/HostTest.cpp
index 733909902474d7..8ecaf3ec0decb0 100644
--- a/lldb/unittests/Host/linux/HostTest.cpp
+++ b/lldb/unittests/Host/linux/HostTest.cpp
@@ -69,17 +69,21 @@ TEST_F(HostTest, GetProcessInfo) {
   EXPECT_EQ(HostInfo::GetArchitecture(HostInfo::eArchKindDefault),
             Info.GetArchitecture());
   // Test timings
-  /*
-   * This is flaky in the buildbots on all archs
+  // In some sense this is a pretty trivial test. What it is trying to
+  // accomplish is just to validate that these values are never decreasing
+  // which would be unambiguously wrong. We can not reliably show them
+  // to be always increasing because the microsecond granularity means that,
+  // with hardware variations the number of loop iterations need to always
+  // be increasing for faster and faster machines.
   ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
   ProcessInstanceInfo::timespec user_time = Info.GetUserTime();
   static volatile unsigned u = 0;
   for (unsigned i = 0; i < 10'000'000; i++) {
-    u = i;
+    u += i;
   }
+  ASSERT_TRUE(u > 0);
   ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
   ProcessInstanceInfo::timespec next_user_time = Info.GetUserTime();
-  ASSERT_TRUE(user_time.tv_sec < next_user_time.tv_sec ||
-              user_time.tv_usec < next_user_time.tv_usec);
-  */
+  ASSERT_TRUE(user_time.tv_sec <= next_user_time.tv_sec ||
+              user_time.tv_usec <= next_user_time.tv_usec);
 }


        


More information about the lldb-commits mailing list