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_create() creates a new thread with attributes specified
9 * by 'attr', within a process.
10 *
11 * Steps:
12 * 1.  Create a thread using pthread_create()
13 * 2.  Compare the thread ID of 'main' to the thread ID of the newly created
14 *     thread. They should be different.
15 */
16
17#include <pthread.h>
18#include <stdio.h>
19#include "posixtest.h"
20
21void *a_thread_func()
22{
23
24	pthread_exit(0);
25	return NULL;
26}
27
28int main()
29{
30	pthread_t main_th, new_th;
31
32	if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0)
33	{
34		perror("Error creating thread\n");
35		return PTS_UNRESOLVED;
36	}
37
38	/* Obtain the thread ID of this main function */
39	main_th=pthread_self();
40
41	/* Compare the thread ID of the new thread to the main thread.
42	 * They should be different.  If not, the test fails. */
43	if(pthread_equal(new_th, main_th) != 0)
44	{
45		printf("Test FAILED: A new thread wasn't created\n");
46		return PTS_FAIL;
47	}
48
49	printf("Test PASSED\n");
50	return PTS_PASS;
51}
52
53
54