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_condattr_getpshared() 9 * 10 * It shall obtain the value of the process-shared attribute from 'attr'. 11 * 12 * Steps: 13 * 1. Initialize a pthread_condattr_t object with pthread_condattr_init() 14 * 2. Call pthread_condattr_getpshared() to check if the process-shared 15 * attribute is set as the default value PTHREAD_PROCESS_PRIVATE. 16 * 17 */ 18 19#include <pthread.h> 20#include <stdio.h> 21#include "posixtest.h" 22 23int main() 24{ 25 26 /* Make sure there is process-shared capability. */ 27 #ifndef PTHREAD_PROCESS_SHARED 28 fprintf(stderr,"process-shared attribute is not available for testing\n"); 29 return PTS_UNRESOLVED; 30 #endif 31 32 pthread_condattr_t attr; 33 int pshared; 34 35 /* Initialize a mutex attributes object */ 36 if(pthread_condattr_init(&attr) != 0) 37 { 38 perror("Error at pthread_condattr_init()\n"); 39 return PTS_UNRESOLVED; 40 } 41 42 /* The default 'pshared' attribute should be PTHREAD_PROCESS_PRIVATE */ 43 if(pthread_condattr_getpshared(&attr, &pshared) != 0) 44 { 45 fprintf(stderr,"Error obtaining the attribute process-shared\n"); 46 return PTS_UNRESOLVED; 47 } 48 49 if(pshared != PTHREAD_PROCESS_PRIVATE) 50 { 51 printf("Test FAILED: Incorrect default pshared value: %d\n", pshared); 52 return PTS_FAIL; 53 } 54 55 printf("Test PASSED\n"); 56 return PTS_PASS; 57} 58