Skip to content

Commit 31c582a

Browse files
committed
adds a test for the user time
1 parent 9b8ec4d commit 31c582a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lldb/unittests/Host/linux/HostTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,14 @@ TEST_F(HostTest, GetProcessInfo) {
6161
EXPECT_TRUE(Info.GetArchitecture().IsValid());
6262
EXPECT_EQ(HostInfo::GetArchitecture(HostInfo::eArchKindDefault),
6363
Info.GetArchitecture());
64+
// Test timings
65+
ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
66+
ProcessInstanceInfo::timespec user_time = Info.GetUserTime();
67+
for (unsigned i = 0; i < 10'000'000; i++) {
68+
__asm__ __volatile__("" : "+g"(i) : :);
69+
}
70+
ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
71+
ProcessInstanceInfo::timespec next_user_time = Info.GetUserTime();
72+
ASSERT_TRUE(user_time.tv_sec < next_user_time.tv_sec ||
73+
user_time.tv_usec < next_user_time.tv_usec);
6474
}

0 commit comments

Comments
 (0)