1 /* 2 * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 * Created by: rolla.n.selbak 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_attr_setdetachstate() 9 * 10 * shall fail if: 11 * -[EINVAL] The value of detachstate was not valid 12 * 13 * Steps: 14 * 1. Initialize a pthread_attr_t object using pthread_attr_init() 15 * 2. Call pthread_attr_setdetachstate() using an invalid value of 0 16 * 17 */ 18 19 #include <pthread.h> 20 #include <stdio.h> 21 #include <errno.h> 22 #include "posixtest.h" 23 main(void)24int main(void) 25 { 26 pthread_attr_t new_attr; 27 int ret_val, invalid_val; 28 29 /* Initialize attribute */ 30 if (pthread_attr_init(&new_attr) != 0) { 31 perror("Cannot initialize attribute object\n"); 32 return PTS_UNRESOLVED; 33 } 34 35 /* Set the attribute object to an invalid value of 1000000. */ 36 invalid_val = 1000000; 37 ret_val = pthread_attr_setdetachstate(&new_attr, invalid_val); 38 39 if (ret_val != EINVAL) { 40 printf("Test FAILED: Returned %d instead of EINVAL\n", ret_val); 41 return PTS_FAIL; 42 } 43 44 printf("Test PASSED\n"); 45 return PTS_PASS; 46 } 47