Make test more lenient for custom clang version strings
[llvm-project.git] / libc / test / src / time / nanosleep_test.cpp
blob2a6eea4d5e161316317e089e9accef7a3ee7818c
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 //===----------------------------------------------------------------------===//
9 #include <time.h>
11 #include "src/errno/libc_errno.h"
12 #include "src/time/nanosleep.h"
13 #include "test/UnitTest/ErrnoSetterMatcher.h"
14 #include "test/UnitTest/Test.h"
16 namespace cpp = LIBC_NAMESPACE::cpp;
18 TEST(LlvmLibcNanosleep, SmokeTest) {
19 // TODO: When we have the code to read clocks, test that time has passed.
20 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
21 LIBC_NAMESPACE::libc_errno = 0;
23 struct timespec tim = {1, 500};
24 struct timespec tim2 = {0, 0};
25 int ret = LIBC_NAMESPACE::nanosleep(&tim, &tim2);
26 ASSERT_ERRNO_SUCCESS();
27 ASSERT_EQ(ret, 0);