Home | History | Annotate | Download | only in clock_gettime
      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    General test that clock_gettime() returns a non-empty tp for a given
      9    clock_id (the clock_id chosen for this test is CLOCK_REALTIME).
     10  */
     11 #include <stdio.h>
     12 #include <time.h>
     13 #include "posixtest.h"
     14 
     15 int main(void)
     16 {
     17 	struct timespec tp;
     18 
     19 	//Initialize tp
     20 	tp.tv_sec = 0;
     21 	tp.tv_nsec = 0;
     22 	if (clock_gettime(CLOCK_REALTIME, &tp) == 0) {
     23 		if (0 != tp.tv_sec) {	//assume this means time was sent
     24 			printf("Test PASSED\n");
     25 			return PTS_PASS;
     26 		} else {
     27 			printf("clock_gettime() success, but tp not filled\n");
     28 			return PTS_FAIL;
     29 		}
     30 	}
     31 
     32 	printf("clock_gettime() failed\n");
     33 	return PTS_FAIL;
     34 }
     35