[libc-commits] [libc] [libc][NFC] Forcing data type in gettimeofday_test when comparing the diff. (PR #69652)
via libc-commits
libc-commits at lists.llvm.org
Thu Oct 19 15:36:17 PDT 2023
https://github.com/lntue created https://github.com/llvm/llvm-project/pull/69652
None
>From 0ee9aeea47bbe21be52bda6c20e64ecfd37a4d3f Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue at google.com>
Date: Thu, 19 Oct 2023 18:32:48 -0400
Subject: [PATCH] [libc][NFC] Forcing data type in gettimeofday_test when
comparing the diff.
---
libc/test/src/time/gettimeofday_test.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libc/test/src/time/gettimeofday_test.cpp b/libc/test/src/time/gettimeofday_test.cpp
index 44250787c5381ef..6f4386ccec30ba8 100644
--- a/libc/test/src/time/gettimeofday_test.cpp
+++ b/libc/test/src/time/gettimeofday_test.cpp
@@ -18,7 +18,7 @@ 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};
for (int i = 0; i < 2; i++) {
@@ -27,15 +27,15 @@ TEST(LlvmLibcGettimeofday, SmokeTest) {
int 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);
+ ASSERT_GE(tv1.tv_usec - tv.tv_usec, static_cast<suseconds_t>(sleep_time));
}
}
More information about the libc-commits
mailing list