blob: c988c07bfaa16d81d9a816b3ff654ee7dc8d8165 [file] [log] [blame]
Cyril Hrubisfe85aee2013-09-04 16:46:46 +02001/******************************************************************************
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 ******************************************************************************/
subrata_modak07168752009-05-21 18:41:36 +000022
23#include <stdio.h>
24#include <errno.h>
25#include <time.h>
26#include <signal.h>
27#include <syscall.h>
28
subrata_modak07168752009-05-21 18:41:36 +000029#include "test.h"
subrata_modak07168752009-05-21 18:41:36 +000030#include "linux_syscall_numbers.h"
31
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020032char *TCID = "timer_getoverrun01";
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020033int TST_TOTAL = 1;
subrata_modak07168752009-05-21 18:41:36 +000034
Cyril Hrubisfe85aee2013-09-04 16:46:46 +020035static void cleanup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +080036{
Garrett Cooper2c282152010-12-16 00:55:50 -080037
Wanlong Gao354ebb42012-12-07 10:10:04 +080038 tst_rmdir();
subrata_modak07168752009-05-21 18:41:36 +000039}
40
Cyril Hrubisfe85aee2013-09-04 16:46:46 +020041static void setup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +080042{
Wanlong Gao354ebb42012-12-07 10:10:04 +080043 TEST_PAUSE;
44 tst_tmpdir();
subrata_modak07168752009-05-21 18:41:36 +000045}
46
Wanlong Gao354ebb42012-12-07 10:10:04 +080047int main(int ac, char **av)
48{
Cyril Hrubis89af32a2012-10-24 16:39:11 +020049 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020050 const char *msg;
Cyril Hrubisfe85aee2013-09-04 16:46:46 +020051 int timer;
Wanlong Gao354ebb42012-12-07 10:10:04 +080052 struct sigevent ev;
Garrett Cooper2c282152010-12-16 00:55:50 -080053
Cyril Hrubisfe85aee2013-09-04 16:46:46 +020054 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Wanlong Gao354ebb42012-12-07 10:10:04 +080055 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
subrata_modak07168752009-05-21 18:41:36 +000056
Wanlong Gao354ebb42012-12-07 10:10:04 +080057 setup();
subrata_modak07168752009-05-21 18:41:36 +000058
Cyril Hrubisfe85aee2013-09-04 16:46:46 +020059 ev.sigev_value = (sigval_t) 0;
60 ev.sigev_signo = SIGALRM;
61 ev.sigev_notify = SIGEV_SIGNAL;
62 TEST(ltp_syscall(__NR_timer_create, CLOCK_REALTIME, &ev, &timer));
63
64 if (TEST_RETURN != 0)
65 tst_brkm(TBROK | TERRNO, cleanup, "Failed to create timer");
66
Wanlong Gao354ebb42012-12-07 10:10:04 +080067 for (lc = 0; TEST_LOOPING(lc); ++lc) {
Caspar Zhangd59a6592013-03-07 14:59:12 +080068 tst_count = 0;
Garrett Cooper2c282152010-12-16 00:55:50 -080069
Cyril Hrubisfe85aee2013-09-04 16:46:46 +020070 TEST(ltp_syscall(__NR_timer_getoverrun, timer));
71 if (TEST_RETURN == 0) {
72 tst_resm(TPASS,
73 "timer_getoverrun(CLOCK_REALTIME) Passed");
74 } else {
75 tst_resm(TFAIL | TERRNO,
76 "timer_getoverrun(CLOCK_REALTIME) Failed");
77 }
subrata_modak07168752009-05-21 18:41:36 +000078
Cyril Hrubisfe85aee2013-09-04 16:46:46 +020079 TEST(ltp_syscall(__NR_timer_getoverrun, -1));
80 if (TEST_RETURN == -1 && TEST_ERRNO == EINVAL) {
81 tst_resm(TPASS, "timer_gettime(-1) Failed: EINVAL");
82 } else {
83 tst_resm(TFAIL | TERRNO,
84 "timer_gettime(-1) = %li", TEST_RETURN);
Wanlong Gao354ebb42012-12-07 10:10:04 +080085 }
86 }
Cyril Hrubisfe85aee2013-09-04 16:46:46 +020087
subrata_modak07168752009-05-21 18:41:36 +000088 cleanup();
Wanlong Gao354ebb42012-12-07 10:10:04 +080089 tst_exit();
subrata_modak07168752009-05-21 18:41:36 +000090}