xref: /llvm-project/libc/test/integration/src/pthread/pthread_join_test.cpp (revision 3eb1e6d8e930f5aff17b8d6bcc160f5bbf8cabc7)
1ef094982SNoah Goldstein //===-- Tests for pthread_join-- ------------------------------------------===//
2ef094982SNoah Goldstein //
3ef094982SNoah Goldstein // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4ef094982SNoah Goldstein // See https://llvm.org/LICENSE.txt for license information.
5ef094982SNoah Goldstein // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6ef094982SNoah Goldstein //
7ef094982SNoah Goldstein //===----------------------------------------------------------------------===//
8ef094982SNoah Goldstein 
9ef094982SNoah Goldstein #include "src/pthread/pthread_create.h"
10ef094982SNoah Goldstein #include "src/pthread/pthread_join.h"
11ef094982SNoah Goldstein 
12ef094982SNoah Goldstein #include "src/errno/libc_errno.h"
13ef094982SNoah Goldstein 
14ef094982SNoah Goldstein #include "test/IntegrationTest/test.h"
15ef094982SNoah Goldstein #include <pthread.h>
16ef094982SNoah Goldstein 
simpleFunc(void *)17ef094982SNoah Goldstein static void *simpleFunc(void *) { return nullptr; }
nullJoinTest()18ef094982SNoah Goldstein static void nullJoinTest() {
19ef094982SNoah Goldstein   pthread_t Tid;
20b6bc9d72SGuillaume Chatelet   ASSERT_EQ(LIBC_NAMESPACE::pthread_create(&Tid, nullptr, simpleFunc, nullptr),
21b6bc9d72SGuillaume Chatelet             0);
2273874f7aSGuillaume Chatelet   ASSERT_ERRNO_SUCCESS();
23b6bc9d72SGuillaume Chatelet   ASSERT_EQ(LIBC_NAMESPACE::pthread_join(Tid, nullptr), 0);
2473874f7aSGuillaume Chatelet   ASSERT_ERRNO_SUCCESS();
25ef094982SNoah Goldstein }
26ef094982SNoah Goldstein 
TEST_MAIN()27ef094982SNoah Goldstein TEST_MAIN() {
28*3eb1e6d8Smichaelrj-google   LIBC_NAMESPACE::libc_errno = 0;
29ef094982SNoah Goldstein   nullJoinTest();
30ef094982SNoah Goldstein   return 0;
31ef094982SNoah Goldstein }
32