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_gettype()
9 *
10 * Gets the mutex 'type' attribute.  This attribute is set in the 'type' parameter to
11 * these functions.  The default value is PTHREAD_MUTEX_DEFAULT.
12 *
13 * Testing the default 'type' value.
14 *
15 * Steps:
16 * 1.  Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
17 * 2.  Call pthread_mutexattr_gettype() to check if type
18 *     attribute is set as the default value PTHREAD_MUTEX_DEFAULT.
19 *
20 */
21
22#define _XOPEN_SOURCE 600
23
24#include <pthread.h>
25#include <stdio.h>
26#include "posixtest.h"
27
28int main()
29{
30	pthread_mutexattr_t mta;
31	int type;
32
33	/* Initialize a mutex attributes object */
34	if(pthread_mutexattr_init(&mta) != 0)
35	{
36		perror("Error at pthread_mutexattr_init()\n");
37		return PTS_UNRESOLVED;
38	}
39
40	 /* The default 'type' attribute should be PTHREAD_MUTEX_DEFAULT  */
41	if(pthread_mutexattr_gettype(&mta, &type) != 0)
42	{
43		fprintf(stderr,"pthread_mutexattr_gettype(): Error obtaining the attribute 'type'\n");
44		return PTS_UNRESOLVED;
45	}
46
47	if(type != PTHREAD_MUTEX_DEFAULT)
48	{
49		printf("Test FAILED: Incorrect default mutexattr 'type' value: %d\n", type);
50		return PTS_FAIL;
51	}
52
53	printf("Test PASSED\n");
54	return PTS_PASS;
55}
56