1 /* 2 * 3 * Copyright (c) Novell Inc. 2011 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms in version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 12 * the GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 * 18 * Author: Peter W. Morreale <pmorreale AT novell DOT com> 19 * 20 * Date: 31/05/2011 21 * 22 * Test assertion 4 - EBUSY is returned for re-initializing a 23 * condition variable. Note the 0 (zero) may be returned 24 */ 25 26 #include <stdio.h> 27 #include <string.h> 28 #include <pthread.h> 29 #include <unistd.h> 30 #include <errno.h> 31 #include <posixtest.h> 32 33 #define ERR_MSG(f, rc) printf("Failed: function: %s status: %s(%u)\n", \ 34 f, strerror(rc), rc) 35 36 int main(void) 37 { 38 int status; 39 pthread_cond_t cond; 40 int rc; 41 42 status = PTS_UNRESOLVED; 43 44 rc = pthread_cond_init(&cond, NULL); 45 if (rc) { 46 ERR_MSG("pthread_cond_init()", rc); 47 return status; 48 } 49 50 rc = pthread_cond_init(&cond, NULL); 51 if (rc && rc != EBUSY) { 52 ERR_MSG("pthread_cond_init() 2", rc); 53 return PTS_FAIL; 54 } 55 56 printf("Test PASSED\n"); 57 return PTS_PASS; 58 } 59