summaryrefslogtreecommitdiff
path: root/libc/test/src/time/nanosleep_test.cpp
blob: b66a7e898056b0dcc2cf293f9c18ee5601b2010d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//===-- 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 <time.h>

#include "src/errno/libc_errno.h"
#include "src/time/nanosleep.h"
#include "test/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

namespace cpp = __llvm_libc::cpp;

TEST(LlvmLibcNanosleep, SmokeTest) {
  // TODO: When we have the code to read clocks, test that time has passed.
  using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
  libc_errno = 0;

  struct timespec tim = {1, 500};
  struct timespec tim2 = {0, 0};
  int ret = __llvm_libc::nanosleep(&tim, &tim2);
  ASSERT_EQ(libc_errno, 0);
  ASSERT_EQ(ret, 0);
}