Skip to content

Commit 6d53fde

Browse files
authored
[libc][NFC] Attempt to deflake gettimeofday_test. (#69719)
Only check if gettimeofday call succeeds.
1 parent ab76a7c commit 6d53fde

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

libc/test/src/time/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,9 @@ add_libc_unittest(
5656
libc_time_unittests
5757
SRCS
5858
gettimeofday_test.cpp
59-
HDRS
60-
TmHelper.h
61-
TmMatcher.h
62-
CXX_STANDARD
63-
20
6459
DEPENDS
6560
libc.include.time
6661
libc.src.time.gettimeofday
67-
libc.src.time.nanosleep
68-
libc.src.errno.errno
6962
)
7063

7164
add_libc_unittest(

libc/test/src/time/gettimeofday_test.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,10 @@
99
#include <time.h>
1010

1111
#include "src/time/gettimeofday.h"
12-
#include "src/time/nanosleep.h"
13-
#include "test/UnitTest/ErrnoSetterMatcher.h"
1412
#include "test/UnitTest/Test.h"
1513

16-
namespace cpp = LIBC_NAMESPACE::cpp;
17-
1814
TEST(LlvmLibcGettimeofday, SmokeTest) {
19-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
20-
void *tz = nullptr;
2115
timeval tv;
22-
23-
suseconds_t sleep_times[2] = {200, 1000};
24-
for (int i = 0; i < 2; i++) {
25-
int ret = LIBC_NAMESPACE::gettimeofday(&tv, tz);
26-
ASSERT_EQ(ret, 0);
27-
28-
suseconds_t sleep_time = sleep_times[i];
29-
// Sleep for {sleep_time} microsceconds.
30-
timespec tim = {0, sleep_time * 1000};
31-
timespec tim2 = {0, 0};
32-
ret = LIBC_NAMESPACE::nanosleep(&tim, &tim2);
33-
34-
// Call gettimeofday again and verify that it is more {sleep_time}
35-
// microscecods.
36-
timeval tv1;
37-
ret = LIBC_NAMESPACE::gettimeofday(&tv1, tz);
38-
ASSERT_EQ(ret, 0);
39-
ASSERT_GE(tv1.tv_usec - tv.tv_usec, sleep_time);
40-
}
16+
int ret = LIBC_NAMESPACE::gettimeofday(&tv, nullptr);
17+
ASSERT_EQ(ret, 0);
4118
}

0 commit comments

Comments
 (0)