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 timer_gettime() sets itimerspec.it_value = 0 if the timer 9 * was previously disarmed because it had just been created. 10 * 11 * For this test, signal SIGCONT will be used so that the test will 12 * not abort. Clock CLOCK_REALTIME will be used. 13 */ 14 15#include <time.h> 16#include <signal.h> 17#include <stdio.h> 18#include <unistd.h> 19#include <stdlib.h> 20#include "posixtest.h" 21 22#define TIMERSEC 1 23 24int main(void) 25{ 26 struct sigevent ev; 27 timer_t tid; 28 struct itimerspec its; 29 30 ev.sigev_notify = SIGEV_SIGNAL; 31 ev.sigev_signo = SIGCONT; 32 33 if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) { 34 perror("timer_create() did not return success\n"); 35 return PTS_UNRESOLVED; 36 } 37 38 if (timer_gettime(tid, &its) != 0) { 39 perror("timer_gettime() did not return success\n"); 40 return PTS_UNRESOLVED; 41 } 42 43 if (0 == its.it_value.tv_sec && 0 == its.it_value.tv_nsec) { 44 printf("Test PASSED\n"); 45 return PTS_PASS; 46 } else { 47 printf("Test FAILED: tv_sec %d tv_nsec %d\n", 48 (int)its.it_value.tv_sec, (int)its.it_value.tv_nsec); 49 return PTS_FAIL; 50 } 51 52 return PTS_UNRESOLVED; 53} 54