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_settime() 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 test is a "may" assertion, either way is a 11 * pass. 12 * 13 * For this test, signal SIGTOTEST will be used, clock CLOCK_REALTIME 14 * will be used. 15 */ 16 17 #include <sys/types.h> 18 #include <errno.h> 19 #include <signal.h> 20 #include <stdio.h> 21 #include <time.h> 22 #include "posixtest.h" 23 24 #define SIGTOTEST SIGALRM 25 26 int main(void) 27 { 28 struct sigevent ev; 29 timer_t tid; 30 struct itimerspec its; 31 32 its.it_interval.tv_sec = 0; 33 its.it_interval.tv_nsec = 0; 34 its.it_value.tv_sec = 0; 35 its.it_value.tv_nsec = 0; 36 37 ev.sigev_notify = SIGEV_SIGNAL; 38 ev.sigev_signo = SIGTOTEST; 39 40 if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) { 41 perror("timer_create() did not return success\n"); 42 return PTS_UNRESOLVED; 43 } 44 45 if (timer_settime(tid + 1, 0, &its, NULL) == -1) { 46 if (EINVAL == errno) { 47 printf("fcn returned -1 and 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 printf("fcn did not return -1\n"); 56 return PTS_PASS; 57 } 58