aboutsummaryrefslogtreecommitdiff
path: root/libc/test/src/time/nanosleep_test.cpp
blob: bd143ac2eb25bc9e566c54dfccd044885d33139e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//===-- Unittests for nanosleep -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "hdr/types/struct_timespec.h"
#include "src/time/nanosleep.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/Test.h"

namespace cpp = LIBC_NAMESPACE::cpp;

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};
  ASSERT_EQ(LIBC_NAMESPACE::nanosleep(&tim, &tim2), 0);
}