1 /* 2 * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 * Created by: julie.n.fleischer 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 * pt:MON 9 * Test that clock_getres() supports a clock_id of CLOCK_MONOTONIC if 10 * pt:MON. 11 */ 12 #include <stdio.h> 13 #include <time.h> 14 #include "posixtest.h" 15 16 #define LARGENUM 100000 17 18 int main(void) 19 { 20 #ifdef CLOCK_MONOTONIC 21 struct timespec res; 22 23 /* Initialize res to a number much larger than the resolution 24 * could possibly be 25 */ 26 res.tv_sec = LARGENUM; 27 res.tv_nsec = LARGENUM; 28 if (clock_getres(CLOCK_MONOTONIC, &res) == 0) { 29 if (res.tv_sec != LARGENUM) { //assume initialized 30 #ifdef DEBUG 31 printf("Resolution is %d sec %d nsec\n", 32 (int)res.tv_sec, (int)res.tv_nsec); 33 #endif 34 printf("Test PASSED\n"); 35 return PTS_PASS; 36 } else { 37 printf("clock_getres() success, but res not filled\n"); 38 } 39 } else { 40 printf("clock_getres() failed\n"); 41 } 42 43 printf("Test FAILED\n"); 44 return PTS_FAIL; 45 #else 46 printf("CLOCK_MONOTONIC unsupported\n"); 47 return PTS_UNSUPPORTED; 48 #endif 49 50 } 51