blob: e89d4fdfc05763ef08abfe53c021b7caadb003b1 [file] [log] [blame]
//===-- 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/UnitTest/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);
}