blob: 49f7a889f89eee1e59f86c597ad12da3adb5e848 [file] [log] [blame]
subrata_modakded2c1e2009-12-07 11:44:52 +00001/*
2 * Copyright (c) Jiri Palecek<jpalecek@web.de>, 2009
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 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
Wanlong Gaofed96412012-10-24 10:10:29 +080020 * with this program; if not, write the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
subrata_modakded2c1e2009-12-07 11:44:52 +000022 */
23#include "test.h"
subrata_modakded2c1e2009-12-07 11:44:52 +000024#include <errno.h>
25#include <signal.h>
26#include "../utils/include_j_h.h"
27#include "../utils/common_j_h.c"
28#include <limits.h>
29#include "linux_syscall_numbers.h"
30
Garrett Cooper60611092011-02-23 00:04:58 -080031#define SUCCEED_OR_DIE(syscall, message, ...) \
32 (errno = 0, \
33 ({int ret=syscall(__VA_ARGS__); \
34 if (ret==-1) \
35 tst_brkm(TBROK|TERRNO, cleanup, message);\
subrata_modakded2c1e2009-12-07 11:44:52 +000036 ret;}))
37
38/* Report success iff TEST_RETURN and TEST_ERRNO are equal to
39 exp_return and exp_errno, resp., and cond is true. If cond is not
40 true, report condition_errmsg
41*/
Wanlong Gao354ebb42012-12-07 10:10:04 +080042static void report_success_cond(const char *func, const char *file, int line,
43 long exp_return, int exp_errno, int condition,
44 char *condition_errmsg)
subrata_modakded2c1e2009-12-07 11:44:52 +000045{
Wanlong Gao354ebb42012-12-07 10:10:04 +080046 if (exp_return == TEST_RETURN
47 && (exp_return != -1 || exp_errno == TEST_ERRNO))
Garrett Cooperdf3eb162010-11-28 22:44:32 -080048 if (condition)
subrata_modakded2c1e2009-12-07 11:44:52 +000049 tst_resm(TPASS, "Test passed");
50 else
Wanlong Gao354ebb42012-12-07 10:10:04 +080051 tst_resm(TFAIL, "%s (%s: %d): %s", func, file, line,
52 condition_errmsg);
Garrett Cooperdf3eb162010-11-28 22:44:32 -080053 else if (TEST_RETURN != -1)
Wanlong Gao354ebb42012-12-07 10:10:04 +080054 tst_resm(TFAIL,
55 "%s (%s: %d): Unexpected return value; expected %ld, got %ld",
56 func, file, line, exp_return, TEST_RETURN);
subrata_modakded2c1e2009-12-07 11:44:52 +000057 else
Wanlong Gao354ebb42012-12-07 10:10:04 +080058 tst_resm(TFAIL | TTERRNO, "%s (%s: %d): Unexpected failure",
59 func, file, line);
subrata_modakded2c1e2009-12-07 11:44:52 +000060}
61
62#define REPORT_SUCCESS_COND(exp_return, exp_errno, condition, condition_errmsg) \
63 report_success_cond(__FUNCTION__, __FILE__, __LINE__, exp_return, exp_errno, condition, condition_errmsg);
64
65/* Report success iff TEST_RETURN and TEST_ERRNO are equal to
66 exp_return and exp_errno, resp.
67*/
68#define REPORT_SUCCESS(exp_return, exp_errno) \
69 REPORT_SUCCESS_COND(exp_return, exp_errno, 1, "");
70
Garrett Cooperab5336e2010-12-19 08:41:59 -080071static void cleanup(void);
subrata_modakded2c1e2009-12-07 11:44:52 +000072
73static void empty_handler(int sig)
74{
75}
76
77static void setup(void)
78{
79 tst_sig(FORK, DEF_HANDLER, cleanup);
80 signal(SIGUSR1, empty_handler);
81 signal(SIGALRM, empty_handler);
82 signal(SIGUSR2, SIG_IGN);
83
84 TEST_PAUSE;
85}
86
87static void cleanup(void)
88{
subrata_modakded2c1e2009-12-07 11:44:52 +000089}
90
Wanlong Gao354ebb42012-12-07 10:10:04 +080091typedef int (*swi_func) (const sigset_t * set, siginfo_t * info,
92 struct timespec * timeout);
93typedef void (*test_func) (swi_func, int);
subrata_modakded2c1e2009-12-07 11:44:52 +000094
Garrett Cooperab5336e2010-12-19 08:41:59 -080095#ifdef TEST_SIGWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +080096static int my_sigwait(const sigset_t * set, siginfo_t * info,
97 struct timespec *timeout)
subrata_modakded2c1e2009-12-07 11:44:52 +000098{
99 int ret;
Wanlong Gao354ebb42012-12-07 10:10:04 +0800100 int err = sigwait(set, &ret);
subrata_modakded2c1e2009-12-07 11:44:52 +0000101
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800102 if (err == 0)
subrata_modakded2c1e2009-12-07 11:44:52 +0000103 return ret;
104 errno = err;
105 return -1;
106}
Garrett Cooperab5336e2010-12-19 08:41:59 -0800107#endif
subrata_modakded2c1e2009-12-07 11:44:52 +0000108
Garrett Cooperab5336e2010-12-19 08:41:59 -0800109#ifdef TEST_SIGWAITINFO
Wanlong Gao354ebb42012-12-07 10:10:04 +0800110static int my_sigwaitinfo(const sigset_t * set, siginfo_t * info,
111 struct timespec *timeout)
subrata_modakded2c1e2009-12-07 11:44:52 +0000112{
Garrett Cooper60611092011-02-23 00:04:58 -0800113
subrata_modakded2c1e2009-12-07 11:44:52 +0000114 return sigwaitinfo(set, info);
115}
Garrett Cooperab5336e2010-12-19 08:41:59 -0800116#endif
subrata_modakded2c1e2009-12-07 11:44:52 +0000117
Garrett Cooperab5336e2010-12-19 08:41:59 -0800118#ifdef TEST_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800119static int my_sigtimedwait(const sigset_t * set, siginfo_t * info,
120 struct timespec *timeout)
subrata_modakded2c1e2009-12-07 11:44:52 +0000121{
Garrett Cooper60611092011-02-23 00:04:58 -0800122
subrata_modakded2c1e2009-12-07 11:44:52 +0000123 return sigtimedwait(set, info, timeout);
124}
Garrett Cooperab5336e2010-12-19 08:41:59 -0800125#endif
subrata_modakded2c1e2009-12-07 11:44:52 +0000126
Garrett Cooperab5336e2010-12-19 08:41:59 -0800127#ifdef TEST_RT_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800128static int my_rt_sigtimedwait(const sigset_t * set, siginfo_t * info,
129 struct timespec *timeout)
subrata_modakded2c1e2009-12-07 11:44:52 +0000130{
Garrett Cooper60611092011-02-23 00:04:58 -0800131
subrata_modakded2c1e2009-12-07 11:44:52 +0000132 /* The last argument is (number_of_signals)/(bits_per_byte), which are 64 and 8, resp. */
Jan Stancek359980f2013-02-15 10:16:05 +0100133 return ltp_syscall(__NR_rt_sigtimedwait, set, info, timeout, 8);
subrata_modakded2c1e2009-12-07 11:44:52 +0000134}
Garrett Cooperab5336e2010-12-19 08:41:59 -0800135#endif
subrata_modakded2c1e2009-12-07 11:44:52 +0000136
137void test_empty_set(swi_func sigwaitinfo, int signo)
138{
139 sigset_t sigs;
140 siginfo_t si;
141 pid_t child;
142
143 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
144 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800145 child = create_sig_proc(100000, signo, UINT_MAX);
subrata_modakded2c1e2009-12-07 11:44:52 +0000146
147 TEST(sigwaitinfo(&sigs, &si, NULL));
148 REPORT_SUCCESS(-1, EINTR);
149
150 kill(child, SIGTERM);
151}
152
153void test_timeout(swi_func sigwaitinfo, int signo)
154{
155 sigset_t sigs;
156 siginfo_t si;
157 pid_t child;
Wanlong Gao354ebb42012-12-07 10:10:04 +0800158 struct timespec ts = {.tv_sec = 1 };
subrata_modakded2c1e2009-12-07 11:44:52 +0000159
160 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
161
162 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800163 child = create_sig_proc(100000, signo, UINT_MAX);
subrata_modakded2c1e2009-12-07 11:44:52 +0000164
165 TEST(sigwaitinfo(&sigs, &si, &ts));
166 REPORT_SUCCESS(-1, EAGAIN);
167
168 kill(child, SIGTERM);
169}
170
171/* Note: sigwait-ing for a signal that is not blocked is unspecified
172 * by POSIX; but works for non-ignored signals under Linux
173 */
174void test_unmasked_matching(swi_func sigwaitinfo, int signo)
175{
176 sigset_t sigs;
177 siginfo_t si;
178 pid_t child;
179
180 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
181 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
182
183 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800184 child = create_sig_proc(100000, signo, UINT_MAX);
subrata_modakded2c1e2009-12-07 11:44:52 +0000185
186 TEST(sigwaitinfo(&sigs, &si, NULL));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800187 REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
188 && si.si_code == SI_USER
189 && si.si_signo == signo, "Struct siginfo mismatch");
subrata_modakded2c1e2009-12-07 11:44:52 +0000190
191 kill(child, SIGTERM);
192}
193
194void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo)
195{
196 sigset_t sigs;
197 pid_t child;
198
199 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
200 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
201 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800202 child = create_sig_proc(100000, signo, UINT_MAX);
subrata_modakded2c1e2009-12-07 11:44:52 +0000203
204 TEST(sigwaitinfo(&sigs, NULL, NULL));
205 REPORT_SUCCESS(signo, 0);
206
207 kill(child, SIGTERM);
208}
209
210void test_masked_matching(swi_func sigwaitinfo, int signo)
211{
212 sigset_t sigs, oldmask;
213 siginfo_t si;
214 pid_t child;
215
216 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
217 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
218 /* let's not get interrupted by our dying child */
219 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
220
Wanlong Gao354ebb42012-12-07 10:10:04 +0800221 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs,
222 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000223
224 /* don't wait on a SIGCHLD */
225 SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
226
227 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800228 child = create_sig_proc(0, signo, 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000229
230 TEST(sigwaitinfo(&sigs, &si, NULL));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800231 REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
232 && si.si_code == SI_USER
233 && si.si_signo == signo, "Struct siginfo mismatch");
subrata_modakded2c1e2009-12-07 11:44:52 +0000234
Wanlong Gao354ebb42012-12-07 10:10:04 +0800235 SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed",
236 SIG_SETMASK, &oldmask, &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000237
Caspar Zhangd59a6592013-03-07 14:59:12 +0800238 tst_count--;
subrata_modakded2c1e2009-12-07 11:44:52 +0000239
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800240 if (sigismember(&oldmask, signo))
subrata_modakded2c1e2009-12-07 11:44:52 +0000241 tst_resm(TPASS, "sigwaitinfo restored the original mask");
242 else
Wanlong Gao354ebb42012-12-07 10:10:04 +0800243 tst_resm(TFAIL,
244 "sigwaitinfo failed to restore the original mask");
subrata_modakded2c1e2009-12-07 11:44:52 +0000245}
246
247void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
248{
249 sigset_t sigs, oldmask;
250 siginfo_t si;
251 pid_t child[2];
252
Wanlong Gao354ebb42012-12-07 10:10:04 +0800253 signo = SIGRTMIN + 1;
subrata_modakded2c1e2009-12-07 11:44:52 +0000254
255 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
256 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
Wanlong Gao354ebb42012-12-07 10:10:04 +0800257 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo + 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000258 /* let's not get interrupted by our dying child */
259 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
260
Wanlong Gao354ebb42012-12-07 10:10:04 +0800261 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs,
262 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000263
264 /* don't wait on a SIGCHLD */
265 SUCCEED_OR_DIE(sigdelset, "sigdelset failed", &sigs, SIGCHLD);
266
267 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800268 child[0] = create_sig_proc(0, signo, 1);
269 child[1] = create_sig_proc(0, signo + 1, 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000270
271 TEST(sigwaitinfo(&sigs, &si, NULL));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800272 REPORT_SUCCESS_COND(signo, 0, si.si_pid == child[0]
273 && si.si_code == SI_USER
274 && si.si_signo == signo, "Struct siginfo mismatch");
subrata_modakded2c1e2009-12-07 11:44:52 +0000275
276 /* eat the other signal */
Caspar Zhangd59a6592013-03-07 14:59:12 +0800277 tst_count--;
subrata_modakded2c1e2009-12-07 11:44:52 +0000278 TEST(sigwaitinfo(&sigs, &si, NULL));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800279 REPORT_SUCCESS_COND(signo + 1, 0, si.si_pid == child[1]
280 && si.si_code == SI_USER
281 && si.si_signo == signo + 1,
282 "Struct siginfo mismatch");
subrata_modakded2c1e2009-12-07 11:44:52 +0000283
Wanlong Gao354ebb42012-12-07 10:10:04 +0800284 SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed",
285 SIG_SETMASK, &oldmask, &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000286
Caspar Zhangd59a6592013-03-07 14:59:12 +0800287 tst_count--;
subrata_modakded2c1e2009-12-07 11:44:52 +0000288
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800289 if (sigismember(&oldmask, signo))
subrata_modakded2c1e2009-12-07 11:44:52 +0000290 tst_resm(TPASS, "sigwaitinfo restored the original mask");
291 else
Wanlong Gao354ebb42012-12-07 10:10:04 +0800292 tst_resm(TFAIL,
293 "sigwaitinfo failed to restore the original mask");
subrata_modakded2c1e2009-12-07 11:44:52 +0000294}
295
296void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo)
297{
298 sigset_t sigs, oldmask;
299 pid_t child;
300
301 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
302 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
303 /* let's not get interrupted by our dying child */
304 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
305
Wanlong Gao354ebb42012-12-07 10:10:04 +0800306 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs,
307 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000308
309 /* don't wait on a SIGCHLD */
310 SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
311
312 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800313 child = create_sig_proc(0, signo, 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000314
315 TEST(sigwaitinfo(&sigs, NULL, NULL));
316 REPORT_SUCCESS(signo, 0);
317
Wanlong Gao354ebb42012-12-07 10:10:04 +0800318 SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed",
319 SIG_SETMASK, &oldmask, &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000320
Caspar Zhangd59a6592013-03-07 14:59:12 +0800321 tst_count--;
subrata_modakded2c1e2009-12-07 11:44:52 +0000322
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800323 if (sigismember(&oldmask, signo))
subrata_modakded2c1e2009-12-07 11:44:52 +0000324 tst_resm(TPASS, "sigwaitinfo restored the original mask");
325 else
Wanlong Gao354ebb42012-12-07 10:10:04 +0800326 tst_resm(TFAIL,
327 "sigwaitinfo failed to restore the original mask");
subrata_modakded2c1e2009-12-07 11:44:52 +0000328
329}
330
331void test_bad_address(swi_func sigwaitinfo, int signo)
332{
333 sigset_t sigs, oldmask;
334 pid_t child;
335
336 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
337 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
338 /* let's not get interrupted by our dying child */
339 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
340
Wanlong Gao354ebb42012-12-07 10:10:04 +0800341 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs,
342 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000343
344 /* don't wait on a SIGCHLD */
345 SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
346
347 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800348 child = create_sig_proc(0, signo, 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000349
Wanlong Gao354ebb42012-12-07 10:10:04 +0800350 TEST(sigwaitinfo(&sigs, (void *)1, NULL));
subrata_modakded2c1e2009-12-07 11:44:52 +0000351 REPORT_SUCCESS(-1, EFAULT);
352
Wanlong Gao354ebb42012-12-07 10:10:04 +0800353 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &oldmask,
354 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000355
356 kill(child, SIGTERM);
357}
358
359void test_bad_address2(swi_func sigwaitinfo, int signo)
360{
Wanlong Gao354ebb42012-12-07 10:10:04 +0800361 TEST(sigwaitinfo((void *)1, NULL, NULL));
subrata_modakded2c1e2009-12-07 11:44:52 +0000362 REPORT_SUCCESS(-1, EFAULT);
363}
364
365void test_bad_address3(swi_func sigwaitinfo, int signo)
366{
367 sigset_t sigs;
368 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
369
Wanlong Gao354ebb42012-12-07 10:10:04 +0800370 TEST(sigwaitinfo(&sigs, NULL, (void *)1));
subrata_modakded2c1e2009-12-07 11:44:52 +0000371 REPORT_SUCCESS(-1, EFAULT);
372}
373
374struct test_desc {
375 test_func tf;
376 swi_func swi;
377 int signo;
Garrett Cooperab5336e2010-12-19 08:41:59 -0800378} tests[] = {
379#ifdef TEST_RT_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800380 {
381 test_empty_set, my_rt_sigtimedwait, SIGUSR1}, {
382 test_unmasked_matching, my_rt_sigtimedwait, SIGUSR1}, {
383 test_masked_matching, my_rt_sigtimedwait, SIGUSR1}, {
384 test_unmasked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1}, {
385 test_masked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1}, {
386 test_bad_address, my_rt_sigtimedwait, SIGUSR1}, {
387 test_bad_address2, my_rt_sigtimedwait, SIGUSR1}, {
388 test_bad_address3, my_rt_sigtimedwait, SIGUSR1}, {
389 test_timeout, my_rt_sigtimedwait, 0},
390 /* Special cases */
391 /* 1: sigwaitinfo does respond to ignored signal */
392 {
393 test_masked_matching, my_rt_sigtimedwait, SIGUSR2},
394 /* 2: An ignored signal doesn't cause sigwaitinfo to return EINTR */
395 {
396 test_timeout, my_rt_sigtimedwait, SIGUSR2},
397 /* 3: The handler is not called when the signal is waited for by sigwaitinfo */
398 {
399 test_masked_matching, my_rt_sigtimedwait, SIGTERM},
400 /* 4: Simultaneous realtime signals are delivered in the order of increasing signal number */
401 {
402 test_masked_matching_rt, my_rt_sigtimedwait, -1},
subrata_modakded2c1e2009-12-07 11:44:52 +0000403#endif
404#if defined TEST_SIGWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800405 {
406 test_unmasked_matching_noinfo, my_sigwait, SIGUSR1}, {
407 test_masked_matching_noinfo, my_sigwait, SIGUSR1},
subrata_modakded2c1e2009-12-07 11:44:52 +0000408#endif
409#if defined TEST_SIGWAITINFO
Wanlong Gao354ebb42012-12-07 10:10:04 +0800410 {
411 test_empty_set, my_sigwaitinfo, SIGUSR1}, {
412 test_unmasked_matching, my_sigwaitinfo, SIGUSR1}, {
413 test_masked_matching, my_sigwaitinfo, SIGUSR1}, {
414 test_unmasked_matching_noinfo, my_sigwaitinfo, SIGUSR1}, {
415 test_masked_matching_noinfo, my_sigwaitinfo, SIGUSR1}, {
416 test_bad_address, my_sigwaitinfo, SIGUSR1}, {
417 test_bad_address2, my_sigwaitinfo, SIGUSR1},
subrata_modakded2c1e2009-12-07 11:44:52 +0000418#endif
419#if defined TEST_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800420 {
421 test_empty_set, my_sigtimedwait, SIGUSR1}, {
422 test_unmasked_matching, my_sigtimedwait, SIGUSR1}, {
423 test_masked_matching, my_sigtimedwait, SIGUSR1}, {
424 test_unmasked_matching_noinfo, my_sigtimedwait, SIGUSR1}, {
425 test_masked_matching_noinfo, my_sigtimedwait, SIGUSR1}, {
426 test_bad_address, my_sigtimedwait, SIGUSR1}, {
427 test_bad_address2, my_sigtimedwait, SIGUSR1}, {
428 test_bad_address3, my_sigtimedwait, SIGUSR1}, {
429 test_timeout, my_sigtimedwait, 0},
subrata_modakded2c1e2009-12-07 11:44:52 +0000430#endif
431};
432
433#if defined TEST_SIGWAITINFO
Wanlong Gao354ebb42012-12-07 10:10:04 +0800434const char *TCID = "sigwaitinfo01";
subrata_modakded2c1e2009-12-07 11:44:52 +0000435#elif defined TEST_RT_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800436const char *TCID = "rt_sigtimedwait01";
subrata_modakded2c1e2009-12-07 11:44:52 +0000437#elif defined TEST_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800438const char *TCID = "sigtimedwait01";
subrata_modakded2c1e2009-12-07 11:44:52 +0000439#elif defined TEST_SIGWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800440const char *TCID = "sigwait01";
subrata_modakded2c1e2009-12-07 11:44:52 +0000441#endif
442
Cyril Hrubisb863a0b2014-09-24 13:15:29 +0200443int TST_TOTAL = ARRAY_SIZE(tests);
subrata_modakded2c1e2009-12-07 11:44:52 +0000444
Wanlong Gao354ebb42012-12-07 10:10:04 +0800445int main(int argc, char **argv)
subrata_modakded2c1e2009-12-07 11:44:52 +0000446{
447 unsigned i;
448 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +0200449 const char *msg;
subrata_modakded2c1e2009-12-07 11:44:52 +0000450
Garrett Cooperab5336e2010-12-19 08:41:59 -0800451 if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -0800452 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
Garrett Cooper2c282152010-12-16 00:55:50 -0800453
subrata_modakded2c1e2009-12-07 11:44:52 +0000454 setup();
455
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800456 for (lc = 0; TEST_LOOPING(lc); ++lc) {
Caspar Zhangd59a6592013-03-07 14:59:12 +0800457 tst_count = 0;
subrata_modakded2c1e2009-12-07 11:44:52 +0000458
Cyril Hrubisb863a0b2014-09-24 13:15:29 +0200459 for (i = 0; i < ARRAY_SIZE(tests); i++) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800460 alarm(10); /* arrange a 10 second timeout */
Garrett Cooperab5336e2010-12-19 08:41:59 -0800461 tst_resm(TINFO, "%p, %d", tests[i].swi, tests[i].signo);
subrata_modakded2c1e2009-12-07 11:44:52 +0000462 tests[i].tf(tests[i].swi, tests[i].signo);
463 }
464 alarm(0);
465 }
466
467 cleanup();
Garrett Cooperab5336e2010-12-19 08:41:59 -0800468 tst_exit();
Garrett Cooper60611092011-02-23 00:04:58 -0800469}