19372e42fSRaman Tenneti //===-- Unittests for nanosleep -------------------------------------------===// 28f1e362eSRaman Tenneti // 38f1e362eSRaman Tenneti // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 48f1e362eSRaman Tenneti // See https://llvm.org/LICENSE.txt for license information. 58f1e362eSRaman Tenneti // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 68f1e362eSRaman Tenneti // 78f1e362eSRaman Tenneti //===----------------------------------------------------------------------===// 88f1e362eSRaman Tenneti 9*f9c2377fSMichael Jones #include "hdr/types/struct_timespec.h" 10b98c1906SRaman Tenneti #include "src/errno/libc_errno.h" 118f1e362eSRaman Tenneti #include "src/time/nanosleep.h" 124f1fe19dSSiva Chandra Reddy #include "test/UnitTest/ErrnoSetterMatcher.h" 13af1315c2SSiva Chandra Reddy #include "test/UnitTest/Test.h" 148f1e362eSRaman Tenneti 15b6bc9d72SGuillaume Chatelet namespace cpp = LIBC_NAMESPACE::cpp; 168f1e362eSRaman Tenneti 178f1e362eSRaman Tenneti TEST(LlvmLibcNanosleep, SmokeTest) { 188f1e362eSRaman Tenneti // TODO: When we have the code to read clocks, test that time has passed. 19b6bc9d72SGuillaume Chatelet using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; 203eb1e6d8Smichaelrj-google LIBC_NAMESPACE::libc_errno = 0; 218f1e362eSRaman Tenneti 228f1e362eSRaman Tenneti struct timespec tim = {1, 500}; 238f1e362eSRaman Tenneti struct timespec tim2 = {0, 0}; 24b6bc9d72SGuillaume Chatelet int ret = LIBC_NAMESPACE::nanosleep(&tim, &tim2); 2573874f7aSGuillaume Chatelet ASSERT_ERRNO_SUCCESS(); 268f1e362eSRaman Tenneti ASSERT_EQ(ret, 0); 278f1e362eSRaman Tenneti } 28