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 * Upon success, it returns 0. 11 * 12 * Steps: 13 * 14 * 1. Initialized a mutexattr object. 15 * 2. Set the attributes object to PTHREAD_PROCESS_SHARED. The error return code should be 0. 16 * 17 */ 18 19 #include <pthread.h> 20 #include <stdio.h> 21 #include "posixtest.h" 22 23 int main(void) 24 { 25 26 /* Make sure there is process-shared capability. */ 27 #ifndef PTHREAD_PROCESS_SHARED 28 fprintf(stderr, 29 "process-shared attribute is not available for testing\n"); 30 return PTS_UNRESOLVED; 31 #endif 32 33 pthread_mutexattr_t mta; 34 int ret; 35 36 /* Initialize a mutex attributes object */ 37 if (pthread_mutexattr_init(&mta) != 0) { 38 perror("Error at pthread_mutexattr_init()\n"); 39 return PTS_UNRESOLVED; 40 } 41 42 /* Set the attribute to PTHREAD_PROCESS_PRIVATE. */ 43 ret = pthread_mutexattr_setpshared(&mta, PTHREAD_PROCESS_SHARED); 44 if (ret != 0) { 45 printf("Test FAILED: Expected return code 0, got: %d\n", ret); 46 return PTS_FAIL; 47 } 48 49 printf("Test PASSED\n"); 50 return PTS_PASS; 51 } 52