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_getoverrun() returns -1 and sets errno==EINVAL when 9 * trying to call timer_getoverrun on a timer that has been deleted or not. 10 * Since this assertion is a "may," either option is a pass. 11 * 12 * For this test, signal SIGCONT will be used, clock CLOCK_REALTIME 13 * will be used. 14 */ 15 16 #include <sys/types.h> 17 #include <errno.h> 18 #include <signal.h> 19 #include <stdio.h> 20 #include <stdlib.h> 21 #include <time.h> 22 #include <unistd.h> 23 #include "posixtest.h" 24 25 #define TIMERSEC 3 26 27 int main(void) 28 { 29 struct sigevent ev; 30 timer_t tid; 31 32 ev.sigev_notify = SIGEV_SIGNAL; 33 ev.sigev_signo = SIGCONT; 34 35 if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) { 36 perror("timer_create() did not return success\n"); 37 return PTS_UNRESOLVED; 38 } 39 40 if (timer_delete(tid) != 0) { 41 perror("timer_delete() did not return success\n"); 42 return PTS_UNRESOLVED; 43 } 44 45 if (timer_getoverrun(tid) == -1) { 46 if (errno == EINVAL) { 47 printf("fcn returned -1 and set errno=EINVAL\n"); 48 return PTS_PASS; 49 } else { 50 printf("fcn returned -1 but errno!=EINVAL\n"); 51 printf("Test FAILED\n"); 52 return PTS_FAIL; 53 } 54 } 55 56 printf("fcn did not return -1\n"); 57 return PTS_PASS; 58 } 59