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_getclock() 9 * shall get the 'clock' attribute of a condattr object. 10 * 11 * Steps: 12 * 1. Initialize a pthread_condattr_t object 13 * 2. Set the clock attribute to CLOCK_REALTIME 14 * 3. Get the clock attribute 15 * 4. Check that it was successful 16 * 17 */ 18 19 #define _XOPEN_SOURCE 600 20 21 #include <pthread.h> 22 #include <stdio.h> 23 #include "posixtest.h" 24 25 int main(void) 26 { 27 pthread_condattr_t condattr; 28 clockid_t clockid; 29 int rc; 30 31 /* Initialize a cond attributes object */ 32 if ((rc = pthread_condattr_init(&condattr)) != 0) { 33 fprintf(stderr, "Error at pthread_condattr_init(), rc=%d\n", 34 rc); 35 printf("Test FAILED\n"); 36 return PTS_FAIL; 37 } 38 39 rc = pthread_condattr_setclock(&condattr, CLOCK_REALTIME); 40 if (rc != 0) { 41 perror("Error: Could not set clock to CLOCK_REALTIME\n"); 42 return PTS_UNRESOLVED; 43 } 44 45 rc = pthread_condattr_getclock(&condattr, &clockid); 46 if (rc != 0) { 47 printf("Test FAILED: Could not get the clock attribute\n"); 48 return PTS_FAIL; 49 } 50 51 printf("Test PASSED\n"); 52 return PTS_PASS; 53 } 54