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_cond_destroy() 9 * Upon succesful completion, it shall return a 0 10 * 11 */ 12 13#include <pthread.h> 14#include <stdio.h> 15#include <errno.h> 16#include "posixtest.h" 17 18int main() 19{ 20 pthread_cond_t cond; 21 int rc; 22 23 /* Initialize a cond object */ 24 if((rc=pthread_cond_init(&cond,NULL)) != 0) { 25 fprintf(stderr,"Fail to initialize cond, rc=%d\n",rc); 26 return PTS_UNRESOLVED; 27 } 28 29 if((rc=pthread_cond_destroy(&cond)) == 0) { 30 printf("Test PASSED\n"); 31 return PTS_PASS; 32 } 33 34 /* Check if returned values are tolerable */ 35 else if(rc == EBUSY) { 36 fprintf(stderr,"Detected an attempt to destroy a cond in use\n"); 37 return PTS_FAIL; 38 } 39 else if(rc == EINVAL) { 40 fprintf(stderr,"The value specified by 'cond' is invalid\n"); 41 return PTS_FAIL; 42 } 43 44 /* Any other returned value means the test failed */ 45 else 46 { 47 printf("Test FAILED (error %i unexpected)\n", rc); 48 return PTS_FAIL; 49 } 50} 51