[libc-commits] [libc] [libc] Implement sleep and usleep for Linux (PR #205922)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Tue Jul 21 07:30:08 PDT 2026


================
@@ -17,7 +24,27 @@ using LlvmLibcNanosleep = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
 
 TEST_F(LlvmLibcNanosleep, SmokeTest) {
   // TODO: When we have the code to read clocks, test that time has passed.
-  struct timespec tim = {1, 500};
-  struct timespec tim2 = {0, 0};
+  timespec tim = {1, 500};
+  timespec tim2 = {0, 0};
   ASSERT_EQ(LIBC_NAMESPACE::nanosleep(&tim, &tim2), 0);
 }
+
+TEST_F(LlvmLibcNanosleep, InvalidNsec) {
+  timespec tim = {0, -1};
+  timespec tim2 = {0, 0};
+
+  libc_errno = 0;
----------------
labath wrote:

```suggestion
```

I think ErrnoCheckingTest makes sure errno is always zero.

https://github.com/llvm/llvm-project/pull/205922


More information about the libc-commits mailing list