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_setpshared() 9 * 10 * It MAY fail if: 11 * 12 * [EINVAL] - 'attr' is invalid. 13 * 14 * Steps: 15 * 16 * 1. Pass to pthread_mutexattr_setpshared() an uninitialized attributes object. 17 * 2. It may return the value of EINVAL. 18 * 19 */ 20 21 #include <pthread.h> 22 #include <stdio.h> 23 #include <errno.h> 24 #include "posixtest.h" 25 26 int main(void) 27 { 28 29 /* Make sure there is process-shared capability. */ 30 #ifndef PTHREAD_PROCESS_SHARED 31 fprintf(stderr, 32 "process-shared attribute is not available for testing\n"); 33 return PTS_UNRESOLVED; 34 #endif 35 36 pthread_mutexattr_t mta; 37 int ret; 38 39 /* Set the attribute to PTHREAD_PROCESS_PRIVATE. */ 40 ret = pthread_mutexattr_setpshared(&mta, PTHREAD_PROCESS_PRIVATE); 41 if (ret != 0) { 42 if (ret == EINVAL) { 43 printf("Test PASSED\n"); 44 return PTS_PASS; 45 } 46 47 printf("Test FAILED: Expected return code 0 or EINVAL, got: %d", 48 ret); 49 return PTS_FAIL; 50 } 51 52 printf 53 ("Test PASSED: NOTE*: Returned 0 on error, though standard states 'may' fail.\n"); 54 return PTS_PASS; 55 56 } 57