blob: d592289b692322d55f34804b569f47a5e66fb324 [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"
24#include "usctest.h"
25#include <errno.h>
26#include <signal.h>
27#include "../utils/include_j_h.h"
28#include "../utils/common_j_h.c"
29#include <limits.h>
30#include "linux_syscall_numbers.h"
31
Garrett Cooper60611092011-02-23 00:04:58 -080032#define SUCCEED_OR_DIE(syscall, message, ...) \
33 (errno = 0, \
34 ({int ret=syscall(__VA_ARGS__); \
35 if (ret==-1) \
36 tst_brkm(TBROK|TERRNO, cleanup, message);\
subrata_modakded2c1e2009-12-07 11:44:52 +000037 ret;}))
38
39/* Report success iff TEST_RETURN and TEST_ERRNO are equal to
40 exp_return and exp_errno, resp., and cond is true. If cond is not
41 true, report condition_errmsg
42*/
Wanlong Gao354ebb42012-12-07 10:10:04 +080043static void report_success_cond(const char *func, const char *file, int line,
44 long exp_return, int exp_errno, int condition,
45 char *condition_errmsg)
subrata_modakded2c1e2009-12-07 11:44:52 +000046{
Wanlong Gao354ebb42012-12-07 10:10:04 +080047 if (exp_return == TEST_RETURN
48 && (exp_return != -1 || exp_errno == TEST_ERRNO))
Garrett Cooperdf3eb162010-11-28 22:44:32 -080049 if (condition)
subrata_modakded2c1e2009-12-07 11:44:52 +000050 tst_resm(TPASS, "Test passed");
51 else
Wanlong Gao354ebb42012-12-07 10:10:04 +080052 tst_resm(TFAIL, "%s (%s: %d): %s", func, file, line,
53 condition_errmsg);
Garrett Cooperdf3eb162010-11-28 22:44:32 -080054 else if (TEST_RETURN != -1)
Wanlong Gao354ebb42012-12-07 10:10:04 +080055 tst_resm(TFAIL,
56 "%s (%s: %d): Unexpected return value; expected %ld, got %ld",
57 func, file, line, exp_return, TEST_RETURN);
subrata_modakded2c1e2009-12-07 11:44:52 +000058 else
Wanlong Gao354ebb42012-12-07 10:10:04 +080059 tst_resm(TFAIL | TTERRNO, "%s (%s: %d): Unexpected failure",
60 func, file, line);
subrata_modakded2c1e2009-12-07 11:44:52 +000061}
62
63#define REPORT_SUCCESS_COND(exp_return, exp_errno, condition, condition_errmsg) \
64 report_success_cond(__FUNCTION__, __FILE__, __LINE__, exp_return, exp_errno, condition, condition_errmsg);
65
66/* Report success iff TEST_RETURN and TEST_ERRNO are equal to
67 exp_return and exp_errno, resp.
68*/
69#define REPORT_SUCCESS(exp_return, exp_errno) \
70 REPORT_SUCCESS_COND(exp_return, exp_errno, 1, "");
71
Garrett Cooperab5336e2010-12-19 08:41:59 -080072static void cleanup(void);
subrata_modakded2c1e2009-12-07 11:44:52 +000073
74static void empty_handler(int sig)
75{
76}
77
78static void setup(void)
79{
80 tst_sig(FORK, DEF_HANDLER, cleanup);
81 signal(SIGUSR1, empty_handler);
82 signal(SIGALRM, empty_handler);
83 signal(SIGUSR2, SIG_IGN);
84
85 TEST_PAUSE;
86}
87
88static void cleanup(void)
89{
subrata_modakded2c1e2009-12-07 11:44:52 +000090
Garrett Cooper60611092011-02-23 00:04:58 -080091 TEST_CLEANUP;
subrata_modakded2c1e2009-12-07 11:44:52 +000092}
93
Wanlong Gao354ebb42012-12-07 10:10:04 +080094typedef int (*swi_func) (const sigset_t * set, siginfo_t * info,
95 struct timespec * timeout);
96typedef void (*test_func) (swi_func, int);
subrata_modakded2c1e2009-12-07 11:44:52 +000097
Garrett Cooperab5336e2010-12-19 08:41:59 -080098#ifdef TEST_SIGWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +080099static int my_sigwait(const sigset_t * set, siginfo_t * info,
100 struct timespec *timeout)
subrata_modakded2c1e2009-12-07 11:44:52 +0000101{
102 int ret;
Wanlong Gao354ebb42012-12-07 10:10:04 +0800103 int err = sigwait(set, &ret);
subrata_modakded2c1e2009-12-07 11:44:52 +0000104
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800105 if (err == 0)
subrata_modakded2c1e2009-12-07 11:44:52 +0000106 return ret;
107 errno = err;
108 return -1;
109}
Garrett Cooperab5336e2010-12-19 08:41:59 -0800110#endif
subrata_modakded2c1e2009-12-07 11:44:52 +0000111
Garrett Cooperab5336e2010-12-19 08:41:59 -0800112#ifdef TEST_SIGWAITINFO
Wanlong Gao354ebb42012-12-07 10:10:04 +0800113static int my_sigwaitinfo(const sigset_t * set, siginfo_t * info,
114 struct timespec *timeout)
subrata_modakded2c1e2009-12-07 11:44:52 +0000115{
Garrett Cooper60611092011-02-23 00:04:58 -0800116
subrata_modakded2c1e2009-12-07 11:44:52 +0000117 return sigwaitinfo(set, info);
118}
Garrett Cooperab5336e2010-12-19 08:41:59 -0800119#endif
subrata_modakded2c1e2009-12-07 11:44:52 +0000120
Garrett Cooperab5336e2010-12-19 08:41:59 -0800121#ifdef TEST_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800122static int my_sigtimedwait(const sigset_t * set, siginfo_t * info,
123 struct timespec *timeout)
subrata_modakded2c1e2009-12-07 11:44:52 +0000124{
Garrett Cooper60611092011-02-23 00:04:58 -0800125
subrata_modakded2c1e2009-12-07 11:44:52 +0000126 return sigtimedwait(set, info, timeout);
127}
Garrett Cooperab5336e2010-12-19 08:41:59 -0800128#endif
subrata_modakded2c1e2009-12-07 11:44:52 +0000129
Garrett Cooperab5336e2010-12-19 08:41:59 -0800130#ifdef TEST_RT_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800131static int my_rt_sigtimedwait(const sigset_t * set, siginfo_t * info,
132 struct timespec *timeout)
subrata_modakded2c1e2009-12-07 11:44:52 +0000133{
Garrett Cooper60611092011-02-23 00:04:58 -0800134
subrata_modakded2c1e2009-12-07 11:44:52 +0000135 /* The last argument is (number_of_signals)/(bits_per_byte), which are 64 and 8, resp. */
Jan Stancek359980f2013-02-15 10:16:05 +0100136 return ltp_syscall(__NR_rt_sigtimedwait, set, info, timeout, 8);
subrata_modakded2c1e2009-12-07 11:44:52 +0000137}
Garrett Cooperab5336e2010-12-19 08:41:59 -0800138#endif
subrata_modakded2c1e2009-12-07 11:44:52 +0000139
140void test_empty_set(swi_func sigwaitinfo, int signo)
141{
142 sigset_t sigs;
143 siginfo_t si;
144 pid_t child;
145
146 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
147 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800148 child = create_sig_proc(100000, signo, UINT_MAX);
subrata_modakded2c1e2009-12-07 11:44:52 +0000149
150 TEST(sigwaitinfo(&sigs, &si, NULL));
151 REPORT_SUCCESS(-1, EINTR);
152
153 kill(child, SIGTERM);
154}
155
156void test_timeout(swi_func sigwaitinfo, int signo)
157{
158 sigset_t sigs;
159 siginfo_t si;
160 pid_t child;
Wanlong Gao354ebb42012-12-07 10:10:04 +0800161 struct timespec ts = {.tv_sec = 1 };
subrata_modakded2c1e2009-12-07 11:44:52 +0000162
163 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
164
165 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800166 child = create_sig_proc(100000, signo, UINT_MAX);
subrata_modakded2c1e2009-12-07 11:44:52 +0000167
168 TEST(sigwaitinfo(&sigs, &si, &ts));
169 REPORT_SUCCESS(-1, EAGAIN);
170
171 kill(child, SIGTERM);
172}
173
174/* Note: sigwait-ing for a signal that is not blocked is unspecified
175 * by POSIX; but works for non-ignored signals under Linux
176 */
177void test_unmasked_matching(swi_func sigwaitinfo, int signo)
178{
179 sigset_t sigs;
180 siginfo_t si;
181 pid_t child;
182
183 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
184 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
185
186 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800187 child = create_sig_proc(100000, signo, UINT_MAX);
subrata_modakded2c1e2009-12-07 11:44:52 +0000188
189 TEST(sigwaitinfo(&sigs, &si, NULL));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800190 REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
191 && si.si_code == SI_USER
192 && si.si_signo == signo, "Struct siginfo mismatch");
subrata_modakded2c1e2009-12-07 11:44:52 +0000193
194 kill(child, SIGTERM);
195}
196
197void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo)
198{
199 sigset_t sigs;
200 pid_t child;
201
202 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
203 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
204 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800205 child = create_sig_proc(100000, signo, UINT_MAX);
subrata_modakded2c1e2009-12-07 11:44:52 +0000206
207 TEST(sigwaitinfo(&sigs, NULL, NULL));
208 REPORT_SUCCESS(signo, 0);
209
210 kill(child, SIGTERM);
211}
212
213void test_masked_matching(swi_func sigwaitinfo, int signo)
214{
215 sigset_t sigs, oldmask;
216 siginfo_t si;
217 pid_t child;
218
219 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
220 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
221 /* let's not get interrupted by our dying child */
222 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
223
Wanlong Gao354ebb42012-12-07 10:10:04 +0800224 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs,
225 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000226
227 /* don't wait on a SIGCHLD */
228 SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
229
230 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800231 child = create_sig_proc(0, signo, 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000232
233 TEST(sigwaitinfo(&sigs, &si, NULL));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800234 REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
235 && si.si_code == SI_USER
236 && si.si_signo == signo, "Struct siginfo mismatch");
subrata_modakded2c1e2009-12-07 11:44:52 +0000237
Wanlong Gao354ebb42012-12-07 10:10:04 +0800238 SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed",
239 SIG_SETMASK, &oldmask, &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000240
241 Tst_count--;
242
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800243 if (sigismember(&oldmask, signo))
subrata_modakded2c1e2009-12-07 11:44:52 +0000244 tst_resm(TPASS, "sigwaitinfo restored the original mask");
245 else
Wanlong Gao354ebb42012-12-07 10:10:04 +0800246 tst_resm(TFAIL,
247 "sigwaitinfo failed to restore the original mask");
subrata_modakded2c1e2009-12-07 11:44:52 +0000248}
249
250void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
251{
252 sigset_t sigs, oldmask;
253 siginfo_t si;
254 pid_t child[2];
255
Wanlong Gao354ebb42012-12-07 10:10:04 +0800256 signo = SIGRTMIN + 1;
subrata_modakded2c1e2009-12-07 11:44:52 +0000257
258 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
259 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
Wanlong Gao354ebb42012-12-07 10:10:04 +0800260 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo + 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000261 /* let's not get interrupted by our dying child */
262 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
263
Wanlong Gao354ebb42012-12-07 10:10:04 +0800264 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs,
265 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000266
267 /* don't wait on a SIGCHLD */
268 SUCCEED_OR_DIE(sigdelset, "sigdelset failed", &sigs, SIGCHLD);
269
270 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800271 child[0] = create_sig_proc(0, signo, 1);
272 child[1] = create_sig_proc(0, signo + 1, 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000273
274 TEST(sigwaitinfo(&sigs, &si, NULL));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800275 REPORT_SUCCESS_COND(signo, 0, si.si_pid == child[0]
276 && si.si_code == SI_USER
277 && si.si_signo == signo, "Struct siginfo mismatch");
subrata_modakded2c1e2009-12-07 11:44:52 +0000278
279 /* eat the other signal */
280 Tst_count--;
281 TEST(sigwaitinfo(&sigs, &si, NULL));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800282 REPORT_SUCCESS_COND(signo + 1, 0, si.si_pid == child[1]
283 && si.si_code == SI_USER
284 && si.si_signo == signo + 1,
285 "Struct siginfo mismatch");
subrata_modakded2c1e2009-12-07 11:44:52 +0000286
Wanlong Gao354ebb42012-12-07 10:10:04 +0800287 SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed",
288 SIG_SETMASK, &oldmask, &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000289
290 Tst_count--;
291
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800292 if (sigismember(&oldmask, signo))
subrata_modakded2c1e2009-12-07 11:44:52 +0000293 tst_resm(TPASS, "sigwaitinfo restored the original mask");
294 else
Wanlong Gao354ebb42012-12-07 10:10:04 +0800295 tst_resm(TFAIL,
296 "sigwaitinfo failed to restore the original mask");
subrata_modakded2c1e2009-12-07 11:44:52 +0000297}
298
299void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo)
300{
301 sigset_t sigs, oldmask;
302 pid_t child;
303
304 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
305 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
306 /* let's not get interrupted by our dying child */
307 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
308
Wanlong Gao354ebb42012-12-07 10:10:04 +0800309 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs,
310 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000311
312 /* don't wait on a SIGCHLD */
313 SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
314
315 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800316 child = create_sig_proc(0, signo, 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000317
318 TEST(sigwaitinfo(&sigs, NULL, NULL));
319 REPORT_SUCCESS(signo, 0);
320
Wanlong Gao354ebb42012-12-07 10:10:04 +0800321 SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed",
322 SIG_SETMASK, &oldmask, &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000323
324 Tst_count--;
325
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800326 if (sigismember(&oldmask, signo))
subrata_modakded2c1e2009-12-07 11:44:52 +0000327 tst_resm(TPASS, "sigwaitinfo restored the original mask");
328 else
Wanlong Gao354ebb42012-12-07 10:10:04 +0800329 tst_resm(TFAIL,
330 "sigwaitinfo failed to restore the original mask");
subrata_modakded2c1e2009-12-07 11:44:52 +0000331
332}
333
334void test_bad_address(swi_func sigwaitinfo, int signo)
335{
336 sigset_t sigs, oldmask;
337 pid_t child;
338
339 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
340 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
341 /* let's not get interrupted by our dying child */
342 SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
343
Wanlong Gao354ebb42012-12-07 10:10:04 +0800344 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs,
345 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000346
347 /* don't wait on a SIGCHLD */
348 SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
349
350 /* Run a child that will wake us up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800351 child = create_sig_proc(0, signo, 1);
subrata_modakded2c1e2009-12-07 11:44:52 +0000352
Wanlong Gao354ebb42012-12-07 10:10:04 +0800353 TEST(sigwaitinfo(&sigs, (void *)1, NULL));
subrata_modakded2c1e2009-12-07 11:44:52 +0000354 REPORT_SUCCESS(-1, EFAULT);
355
Wanlong Gao354ebb42012-12-07 10:10:04 +0800356 SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &oldmask,
357 &oldmask);
subrata_modakded2c1e2009-12-07 11:44:52 +0000358
359 kill(child, SIGTERM);
360}
361
362void test_bad_address2(swi_func sigwaitinfo, int signo)
363{
Wanlong Gao354ebb42012-12-07 10:10:04 +0800364 TEST(sigwaitinfo((void *)1, NULL, NULL));
subrata_modakded2c1e2009-12-07 11:44:52 +0000365 REPORT_SUCCESS(-1, EFAULT);
366}
367
368void test_bad_address3(swi_func sigwaitinfo, int signo)
369{
370 sigset_t sigs;
371 SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
372
Wanlong Gao354ebb42012-12-07 10:10:04 +0800373 TEST(sigwaitinfo(&sigs, NULL, (void *)1));
subrata_modakded2c1e2009-12-07 11:44:52 +0000374 REPORT_SUCCESS(-1, EFAULT);
375}
376
377struct test_desc {
378 test_func tf;
379 swi_func swi;
380 int signo;
Garrett Cooperab5336e2010-12-19 08:41:59 -0800381} tests[] = {
382#ifdef TEST_RT_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800383 {
384 test_empty_set, my_rt_sigtimedwait, SIGUSR1}, {
385 test_unmasked_matching, my_rt_sigtimedwait, SIGUSR1}, {
386 test_masked_matching, my_rt_sigtimedwait, SIGUSR1}, {
387 test_unmasked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1}, {
388 test_masked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1}, {
389 test_bad_address, my_rt_sigtimedwait, SIGUSR1}, {
390 test_bad_address2, my_rt_sigtimedwait, SIGUSR1}, {
391 test_bad_address3, my_rt_sigtimedwait, SIGUSR1}, {
392 test_timeout, my_rt_sigtimedwait, 0},
393 /* Special cases */
394 /* 1: sigwaitinfo does respond to ignored signal */
395 {
396 test_masked_matching, my_rt_sigtimedwait, SIGUSR2},
397 /* 2: An ignored signal doesn't cause sigwaitinfo to return EINTR */
398 {
399 test_timeout, my_rt_sigtimedwait, SIGUSR2},
400 /* 3: The handler is not called when the signal is waited for by sigwaitinfo */
401 {
402 test_masked_matching, my_rt_sigtimedwait, SIGTERM},
403 /* 4: Simultaneous realtime signals are delivered in the order of increasing signal number */
404 {
405 test_masked_matching_rt, my_rt_sigtimedwait, -1},
subrata_modakded2c1e2009-12-07 11:44:52 +0000406#endif
407#if defined TEST_SIGWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800408 {
409 test_unmasked_matching_noinfo, my_sigwait, SIGUSR1}, {
410 test_masked_matching_noinfo, my_sigwait, SIGUSR1},
subrata_modakded2c1e2009-12-07 11:44:52 +0000411#endif
412#if defined TEST_SIGWAITINFO
Wanlong Gao354ebb42012-12-07 10:10:04 +0800413 {
414 test_empty_set, my_sigwaitinfo, SIGUSR1}, {
415 test_unmasked_matching, my_sigwaitinfo, SIGUSR1}, {
416 test_masked_matching, my_sigwaitinfo, SIGUSR1}, {
417 test_unmasked_matching_noinfo, my_sigwaitinfo, SIGUSR1}, {
418 test_masked_matching_noinfo, my_sigwaitinfo, SIGUSR1}, {
419 test_bad_address, my_sigwaitinfo, SIGUSR1}, {
420 test_bad_address2, my_sigwaitinfo, SIGUSR1},
subrata_modakded2c1e2009-12-07 11:44:52 +0000421#endif
422#if defined TEST_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800423 {
424 test_empty_set, my_sigtimedwait, SIGUSR1}, {
425 test_unmasked_matching, my_sigtimedwait, SIGUSR1}, {
426 test_masked_matching, my_sigtimedwait, SIGUSR1}, {
427 test_unmasked_matching_noinfo, my_sigtimedwait, SIGUSR1}, {
428 test_masked_matching_noinfo, my_sigtimedwait, SIGUSR1}, {
429 test_bad_address, my_sigtimedwait, SIGUSR1}, {
430 test_bad_address2, my_sigtimedwait, SIGUSR1}, {
431 test_bad_address3, my_sigtimedwait, SIGUSR1}, {
432 test_timeout, my_sigtimedwait, 0},
subrata_modakded2c1e2009-12-07 11:44:52 +0000433#endif
434};
435
436#if defined TEST_SIGWAITINFO
Wanlong Gao354ebb42012-12-07 10:10:04 +0800437const char *TCID = "sigwaitinfo01";
subrata_modakded2c1e2009-12-07 11:44:52 +0000438#elif defined TEST_RT_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800439const char *TCID = "rt_sigtimedwait01";
subrata_modakded2c1e2009-12-07 11:44:52 +0000440#elif defined TEST_SIGTIMEDWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800441const char *TCID = "sigtimedwait01";
subrata_modakded2c1e2009-12-07 11:44:52 +0000442#elif defined TEST_SIGWAIT
Wanlong Gao354ebb42012-12-07 10:10:04 +0800443const char *TCID = "sigwait01";
subrata_modakded2c1e2009-12-07 11:44:52 +0000444#endif
445
Wanlong Gao354ebb42012-12-07 10:10:04 +0800446int TST_TOTAL = sizeof(tests) / sizeof(*tests);
subrata_modakded2c1e2009-12-07 11:44:52 +0000447
Wanlong Gao354ebb42012-12-07 10:10:04 +0800448int main(int argc, char **argv)
subrata_modakded2c1e2009-12-07 11:44:52 +0000449{
450 unsigned i;
451 int lc;
Wanlong Gao354ebb42012-12-07 10:10:04 +0800452 char *msg;
subrata_modakded2c1e2009-12-07 11:44:52 +0000453
Garrett Cooperab5336e2010-12-19 08:41:59 -0800454 if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -0800455 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
Garrett Cooper2c282152010-12-16 00:55:50 -0800456
subrata_modakded2c1e2009-12-07 11:44:52 +0000457 setup();
458
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800459 for (lc = 0; TEST_LOOPING(lc); ++lc) {
subrata_modakded2c1e2009-12-07 11:44:52 +0000460 Tst_count = 0;
461
Wanlong Gao354ebb42012-12-07 10:10:04 +0800462 for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) {
463 alarm(10); /* arrange a 10 second timeout */
Garrett Cooperab5336e2010-12-19 08:41:59 -0800464 tst_resm(TINFO, "%p, %d", tests[i].swi, tests[i].signo);
subrata_modakded2c1e2009-12-07 11:44:52 +0000465 tests[i].tf(tests[i].swi, tests[i].signo);
466 }
467 alarm(0);
468 }
469
470 cleanup();
Garrett Cooperab5336e2010-12-19 08:41:59 -0800471 tst_exit();
Garrett Cooper60611092011-02-23 00:04:58 -0800472}