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_setdetachstate()
9 *
10 * shall fail if:
11 * -[EINVAL]  The value of detachstate was not valid
12 *
13 * Steps:
14 * 1.  Initialize a pthread_attr_t object using pthread_attr_init()
15 * 2.  Call pthread_attr_setdetachstate() using an invalid value of 0
16 *
17 */
18
19#include <pthread.h>
20#include <stdio.h>
21#include <errno.h>
22#include "posixtest.h"
23
24int main()
25{
26	pthread_attr_t new_attr;
27	int ret_val, invalid_val;
28
29	/* Initialize attribute */
30	if(pthread_attr_init(&new_attr) != 0)
31	{
32		perror("Cannot initialize attribute object\n");
33		return PTS_UNRESOLVED;
34	}
35
36	/* Set the attribute object to an invalid value of 1000000. */
37	invalid_val=1000000;
38	ret_val=pthread_attr_setdetachstate(&new_attr, invalid_val);
39
40	if(ret_val != EINVAL)
41	{
42		printf("Test FAILED: Returned %d instead of EINVAL\n", ret_val);
43		return PTS_FAIL;
44	}
45
46	printf("Test PASSED\n");
47	return PTS_PASS;
48}
49