xref: /llvm-project/libc/test/src/sys/wait/waitpid_test.cpp (revision 46944b0cbc9a9d8daad0182c40fcd3560bc9ca35)
1995105deSSiva Chandra Reddy //===-- Unittests for waitpid ---------------------------------------------===//
2995105deSSiva Chandra Reddy //
3995105deSSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4995105deSSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information.
5995105deSSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6995105deSSiva Chandra Reddy //
7995105deSSiva Chandra Reddy //===----------------------------------------------------------------------===//
8995105deSSiva Chandra Reddy 
9995105deSSiva Chandra Reddy #include "src/sys/wait/waitpid.h"
104f1fe19dSSiva Chandra Reddy #include "test/UnitTest/ErrnoSetterMatcher.h"
11af1315c2SSiva Chandra Reddy #include "test/UnitTest/Test.h"
12995105deSSiva Chandra Reddy 
13995105deSSiva Chandra Reddy #include <sys/wait.h>
14995105deSSiva Chandra Reddy 
15995105deSSiva Chandra Reddy // The test here is a simpl test for WNOHANG functionality. For a more
16995105deSSiva Chandra Reddy // involved test, look at fork_test.
17995105deSSiva Chandra Reddy 
18995105deSSiva Chandra Reddy TEST(LlvmLibcWaitPidTest, NoHangTest) {
19*b6bc9d72SGuillaume Chatelet   using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
20995105deSSiva Chandra Reddy   int status;
21*b6bc9d72SGuillaume Chatelet   ASSERT_THAT(LIBC_NAMESPACE::waitpid(-1, &status, WNOHANG), Fails(ECHILD));
22995105deSSiva Chandra Reddy }
23