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_attr_getdetachstate()
9 * shall get the detachstate attribute in the 'attr' object.  The detach state
10 * is either PTHREAD_CREATE_DETACHED or PTHEAD_CREATE_JOINABLE.
11 *
12 * Steps:
13 * 1.  Initialize a pthread_attr_t object using pthread_attr_init()
14 * 2.  Using pthread_attr_getdetachstate(), get the detachstate of the
15 *     attribute object.  It should be PTHREAD_CREATE_JOINABLE.
16 *
17 */
18
19#include <pthread.h>
20#include <stdio.h>
21#include "posixtest.h"
22
23int main()
24{
25	pthread_attr_t new_attr;
26	int detach_state;
27
28	/* Initialize attribute */
29	if(pthread_attr_init(&new_attr) != 0)
30	{
31		perror("Cannot initialize attribute object\n");
32		return PTS_UNRESOLVED;
33	}
34
35	/* The test passes if pthread_attr_getdetachstate gets the attribute
36	 * of PTHREAD_CREATE_JOINABLE from the attribute object. */
37	if(pthread_attr_getdetachstate(&new_attr, &detach_state) != 0)
38	{
39		printf("Test FAILED\n");
40		return PTS_FAIL;
41	}
42
43	if(detach_state == PTHREAD_CREATE_JOINABLE)
44	{
45		printf("Test PASSED\n");
46		return PTS_PASS;
47	}
48	else
49	{
50		printf("Test FAILED\n");
51		return PTS_FAIL;
52	}
53}
54
55
56