1 /******************************************************************************/
2 /* Copyright (c) Crackerjack Project., 2007 */
3 /* */
4 /* This program is free software; you can redistribute it and/or modify */
5 /* it under the terms of the GNU General Public License as published by */
6 /* the Free Software Foundation; either version 2 of the License, or */
7 /* (at your option) any later version. */
8 /* */
9 /* This program is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
12 /* the GNU General Public License for more details. */
13 /* */
14 /* You should have received a copy of the GNU General Public License */
15 /* along with this program; if not, write to the Free Software */
16 /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
17 /* */
18 /******************************************************************************/
19 /******************************************************************************/
20 /* */
21 /* File: ssetmask01.c */
22 /* */
23 /* Description: This tests the ssetmask() syscall */
24 /* */
25 /* Usage: <for command-line> */
26 /* ssetmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t] */
27 /* where, -c n : Run n copies concurrently. */
28 /* -e : Turn on errno logging. */
29 /* -i n : Execute test n times. */
30 /* -I x : Execute test for x seconds. */
31 /* -P x : Pause for x seconds between iterations. */
32 /* -t : Turn on syscall timing. */
33 /* */
34 /* Total Tests: 2 */
35 /* */
36 /* Test Name: ssetmask01 */
37 /* History: Porting from Crackerjack to LTP is done by */
38 /* Manas Kumar Nayak maknayak@in.ibm.com> */
39 /******************************************************************************/
40
41 #include <stdio.h>
42 #include <errno.h>
43 #include <stdlib.h>
44 #include <signal.h>
45
46 #include "test.h"
47 #include "lapi/syscalls.h"
48
49 char *TCID = "ssetmask01";
50 int testno;
51 int TST_TOTAL = 2;
52
53 /* Extern Global Functions */
54 /******************************************************************************/
55 /* */
56 /* Function: cleanup */
57 /* */
58 /* Description: Performs all one time clean up for this test on successful */
59 /* completion, premature exit or failure. Closes all temporary */
60 /* files, removes all temporary directories exits the test with */
61 /* appropriate return code by calling tst_exit() function. */
62 /* */
63 /* Input: None. */
64 /* */
65 /* Output: None. */
66 /* */
67 /* Return: On failure - Exits calling tst_exit(). Non '0' return code. */
68 /* On success - Exits calling tst_exit(). With '0' return code. */
69 /* */
70 /******************************************************************************/
cleanup(void)71 void cleanup(void)
72 {
73
74 tst_rmdir();
75
76 }
77
78 /* Local Functions */
79 /******************************************************************************/
80 /* */
81 /* Function: setup */
82 /* */
83 /* Description: Performs all one time setup for this test. This function is */
84 /* typically used to capture signals, create temporary dirs */
85 /* and temporary files that may be used in the course of this */
86 /* test. */
87 /* */
88 /* Input: None. */
89 /* */
90 /* Output: None. */
91 /* */
92 /* Return: On failure - Exits by calling cleanup(). */
93 /* On success - returns 0. */
94 /* */
95 /******************************************************************************/
setup(void)96 void setup(void)
97 {
98 /* Capture signals if any */
99 /* Create temporary directories */
100 TEST_PAUSE;
101 tst_tmpdir();
102 }
103
main(int ac,char ** av)104 int main(int ac, char **av)
105 {
106 int lc;
107
108 tst_parse_opts(ac, av, NULL, NULL);
109
110 setup();
111
112 for (lc = 0; TEST_LOOPING(lc); ++lc) {
113 tst_count = 0;
114 for (testno = 0; testno < TST_TOTAL; ++testno) {
115 ltp_syscall(__NR_ssetmask, SIGALRM);
116 TEST(ltp_syscall(__NR_sgetmask));
117 if (TEST_RETURN != SIGALRM) {
118 tst_brkm(TFAIL | TTERRNO, cleanup,
119 "sgetmask() failed");
120 }
121 TEST(ltp_syscall(__NR_ssetmask, SIGUSR1));
122 if (TEST_RETURN != SIGALRM) {
123 tst_brkm(TFAIL | TTERRNO, cleanup,
124 "ssetmask() failed");
125 }
126 tst_resm(TPASS, "Got SIGALRM--Test PASS ");
127 }
128 }
129 cleanup();
130 tst_exit();
131 }
132