blob: 6441ef29c430f362ab7998960e4df70e67351dc9 [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"
73#include "usctest.h"
74#include "common_timers.h"
vapierd13d74b2006-02-11 07:24:00 +000075
Subrata Modak4e947652010-05-28 12:50:38 +053076#define INVALID_ID ((kernel_timer_t)-1)
vapierd13d74b2006-02-11 07:24:00 +000077
Garrett Coopera9670cd2010-11-28 21:55:20 -080078void setup(void);
vapierd13d74b2006-02-11 07:24:00 +000079
Wanlong Gao354ebb42012-12-07 10:10:04 +080080char *TCID = "timer_delete03"; /* Test program identifier. */
81int TST_TOTAL; /* Total number of test cases. */
vapierd13d74b2006-02-11 07:24:00 +000082
Wanlong Gao354ebb42012-12-07 10:10:04 +080083static int exp_enos[] = { EINVAL, 0 };
vapierd13d74b2006-02-11 07:24:00 +000084
yaberauneya1a7f5422009-12-06 20:53:42 +000085int testcase[] = {
Wanlong Gao354ebb42012-12-07 10:10:04 +080086 EINVAL /* Invalid timer ID */
vapierd13d74b2006-02-11 07:24:00 +000087};
88
Wanlong Gao354ebb42012-12-07 10:10:04 +080089int main(int ac, char **av)
vapierd13d74b2006-02-11 07:24:00 +000090{
Cyril Hrubis89af32a2012-10-24 16:39:11 +020091 int lc, i;
92 char *msg;
vapierd13d74b2006-02-11 07:24:00 +000093
Garrett Cooperdf3eb162010-11-28 22:44:32 -080094 if ((msg = parse_opts(ac, av, NULL, NULL))
Wanlong Gao354ebb42012-12-07 10:10:04 +080095 != NULL) {
Garrett Cooper53740502010-12-16 00:04:01 -080096 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
vapierd13d74b2006-02-11 07:24:00 +000097 }
98
99 TST_TOTAL = sizeof(testcase) / sizeof(testcase[0]);
100
vapierd13d74b2006-02-11 07:24:00 +0000101 setup();
102
vapierd13d74b2006-02-11 07:24:00 +0000103 for (lc = 0; TEST_LOOPING(lc); lc++) {
104
vapierd13d74b2006-02-11 07:24:00 +0000105 Tst_count = 0;
106
107 for (i = 0; i < TST_TOTAL; i++) {
108
Jan Stancek359980f2013-02-15 10:16:05 +0100109 TEST(ltp_syscall(__NR_timer_delete, INVALID_ID));
vapierd13d74b2006-02-11 07:24:00 +0000110
vapierd13d74b2006-02-11 07:24:00 +0000111 /* check return code */
yaberauneya1a7f5422009-12-06 20:53:42 +0000112 if (TEST_RETURN == -1 && TEST_ERRNO == testcase[i]) {
113 tst_resm(TPASS | TTERRNO,
Wanlong Gao354ebb42012-12-07 10:10:04 +0800114 "failed as expected failure");
vapierd13d74b2006-02-11 07:24:00 +0000115 } else {
yaberauneya1a7f5422009-12-06 20:53:42 +0000116 tst_resm(TFAIL | TTERRNO,
Wanlong Gao354ebb42012-12-07 10:10:04 +0800117 "didn't fail as expected [expected "
118 "errno = %d (%s)]",
119 testcase[i], strerror(testcase[i]));
120 } /* end of else */
vapierd13d74b2006-02-11 07:24:00 +0000121
Wanlong Gao354ebb42012-12-07 10:10:04 +0800122 } /* End of TEST CASE LOOPING */
yaberauneya1a7f5422009-12-06 20:53:42 +0000123
Wanlong Gao354ebb42012-12-07 10:10:04 +0800124 } /* End for TEST_LOOPING */
vapierd13d74b2006-02-11 07:24:00 +0000125
vapierd13d74b2006-02-11 07:24:00 +0000126 cleanup();
yaberauneya1a7f5422009-12-06 20:53:42 +0000127 tst_exit();
vapierd13d74b2006-02-11 07:24:00 +0000128}
129
130/* setup() - performs all ONE TIME setup for this test */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800131void setup(void)
vapierd13d74b2006-02-11 07:24:00 +0000132{
Garrett Cooper2c282152010-12-16 00:55:50 -0800133
vapierd13d74b2006-02-11 07:24:00 +0000134 tst_sig(NOFORK, DEF_HANDLER, cleanup);
135
136 /* set the expected errnos... */
137 TEST_EXP_ENOS(exp_enos);
138
vapierd13d74b2006-02-11 07:24:00 +0000139 TEST_PAUSE;
Garrett Coopera9670cd2010-11-28 21:55:20 -0800140}
vapierd13d74b2006-02-11 07:24:00 +0000141
142/*
143 * cleanup() - Performs one time cleanup for this test at
144 * completion or premature exit
145 */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800146void cleanup(void)
vapierd13d74b2006-02-11 07:24:00 +0000147{
148 /*
Wanlong Gao354ebb42012-12-07 10:10:04 +0800149 * print timing stats if that option was specified.
150 * print errno log if that option was specified.
151 */
vapierd13d74b2006-02-11 07:24:00 +0000152 TEST_CLEANUP;
Chris Dearmanec6edca2012-10-17 19:54:01 -0700153}