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 18int main(int argc, char *argv[]) 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, 33 (int) res.tv_nsec); 34#endif 35 printf("Test PASSED\n"); 36 return PTS_PASS; 37 } else { 38 printf("clock_getres() success, but res not filled\n"); 39 } 40 } else { 41 printf("clock_getres() failed\n"); 42 } 43 44 printf("Test FAILED\n"); 45 return PTS_FAIL; 46#else 47 printf("CLOCK_MONOTONIC unsupported\n"); 48 return PTS_UNSUPPORTED; 49#endif 50 51} 52