1 /* 2 * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 * Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com 4 * This file is licensed under the GPL license. For the full content 5 * of this license, see the COPYING file at the top level of this 6 * source tree. 7 * 8 * Test that pthread_join() 9 * 10 * Upon successful completion, it returns 0; 11 * 12 * Steps: 13 * 1. Create a new thread. 14 * 2. Join that thread to main. If the return code is not 0, 15 * or the other valid error codes of EINVAL, ESRCH or EDEADLK, 16 * then the test fails. 17 */ 18 19 #include <pthread.h> 20 #include <stdio.h> 21 #include <unistd.h> 22 #include <errno.h> 23 #include "posixtest.h" 24 25 static void *a_thread_func() 26 { 27 pthread_exit(0); 28 return NULL; 29 } 30 31 int main(void) 32 { 33 pthread_t new_th; 34 int ret; 35 36 if (pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { 37 perror("Error creating thread\n"); 38 return PTS_UNRESOLVED; 39 } 40 41 ret = pthread_join(new_th, NULL); 42 if (ret != 0) { 43 if ((ret != EINVAL) && (ret != ESRCH) && (ret != EDEADLK)) { 44 printf("Test FAILED: Invalid return code %d.\n", ret); 45 return PTS_FAIL; 46 } 47 } 48 49 printf("Test PASSED\n"); 50 return PTS_PASS; 51 } 52