Skip to content

Commit a5c4f96

Browse files
authored
[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
1 parent ddb67e6 commit a5c4f96

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lldb/unittests/Host/linux/HostTest.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,21 @@ TEST_F(HostTest, GetProcessInfo) {
6969
EXPECT_EQ(HostInfo::GetArchitecture(HostInfo::eArchKindDefault),
7070
Info.GetArchitecture());
7171
// Test timings
72-
/*
73-
* This is flaky in the buildbots on all archs
72+
// In some sense this is a pretty trivial test. What it is trying to
73+
// accomplish is just to validate that these values are never decreasing
74+
// which would be unambiguously wrong. We can not reliably show them
75+
// to be always increasing because the microsecond granularity means that,
76+
// with hardware variations the number of loop iterations need to always
77+
// be increasing for faster and faster machines.
7478
ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
7579
ProcessInstanceInfo::timespec user_time = Info.GetUserTime();
7680
static volatile unsigned u = 0;
7781
for (unsigned i = 0; i < 10'000'000; i++) {
78-
u = i;
82+
u += i;
7983
}
84+
ASSERT_TRUE(u > 0);
8085
ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
8186
ProcessInstanceInfo::timespec next_user_time = Info.GetUserTime();
82-
ASSERT_TRUE(user_time.tv_sec < next_user_time.tv_sec ||
83-
user_time.tv_usec < next_user_time.tv_usec);
84-
*/
87+
ASSERT_TRUE(user_time.tv_sec <= next_user_time.tv_sec ||
88+
user_time.tv_usec <= next_user_time.tv_usec);
8589
}

0 commit comments

Comments
 (0)