Home | History | Annotate | Download | only in pthread_condattr_setclock
      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_condattr_setclock()
      9  * It returns 0 upon success, and an error code if it fails:
     10  *
     11  * It may fail if:
     12  *
     13  * [EINVAL] - the 'attr' value is invalid
     14  * [EINVAL] - 'clock_id' doesn't refer to a known clock or is a CPU-time clock.
     15  *
     16  * Steps:
     17  * 1.  Initialize a pthread_condattr_t object
     18  * 2.  Set the clock to an invalid value
     19  * 3.  It should fail
     20  *
     21  */
     22 
     23 
     24 #include <pthread.h>
     25 #include <stdio.h>
     26 #include <errno.h>
     27 #include "posixtest.h"
     28 
     29 #define INVALID_CLOCKID -100
     30 
     31 int main(void)
     32 {
     33 	pthread_condattr_t condattr;
     34 	int rc;
     35 
     36 	/* Initialize a cond attributes object */
     37 	if ((rc = pthread_condattr_init(&condattr)) != 0) {
     38 		fprintf(stderr, "Error at pthread_condattr_init(), rc=%d\n",
     39 			rc);
     40 		printf("Test FAILED\n");
     41 		return PTS_FAIL;
     42 	}
     43 
     44 	rc = pthread_condattr_setclock(&condattr, INVALID_CLOCKID);
     45 	if (rc != EINVAL) {
     46 		printf
     47 		    ("Test PASSED: *NOTE: Test passed while passing an invalid clockid, but the standard says 'may' fail\n");
     48 		return PTS_PASS;
     49 	}
     50 
     51 	printf("Test PASSED\n");
     52 	return PTS_PASS;
     53 }
     54