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_cond_init()
9 *   Upon succesful completion, it shall return a 0
10 *
11 */
12
13#include <pthread.h>
14#include <stdio.h>
15#include <string.h>
16#include <errno.h>
17#include "posixtest.h"
18
19#define ERR_MSG(f, rc)  printf("Failed: func: %s rc: %s (%u)\n", \
20			f, strerror(rc), rc)
21
22int main(void)
23{
24	pthread_condattr_t condattr;
25	pthread_cond_t cond;
26	int rc;
27	int status = PTS_UNRESOLVED;
28	char *label;
29
30	label = "pthread_condattr_init()";
31	rc = pthread_condattr_init(&condattr);
32	if (rc)
33		goto done;
34
35	label = "pthread_cond_init()";
36	rc = pthread_cond_init(&cond, &condattr);
37	switch (rc) {
38	case 0:
39		break;
40	case ENOMEM:
41	case EINVAL:
42	case EBUSY:
43	case EAGAIN:
44		status = PTS_UNRESOLVED;
45		goto done;
46	default:
47		status = PTS_FAIL;
48		goto done;
49	}
50
51	printf("Test PASSED\n");
52	return PTS_PASS;
53
54done:
55	ERR_MSG(label, rc);
56	return status;
57}
58