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 to see if timer_gettime() sets errno = EINVAL timerid != a timer ID 9 * created via timer_create(). [Try to set timerid to a timer ID 10 * created + 1.] Since this assertion is a "may," either way is a pass. 11 * 12 * For this test, signal SIGCONT will be used, clock CLOCK_REALTIME 13 * will be used. 14 */ 15 16 #include <time.h> 17 #include <signal.h> 18 #include <stdio.h> 19 #include <errno.h> 20 #include "posixtest.h" 21 22 int main(void) 23 { 24 struct sigevent ev; 25 timer_t tid; 26 struct itimerspec its; 27 28 ev.sigev_notify = SIGEV_SIGNAL; 29 ev.sigev_signo = SIGCONT; 30 31 if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) { 32 perror("timer_create() did not return success\n"); 33 return PTS_UNRESOLVED; 34 } 35 36 if (timer_gettime(tid + 1, &its) == -1) { 37 if (EINVAL == errno) { 38 printf("fcn returned -1 and errno==EINVAL\n"); 39 return PTS_PASS; 40 } else { 41 printf("fcn returned -1 but errno!=EINVAL\n"); 42 printf("Test FAILED\n"); 43 return PTS_FAIL; 44 } 45 } 46 printf("fcn did not return -1\n"); 47 return PTS_PASS; 48 } 49