Add POSIX test suite 1.5.2 (http://sourceforge.net/projects/posixtest/).
[dragonfly.git] / test / contrib / posixtestsuite-1.5.2 / conformance / interfaces / pthread_attr_setscope / 4-1.c
1 /*
2  * Copyright (c) 2004, Intel Corporation. All rights reserved.
3  * Created by:  crystal.xiong 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 pthread_attr_setscope()
9  *
10  * Steps:
11  * 1.  Initialize a pthread_attr_t object using pthread_attr_init()
12  * 2.  Call pthread_attr_setscope with unsupported scope
13  *     parameter
14  *
15  */
16
17 #include <pthread.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <errno.h>
21 #include "posixtest.h"
22
23 #define TEST "4-1"
24 #define FUNCTION "pthread_attr_setscope"
25 #define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "
26
27 #define INVALIDSCOPE 999
28
29 int main()
30 {
31         int                   rc=0;
32         pthread_attr_t        attr;
33
34         rc = pthread_attr_init(&attr);
35         if (rc != 0) {
36                 perror(ERROR_PREFIX "pthread_attr_init");
37                 exit(PTS_UNRESOLVED);
38         }
39
40         rc = pthread_attr_setscope(&attr, INVALIDSCOPE);
41         if ((rc != EINVAL)) {
42                 perror(ERROR_PREFIX "pthread_attr_setscope");
43                 exit(PTS_FAIL);
44         }
45         rc = pthread_attr_destroy(&attr);
46         if( rc != 0) {
47                 perror(ERROR_PREFIX "pthread_attr_destroy");
48                 exit(PTS_UNRESOLVED);
49         }
50         printf("Test PASS\n");
51         return PTS_PASS;
52 }