1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Copyright (c) Jiri Palecek<jpalecek@web.de>, 2009 */
3
4 #include "time64_variants.h"
5 #include "libsigwait.h"
6
my_rt_sigtimedwait(const sigset_t * set,siginfo_t * info,void * timeout)7 static int my_rt_sigtimedwait(const sigset_t * set, siginfo_t * info,
8 void *timeout)
9 {
10 /* _NSIG is always the right number of bits of signal map for all arches */
11 return tst_syscall(__NR_rt_sigtimedwait, set, info, timeout, _NSIG/8);
12 }
13
14 #if (__NR_rt_sigtimedwait_time64 != __LTP__NR_INVALID_SYSCALL)
my_rt_sigtimedwait_time64(const sigset_t * set,siginfo_t * info,void * timeout)15 static int my_rt_sigtimedwait_time64(const sigset_t * set, siginfo_t * info,
16 void *timeout)
17 {
18 /* _NSIG is always the right number of bits of signal map for all arches */
19 return tst_syscall(__NR_rt_sigtimedwait_time64, set, info, timeout, _NSIG/8);
20 }
21 #endif
22
23 struct sigwait_test_desc tests[] = {
24 { test_empty_set, SIGUSR1},
25 { test_unmasked_matching, SIGUSR1},
26 { test_masked_matching, SIGUSR1},
27 { test_unmasked_matching_noinfo, SIGUSR1},
28 { test_masked_matching_noinfo, SIGUSR1},
29 { test_bad_address, SIGUSR1},
30 { test_bad_address2, SIGUSR1},
31 { test_bad_address3, SIGUSR1},
32 { test_timeout, 0},
33 /* Special cases */
34 /* 1: sigwaitinfo does respond to ignored signal */
35 { test_masked_matching, SIGUSR2},
36 /* 2: An ignored signal doesn't cause sigwaitinfo to return EINTR */
37 { test_timeout, SIGUSR2},
38 /* 3: The handler is not called when the signal is waited for by sigwaitinfo */
39 { test_masked_matching, SIGTERM},
40 /* 4: Simultaneous realtime signals are delivered in the order of increasing signal number */
41 { test_masked_matching_rt, -1},
42 };
43
44 static struct time64_variants variants[] = {
45 #if (__NR_rt_sigtimedwait != __LTP__NR_INVALID_SYSCALL)
46 { .sigwait = my_rt_sigtimedwait, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
47 #endif
48
49 #if (__NR_rt_sigtimedwait_time64 != __LTP__NR_INVALID_SYSCALL)
50 { .sigwait = my_rt_sigtimedwait_time64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
51 #endif
52 };
53
run(unsigned int i)54 static void run(unsigned int i)
55 {
56 struct time64_variants *tv = &variants[tst_variant];
57 struct sigwait_test_desc *tc = &tests[i];
58
59 tc->tf(tv->sigwait, tc->signo, tv->ts_type);
60 }
61
setup(void)62 static void setup(void)
63 {
64 tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc);
65 sigwait_setup();
66 }
67
68 static struct tst_test test = {
69 .test= run,
70 .tcnt = ARRAY_SIZE(tests),
71 .test_variants = ARRAY_SIZE(variants),
72 .setup = setup,
73 .forks_child = 1,
74 };
75