1 /****************************************************************************** 2 * Copyright (c) Crackerjack Project., 2007 * 3 * Porting from Crackerjack to LTP is done by: * 4 * Manas Kumar Nayak <maknayak@in.ibm.com> * 5 * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz> * 6 * * 7 * This program is free software; you can redistribute it and/or modify * 8 * it under the terms of the GNU General Public License as published by * 9 * the Free Software Foundation; either version 2 of the License, or * 10 * (at your option) any later version. * 11 * * 12 * This program is distributed in the hope that it will be useful, * 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See * 15 * the GNU General Public License for more details. * 16 * * 17 * You should have received a copy of the GNU General Public License * 18 * along with this program; if not, write to the Free Software Foundation, * 19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 20 * * 21 ******************************************************************************/ 22 23 #include <stdio.h> 24 #include <errno.h> 25 #include <time.h> 26 #include <signal.h> 27 #include <sys/syscall.h> 28 29 #include "test.h" 30 #include "lapi/syscalls.h" 31 32 char *TCID = "timer_getoverrun01"; 33 int TST_TOTAL = 1; 34 35 static void cleanup(void) 36 { 37 38 tst_rmdir(); 39 } 40 41 static void setup(void) 42 { 43 TEST_PAUSE; 44 tst_tmpdir(); 45 } 46 47 int main(int ac, char **av) 48 { 49 int lc; 50 int timer; 51 struct sigevent ev; 52 53 tst_parse_opts(ac, av, NULL, NULL); 54 55 setup(); 56 57 ev.sigev_value = (union sigval) 0; 58 ev.sigev_signo = SIGALRM; 59 ev.sigev_notify = SIGEV_SIGNAL; 60 TEST(ltp_syscall(__NR_timer_create, CLOCK_REALTIME, &ev, &timer)); 61 62 if (TEST_RETURN != 0) 63 tst_brkm(TBROK | TERRNO, cleanup, "Failed to create timer"); 64 65 for (lc = 0; TEST_LOOPING(lc); ++lc) { 66 tst_count = 0; 67 68 TEST(ltp_syscall(__NR_timer_getoverrun, timer)); 69 if (TEST_RETURN == 0) { 70 tst_resm(TPASS, 71 "timer_getoverrun(CLOCK_REALTIME) Passed"); 72 } else { 73 tst_resm(TFAIL | TERRNO, 74 "timer_getoverrun(CLOCK_REALTIME) Failed"); 75 } 76 77 TEST(ltp_syscall(__NR_timer_getoverrun, -1)); 78 if (TEST_RETURN == -1 && TEST_ERRNO == EINVAL) { 79 tst_resm(TPASS, "timer_gettime(-1) Failed: EINVAL"); 80 } else { 81 tst_resm(TFAIL | TERRNO, 82 "timer_gettime(-1) = %li", TEST_RETURN); 83 } 84 } 85 86 cleanup(); 87 tst_exit(); 88 } 89