Home | History | Annotate | Download | only in pthread_condattr_destroy
      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 pthread_condattr_destroy()
      9  *   A destroyed 'attr' attributes object can be reinitialized using
     10  *   pthread_condattr_init(); the results of otherwise referencing the
     11  *   object after it has been destroyed are undefined.
     12  *
     13  * Steps:
     14  * 1.  Initialize a pthread_condattr_t object using pthread_condattr_init()
     15  * 2.  Destroy that initialized attribute using pthread_condattr_destroy()
     16  * 3.  Initialize the pthread_condattr_t object again. This should not result
     17  *     in any error.
     18  *
     19  */
     20 
     21 #include <pthread.h>
     22 #include <stdio.h>
     23 #include <errno.h>
     24 #include "posixtest.h"
     25 
     26 int main(void)
     27 {
     28 	pthread_condattr_t condattr;
     29 
     30 	/* Initialize a condition variable attributes object */
     31 	if (pthread_condattr_init(&condattr) != 0) {
     32 		fprintf(stderr,
     33 			"Cannot initialize condition variable attributes object\n");
     34 		return PTS_UNRESOLVED;
     35 	}
     36 
     37 	/* Destroy the condition variable attributes object */
     38 	if (pthread_condattr_destroy(&condattr) != 0) {
     39 		fprintf(stderr,
     40 			"Cannot destroy the condition variable attributes object\n");
     41 		return PTS_UNRESOLVED;
     42 	}
     43 
     44 	/* Initialize the condition variable attributes object again.  This shouldn't result in an error. */
     45 	if (pthread_condattr_init(&condattr) != 0) {
     46 		printf("Test FAILED\n");
     47 		return PTS_FAIL;
     48 	} else {
     49 		printf("Test PASSED\n");
     50 		return PTS_PASS;
     51 	}
     52 }
     53