Home | History | Annotate | Download | only in clock_settime
      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  * Test that clock_settime() sets errno = EINVAL if clock_id is
      9  * CLOCK_MONOTONIC.
     10  *
     11  * The date chosen is Nov 12, 2002 ~11:13am.
     12  */
     13 #include <errno.h>
     14 #include <stdio.h>
     15 #include <time.h>
     16 #include <unistd.h>
     17 #include "posixtest.h"
     18 
     19 #define TESTTIME 1037128358
     20 
     21 int main(void)
     22 {
     23 #ifdef CLOCK_MONOTONIC
     24 	struct timespec tpset;
     25 
     26 	tpset.tv_sec = TESTTIME;
     27 	tpset.tv_nsec = 0;
     28 	if (geteuid() != 0) {
     29 		printf("Test must be run as superuser\n");
     30 		return PTS_UNRESOLVED;
     31 	}
     32 	if (clock_settime(CLOCK_MONOTONIC, &tpset) == -1) {
     33 		if (EINVAL == errno) {
     34 			printf("Test PASSED\n");
     35 			return PTS_PASS;
     36 		} else {
     37 			printf("errno != EINVAL\n");
     38 			return PTS_FAIL;
     39 		}
     40 	} else {
     41 		printf("clock_settime() did not fail with CLOCK_MONOTONIC\n");
     42 		return PTS_UNRESOLVED;
     43 	}
     44 
     45 	return PTS_UNRESOLVED;
     46 #else
     47 	printf("CLOCK_MONOTONIC not supported\n");
     48 	return PTS_UNSUPPORTED;
     49 #endif
     50 
     51 }
     52