1 /*
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
13 * with this program; if not, write the Free Software Foundation, Inc.,
14 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15 *
16 */
17 /**************************************************************************
18 *
19 * TEST IDENTIFIER : timer_delete03
20 *
21 * EXECUTED BY : anyone
22 *
23 * TEST TITLE : Test checking for basic error conditions for
24 * timer_delete(2)
25 *
26 * TEST CASE TOTAL : 1
27 *
28 * AUTHOR : Aniruddha Marathe <aniruddha.marathe@wipro.com>
29 *
30 * 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.
41 *
42 * 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
48 *
49 * Cleanup:
50 * Print errno log and/or timing stats if options given
51 *
52 * 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
67 #include <stdlib.h>
68 #include <errno.h>
69 #include <time.h>
70 #include <signal.h>
71
72 #include "test.h"
73 #include "common_timers.h"
74
75 #define INVALID_ID ((kernel_timer_t)-1)
76
77 void setup(void);
78
79 int testcase[] = {
80 EINVAL /* Invalid timer ID */
81 };
82
83 char *TCID = "timer_delete03";
84 int TST_TOTAL = ARRAY_SIZE(testcase);
85
main(int ac,char ** av)86 int main(int ac, char **av)
87 {
88 int lc, i;
89
90 tst_parse_opts(ac, av, NULL, NULL);
91
92 setup();
93
94 for (lc = 0; TEST_LOOPING(lc); lc++) {
95
96 tst_count = 0;
97
98 for (i = 0; i < TST_TOTAL; i++) {
99
100 TEST(ltp_syscall(__NR_timer_delete, INVALID_ID));
101
102 /* check return code */
103 if (TEST_RETURN == -1 && TEST_ERRNO == testcase[i]) {
104 tst_resm(TPASS | TTERRNO,
105 "failed as expected failure");
106 } else {
107 tst_resm(TFAIL | TTERRNO,
108 "didn't fail as expected [expected "
109 "errno = %d (%s)]",
110 testcase[i], strerror(testcase[i]));
111 } /* end of else */
112
113 } /* End of TEST CASE LOOPING */
114
115 } /* End for TEST_LOOPING */
116
117 cleanup();
118 tst_exit();
119 }
120
121 /* setup() - performs all ONE TIME setup for this test */
setup(void)122 void setup(void)
123 {
124
125 tst_sig(NOFORK, DEF_HANDLER, cleanup);
126
127 TEST_PAUSE;
128 }
129
130 /*
131 * cleanup() - Performs one time cleanup for this test at
132 * completion or premature exit
133 */
cleanup(void)134 void cleanup(void)
135 {
136 }
137