blob: 275f71bb07e22d1ff08f57b79583175520e8e177 [file] [log] [blame]
vapierd13d74b2006-02-11 07:24:00 +00001/*
2 * Copyright (c) Wipro Technologies Ltd, 2003. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * You should have received a copy of the GNU General Public License along
Wanlong Gaofed96412012-10-24 10:10:29 +080013 * with this program; if not, write the Free Software Foundation, Inc.,
14 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
vapierd13d74b2006-02-11 07:24:00 +000015 *
16 */
17/**************************************************************************
vapier6670f842006-08-22 05:57:53 +000018 *
19 * TEST IDENTIFIER : timer_delete03
20 *
vapierd13d74b2006-02-11 07:24:00 +000021 * EXECUTED BY : anyone
vapier6670f842006-08-22 05:57:53 +000022 *
vapierd13d74b2006-02-11 07:24:00 +000023 * TEST TITLE : Test checking for basic error conditions for
24 * timer_delete(2)
vapier6670f842006-08-22 05:57:53 +000025 *
vapierd13d74b2006-02-11 07:24:00 +000026 * TEST CASE TOTAL : 1
vapier6670f842006-08-22 05:57:53 +000027 *
vapierd13d74b2006-02-11 07:24:00 +000028 * AUTHOR : Aniruddha Marathe <aniruddha.marathe@wipro.com>
vapier6670f842006-08-22 05:57:53 +000029 *
vapierd13d74b2006-02-11 07:24:00 +000030 * SIGNALS
31 * Uses SIGUSR1 to pause before test if option set.
32 * (See the parse_opts(3) man page).
33 *
34 * DESCRIPTION
35 * This test case check whether timer_delete(2) returns appropriate error
36 * value for invalid parameter
37 *
38 * Setup:
39 * Setup signal handling.
40 * Pause for SIGUSR1 if option specified.
vapier6670f842006-08-22 05:57:53 +000041 *
vapierd13d74b2006-02-11 07:24:00 +000042 * Test:
43 * Loop if the proper options are given.
44 * Execute system call with invalid parameter.
45 * Check return code, if system call fails with errno == expected errno
46 * Issue syscall passed with expected errno
47 * Otherwise, Issue syscall failed to produce expected errno
vapier6670f842006-08-22 05:57:53 +000048 *
vapierd13d74b2006-02-11 07:24:00 +000049 * Cleanup:
50 * Print errno log and/or timing stats if options given
vapier6670f842006-08-22 05:57:53 +000051 *
vapierd13d74b2006-02-11 07:24:00 +000052 * USAGE: <for command-line>
53 * timer_delete03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-p]
54 * where:
55 * -c n : run n copies simultaneously
56 * -e : Turn on errno logging.
57 * -i n : Execute test n times.
58 * -I x : Execute test for x seconds.
59 * -p : Pause for SIGUSR1 before starting
60 * -P x : Pause for x seconds between iterations.
61 * -t : Turn on syscall timing.
62 *
63 * RESTRICTIONS:
64 * None
65 *****************************************************************************/
66
vapierbc8a4612006-08-22 05:43:15 +000067#include <stdlib.h>
vapierd13d74b2006-02-11 07:24:00 +000068#include <errno.h>
vapierd13d74b2006-02-11 07:24:00 +000069#include <time.h>
70#include <signal.h>
71
vapierbc8a4612006-08-22 05:43:15 +000072#include "test.h"
vapierbc8a4612006-08-22 05:43:15 +000073#include "common_timers.h"
vapierd13d74b2006-02-11 07:24:00 +000074
Subrata Modak4e947652010-05-28 12:50:38 +053075#define INVALID_ID ((kernel_timer_t)-1)
vapierd13d74b2006-02-11 07:24:00 +000076
Garrett Coopera9670cd2010-11-28 21:55:20 -080077void setup(void);
vapierd13d74b2006-02-11 07:24:00 +000078
yaberauneya1a7f5422009-12-06 20:53:42 +000079int testcase[] = {
Wanlong Gao354ebb42012-12-07 10:10:04 +080080 EINVAL /* Invalid timer ID */
vapierd13d74b2006-02-11 07:24:00 +000081};
82
Cyril Hrubis63564ce2015-02-04 13:28:31 +010083char *TCID = "timer_delete03";
84int TST_TOTAL = ARRAY_SIZE(testcase);
85
Wanlong Gao354ebb42012-12-07 10:10:04 +080086int main(int ac, char **av)
vapierd13d74b2006-02-11 07:24:00 +000087{
Cyril Hrubis89af32a2012-10-24 16:39:11 +020088 int lc, i;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020089 const char *msg;
vapierd13d74b2006-02-11 07:24:00 +000090
Garrett Cooperdf3eb162010-11-28 22:44:32 -080091 if ((msg = parse_opts(ac, av, NULL, NULL))
Wanlong Gao354ebb42012-12-07 10:10:04 +080092 != NULL) {
Garrett Cooper53740502010-12-16 00:04:01 -080093 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
vapierd13d74b2006-02-11 07:24:00 +000094 }
95
vapierd13d74b2006-02-11 07:24:00 +000096 setup();
97
vapierd13d74b2006-02-11 07:24:00 +000098 for (lc = 0; TEST_LOOPING(lc); lc++) {
99
Caspar Zhangd59a6592013-03-07 14:59:12 +0800100 tst_count = 0;
vapierd13d74b2006-02-11 07:24:00 +0000101
102 for (i = 0; i < TST_TOTAL; i++) {
103
Jan Stancek359980f2013-02-15 10:16:05 +0100104 TEST(ltp_syscall(__NR_timer_delete, INVALID_ID));
vapierd13d74b2006-02-11 07:24:00 +0000105
vapierd13d74b2006-02-11 07:24:00 +0000106 /* check return code */
yaberauneya1a7f5422009-12-06 20:53:42 +0000107 if (TEST_RETURN == -1 && TEST_ERRNO == testcase[i]) {
108 tst_resm(TPASS | TTERRNO,
Wanlong Gao354ebb42012-12-07 10:10:04 +0800109 "failed as expected failure");
vapierd13d74b2006-02-11 07:24:00 +0000110 } else {
yaberauneya1a7f5422009-12-06 20:53:42 +0000111 tst_resm(TFAIL | TTERRNO,
Wanlong Gao354ebb42012-12-07 10:10:04 +0800112 "didn't fail as expected [expected "
113 "errno = %d (%s)]",
114 testcase[i], strerror(testcase[i]));
115 } /* end of else */
vapierd13d74b2006-02-11 07:24:00 +0000116
Wanlong Gao354ebb42012-12-07 10:10:04 +0800117 } /* End of TEST CASE LOOPING */
yaberauneya1a7f5422009-12-06 20:53:42 +0000118
Wanlong Gao354ebb42012-12-07 10:10:04 +0800119 } /* End for TEST_LOOPING */
vapierd13d74b2006-02-11 07:24:00 +0000120
vapierd13d74b2006-02-11 07:24:00 +0000121 cleanup();
yaberauneya1a7f5422009-12-06 20:53:42 +0000122 tst_exit();
vapierd13d74b2006-02-11 07:24:00 +0000123}
124
125/* setup() - performs all ONE TIME setup for this test */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800126void setup(void)
vapierd13d74b2006-02-11 07:24:00 +0000127{
Garrett Cooper2c282152010-12-16 00:55:50 -0800128
vapierd13d74b2006-02-11 07:24:00 +0000129 tst_sig(NOFORK, DEF_HANDLER, cleanup);
130
vapierd13d74b2006-02-11 07:24:00 +0000131 TEST_PAUSE;
Garrett Coopera9670cd2010-11-28 21:55:20 -0800132}
vapierd13d74b2006-02-11 07:24:00 +0000133
134/*
135 * cleanup() - Performs one time cleanup for this test at
136 * completion or premature exit
137 */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800138void cleanup(void)
vapierd13d74b2006-02-11 07:24:00 +0000139{
Chris Dearmanec6edca2012-10-17 19:54:01 -0700140}