1 //===-- Unittests for nanosleep -------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "hdr/types/struct_timespec.h" 10 #include "src/errno/libc_errno.h" 11 #include "src/time/nanosleep.h" 12 #include "test/UnitTest/ErrnoSetterMatcher.h" 13 #include "test/UnitTest/Test.h" 14 15 namespace cpp = LIBC_NAMESPACE::cpp; 16 17 TEST(LlvmLibcNanosleep, SmokeTest) { 18 // TODO: When we have the code to read clocks, test that time has passed. 19 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; 20 LIBC_NAMESPACE::libc_errno = 0; 21 22 struct timespec tim = {1, 500}; 23 struct timespec tim2 = {0, 0}; 24 int ret = LIBC_NAMESPACE::nanosleep(&tim, &tim2); 25 ASSERT_ERRNO_SUCCESS(); 26 ASSERT_EQ(ret, 0); 27 } 28