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 <string.h> 20 #include <errno.h> 21 #include "posixtest.h" 22 23 #define ERR_MSG(f, rc) printf("Failed: func: %s rc: %s (%u)\n", \ 24 f, strerror(rc), rc) 25 26 int main(void) 27 { 28 int rc1; 29 int rc2; 30 pthread_attr_t attr; 31 int status = PTS_PASS; 32 33 rc1 = pthread_attr_init(&attr); 34 if (rc1 != 0) { 35 ERR_MSG("pthread_attr_init()", rc1); 36 return PTS_UNRESOLVED; 37 } 38 39 rc1 = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); 40 rc2 = pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS); 41 if (rc1 || rc2) { 42 if (rc1 && rc2) { 43 /* at least one must be supported */ 44 ERR_MSG("pthread_attr_setscope()", rc1); 45 ERR_MSG("pthread_attr_setscope()", rc2); 46 } 47 if (rc1 && rc1 != ENOTSUP) { 48 ERR_MSG("pthread_attr_setscope()", rc1); 49 status = PTS_FAIL; 50 } 51 if (rc2 && rc2 != ENOTSUP) { 52 ERR_MSG("pthread_attr_setscope()", rc2); 53 status = PTS_FAIL; 54 } 55 } 56 57 pthread_attr_destroy(&attr); 58 59 if (status == PTS_PASS) 60 printf("Test PASSED\n"); 61 return status; 62 } 63