[libc-commits] [libc] 6d53fde - [libc][NFC] Attempt to deflake gettimeofday_test. (#69719)

via libc-commits libc-commits at lists.llvm.org
Fri Oct 20 08:08:06 PDT 2023


Author: lntue
Date: 2023-10-20T11:08:01-04:00
New Revision: 6d53fdeab40fe2030db0f618be1a5e6e4ce70bef

URL: https://github.com/llvm/llvm-project/commit/6d53fdeab40fe2030db0f618be1a5e6e4ce70bef
DIFF: https://github.com/llvm/llvm-project/commit/6d53fdeab40fe2030db0f618be1a5e6e4ce70bef.diff

LOG: [libc][NFC] Attempt to deflake gettimeofday_test. (#69719)

Only check if gettimeofday call succeeds.

Added: 
    

Modified: 
    libc/test/src/time/CMakeLists.txt
    libc/test/src/time/gettimeofday_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/time/CMakeLists.txt b/libc/test/src/time/CMakeLists.txt
index fd8f9762647f483..10b63ce6f39d295 100644
--- a/libc/test/src/time/CMakeLists.txt
+++ b/libc/test/src/time/CMakeLists.txt
@@ -56,16 +56,9 @@ add_libc_unittest(
     libc_time_unittests
   SRCS
     gettimeofday_test.cpp
-  HDRS
-    TmHelper.h
-    TmMatcher.h
-  CXX_STANDARD
-    20
   DEPENDS
     libc.include.time
     libc.src.time.gettimeofday
-    libc.src.time.nanosleep
-    libc.src.errno.errno
 )
 
 add_libc_unittest(

diff  --git a/libc/test/src/time/gettimeofday_test.cpp b/libc/test/src/time/gettimeofday_test.cpp
index 2deb7726264ee39..ee934b7f3a20102 100644
--- a/libc/test/src/time/gettimeofday_test.cpp
+++ b/libc/test/src/time/gettimeofday_test.cpp
@@ -9,33 +9,10 @@
 #include <time.h>
 
 #include "src/time/gettimeofday.h"
-#include "src/time/nanosleep.h"
-#include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
-namespace cpp = LIBC_NAMESPACE::cpp;
-
 TEST(LlvmLibcGettimeofday, SmokeTest) {
-  using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
-  void *tz = nullptr;
   timeval tv;
-
-  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);
-
-    suseconds_t sleep_time = sleep_times[i];
-    // Sleep for {sleep_time} microsceconds.
-    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.
-    timeval tv1;
-    ret = LIBC_NAMESPACE::gettimeofday(&tv1, tz);
-    ASSERT_EQ(ret, 0);
-    ASSERT_GE(tv1.tv_usec - tv.tv_usec, sleep_time);
-  }
+  int ret = LIBC_NAMESPACE::gettimeofday(&tv, nullptr);
+  ASSERT_EQ(ret, 0);
 }


        


More information about the libc-commits mailing list