Skip to content

[libc][NFC] Forcing data type in gettimeofday_test when comparing the diff. #69652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions libc/test/src/time/gettimeofday_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ namespace cpp = LIBC_NAMESPACE::cpp;
TEST(LlvmLibcGettimeofday, SmokeTest) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
void *tz = nullptr;
struct timeval tv;
timeval tv;

int sleep_times[2] = {200, 1000};
suseconds_t sleep_times[2] = {200, 1000};
for (int i = 0; i < 2; i++) {
int ret = LIBC_NAMESPACE::gettimeofday(&tv, tz);
ASSERT_EQ(ret, 0);

int sleep_time = sleep_times[i];
suseconds_t sleep_time = sleep_times[i];
// Sleep for {sleep_time} microsceconds.
struct timespec tim = {0, sleep_time * 1000};
struct timespec tim2 = {0, 0};
timespec tim = {0, sleep_time * 1000};
timespec tim2 = {0, 0};
ret = LIBC_NAMESPACE::nanosleep(&tim, &tim2);

// Call gettimeofday again and verify that it is more {sleep_time}
// microscecods.
struct timeval tv1;
timeval tv1;
ret = LIBC_NAMESPACE::gettimeofday(&tv1, tz);
ASSERT_EQ(ret, 0);
ASSERT_GE(tv1.tv_usec - tv.tv_usec, sleep_time);
Expand Down