Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / test / src / time / nanosleep_test.cpp
blob2826ed14dfedabaa092375d9b0af5d2ed138577c
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_errno = 0;
23 struct timespec tim = {1, 500};
24 struct timespec tim2 = {0, 0};
25 int ret = LIBC_NAMESPACE::nanosleep(&tim, &tim2);
26 ASSERT_EQ(libc_errno, 0);
27 ASSERT_EQ(ret, 0);