1/*
2 * Copyright (c) 2002, Intel Corporation. All rights reserved.
3 * Created by:  bing.wei.liu 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_mutexattr_setpshared()
9 *
10 * It MAY fail if:
11 *
12 * [EINVAL] - the new value pshared value is outside the range of legal values for that
13 *            attribute.
14 *
15 * Steps:
16 *
17 * 1. Pass to pthread_mutexattr_setpshared() a negative value in the 'pshared' parameter..
18 * 2. It may return the value of EINVAL.
19 *
20 */
21
22#include <pthread.h>
23#include <stdio.h>
24#include <errno.h>
25#include "posixtest.h"
26
27#define INVALID_PSHARED_VALUE -1
28
29int main()
30{
31
32	/* Make sure there is process-shared capability. */
33	#ifndef PTHREAD_PROCESS_SHARED
34	fprintf(stderr,"process-shared attribute is not available for testing\n");
35	return PTS_UNRESOLVED;
36	#endif
37
38	pthread_mutexattr_t mta;
39	int ret;
40
41	 /* Set the attribute to INVALID_PSHARED_VALUE.  */
42	ret=pthread_mutexattr_setpshared(&mta, INVALID_PSHARED_VALUE);
43	if(ret != 0)
44	{
45		if(ret == EINVAL)
46		{
47			printf("Test PASSED\n");
48			return PTS_PASS;
49		}
50
51		printf("Test FAILED: Expected return code 0 or EINVAL, got: %d", ret);
52		return PTS_FAIL;
53	}
54
55	printf("Test PASSED: NOTE*: Returned 0 on error, though standard states 'may' fail.\n");
56       	return PTS_PASS;
57
58}
59