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 after a timer is deleted by calling timer_delete(), it 9 * cannot be armed by calling timer_settime(). 10 * Steps: 11 * - Create a timer 12 * - Delete that timer 13 * - Try to call timer_settime() on that timer and ensure it fails 14 * with errno==EINVAL. 15 * 16 * For this test, signal SIGTOTEST will be used, clock CLOCK_REALTIME 17 * will be used. 18 */ 19 20 #include <time.h> 21 #include <signal.h> 22 #include <stdio.h> 23 #include <errno.h> 24 #include "posixtest.h" 25 26 #define SIGTOTEST SIGALRM 27 #define TIMERSEC 3 28 29 int main(void) 30 { 31 struct sigevent ev; 32 timer_t tid; 33 struct itimerspec its; 34 35 ev.sigev_notify = SIGEV_SIGNAL; 36 ev.sigev_signo = SIGTOTEST; 37 38 if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) { 39 perror("timer_create() did not return success\n"); 40 return PTS_UNRESOLVED; 41 } 42 43 if (timer_delete(tid) != 0) { 44 perror("timer_delete() did not return success\n"); 45 return PTS_UNRESOLVED; 46 } 47 48 its.it_interval.tv_sec = 0; 49 its.it_interval.tv_nsec = 0; 50 its.it_value.tv_sec = TIMERSEC; 51 its.it_value.tv_nsec = 0; 52 53 if (timer_settime(tid, 0, &its, NULL) == -1) { 54 if (errno == EINVAL) { 55 printf("Test PASSED\n"); 56 return PTS_PASS; 57 } else { 58 printf("errno!=EINVAL after a timer_delete()\n"); 59 return PTS_FAIL; 60 } 61 } 62 63 printf("timer_settime() did not fail after timer_delete()\n"); 64 return PTS_FAIL; 65 } 66