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_init() 9 * shall initialize the condition variable referenced by cond with attributes 10 * referenced by attr. If attr is NULL, the default condition variable 11 * attributes shall be used; the effect is the same as passing the address 12 * of a default condition variable attributes object. 13 14 * NOTE: There is no direct way to judge if two condition variables are equal, 15 * so this test does not cover the statement in the last sentence. 16 * 17 * 18 * Modified - LK coding style 30/05/2011 19 * Peter W. Morreale <pmorreale AT novell DOT com> 20 */ 21 22 #include <pthread.h> 23 #include <stdio.h> 24 #include <string.h> 25 #include "posixtest.h" 26 27 #define ERR_MSG(f, rc) printf("Failed: func: %s rc: %s (%u)\n", \ 28 f, strerror(rc), rc); 29 30 int main(void) 31 { 32 pthread_condattr_t condattr; 33 pthread_cond_t cond1; 34 pthread_cond_t cond2; 35 int rc; 36 char *f; 37 int status = PTS_UNRESOLVED; 38 39 f = "pthread_condattr_init()"; 40 rc = pthread_condattr_init(&condattr); 41 if (rc) 42 goto done; 43 44 status = PTS_FAIL; 45 f = "pthread_cond_init() - condattr"; 46 rc = pthread_cond_init(&cond1, &condattr); 47 if (rc) 48 goto done; 49 50 f = "pthread_cond_init() - NULL"; 51 rc = pthread_cond_init(&cond2, NULL); 52 if (rc) 53 goto done; 54 55 printf("Test PASSED\n"); 56 return PTS_PASS; 57 58 done: 59 ERR_MSG(f, rc); 60 return status; 61 62 } 63