• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_delete02
20  *
21  *    EXECUTED BY	: anyone
22  *
23  *    TEST TITLE	: Basic test for timer_delete(2)
24  *
25  *    TEST CASE TOTAL	: 1
26  *
27  *    AUTHOR		: Aniruddha Marathe <aniruddha.marathe@wipro.com>
28  *
29  *    SIGNALS
30  * 	Uses SIGUSR1 to pause before test if option set.
31  * 	(See the parse_opts(3) man page).
32  *
33  *    DESCRIPTION
34  *     This is a Phase I test for the timer_delete(2) system call.
35  *     It is intended to provide a limited exposure of the system call.
36  *
37  * 	Setup:
38  *	  Setup signal handling.
39  *	  Pause for SIGUSR1 if option specified.
40  *
41  * 	Test:
42  *	 Loop if the proper options are given.
43  *	 Create a POSIX timer
44  *	 Execute system call
45  *	 Check return code, if system call failed (return=-1)
46  *		Log the errno and Issue a FAIL message.
47  *	 Otherwise, Issue a PASS message.
48  *
49  * 	Cleanup:
50  * 	  Print errno log and/or timing stats if options given
51  *
52  * USAGE:  <for command-line>
53  * timer_delete02 [-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 void setup(void);
76 
77 char *TCID = "timer_delete02";	/* Test program identifier.    */
78 int TST_TOTAL = 1;		/* Total number of test cases. */
79 
main(int ac,char ** av)80 int main(int ac, char **av)
81 {
82 	int lc;
83 	kernel_timer_t timer_id;
84 
85 	tst_parse_opts(ac, av, NULL, NULL);
86 
87 	setup();
88 
89 	for (lc = 0; TEST_LOOPING(lc); lc++) {
90 
91 		tst_count = 0;
92 
93 		/* Create a Posix timer */
94 		if (ltp_syscall(__NR_timer_create, CLOCK_REALTIME, NULL,
95 			&timer_id) < 0) {
96 			tst_count = TST_TOTAL;
97 			tst_brkm(TBROK | TERRNO, cleanup,
98 				 "timer_delete can't be tested because "
99 				 "timer_create failed");
100 		}
101 		TEST(ltp_syscall(__NR_timer_delete, timer_id));
102 		tst_resm((TEST_RETURN == 0 ? TPASS : TFAIL | TTERRNO),
103 			 "%s", (TEST_RETURN == 0 ? "passed" : "failed"));
104 	}
105 
106 	cleanup();
107 	tst_exit();
108 }
109 
110 /* setup() - performs all ONE TIME setup for this test */
setup(void)111 void setup(void)
112 {
113 
114 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
115 
116 	TEST_PAUSE;
117 }
118 
119 /*
120  * cleanup() - Performs one time cleanup for this test at
121  * completion or premature exit
122  */
cleanup(void)123 void cleanup(void)
124 {
125 }
126