xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/sigwait/sigwait01.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /* Copyright (c) Jiri Palecek<[email protected]>, 2009 */
3*49cdfc7eSAndroid Build Coastguard Worker 
4*49cdfc7eSAndroid Build Coastguard Worker #include "libsigwait.h"
5*49cdfc7eSAndroid Build Coastguard Worker 
my_sigwait(const sigset_t * set,siginfo_t * info LTP_ATTRIBUTE_UNUSED,void * timeout LTP_ATTRIBUTE_UNUSED)6*49cdfc7eSAndroid Build Coastguard Worker static int my_sigwait(const sigset_t * set,
7*49cdfc7eSAndroid Build Coastguard Worker 		      siginfo_t * info LTP_ATTRIBUTE_UNUSED,
8*49cdfc7eSAndroid Build Coastguard Worker 		      void *timeout LTP_ATTRIBUTE_UNUSED)
9*49cdfc7eSAndroid Build Coastguard Worker {
10*49cdfc7eSAndroid Build Coastguard Worker 	int ret;
11*49cdfc7eSAndroid Build Coastguard Worker 	int err = sigwait(set, &ret);
12*49cdfc7eSAndroid Build Coastguard Worker 
13*49cdfc7eSAndroid Build Coastguard Worker 	if (err == 0)
14*49cdfc7eSAndroid Build Coastguard Worker 		return ret;
15*49cdfc7eSAndroid Build Coastguard Worker 	errno = err;
16*49cdfc7eSAndroid Build Coastguard Worker 	return -1;
17*49cdfc7eSAndroid Build Coastguard Worker }
18*49cdfc7eSAndroid Build Coastguard Worker 
19*49cdfc7eSAndroid Build Coastguard Worker struct sigwait_test_desc tests[] = {
20*49cdfc7eSAndroid Build Coastguard Worker 	{ test_unmasked_matching_noinfo, SIGUSR1},
21*49cdfc7eSAndroid Build Coastguard Worker 	{ test_masked_matching_noinfo, SIGUSR1},
22*49cdfc7eSAndroid Build Coastguard Worker };
23*49cdfc7eSAndroid Build Coastguard Worker 
run(unsigned int i)24*49cdfc7eSAndroid Build Coastguard Worker static void run(unsigned int i)
25*49cdfc7eSAndroid Build Coastguard Worker {
26*49cdfc7eSAndroid Build Coastguard Worker 	struct sigwait_test_desc *tc = &tests[i];
27*49cdfc7eSAndroid Build Coastguard Worker 
28*49cdfc7eSAndroid Build Coastguard Worker 	tc->tf(my_sigwait, tc->signo, TST_LIBC_TIMESPEC);
29*49cdfc7eSAndroid Build Coastguard Worker }
30*49cdfc7eSAndroid Build Coastguard Worker 
31*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
32*49cdfc7eSAndroid Build Coastguard Worker 	.test= run,
33*49cdfc7eSAndroid Build Coastguard Worker 	.tcnt = ARRAY_SIZE(tests),
34*49cdfc7eSAndroid Build Coastguard Worker 	.setup = sigwait_setup,
35*49cdfc7eSAndroid Build Coastguard Worker 	.forks_child = 1,
36*49cdfc7eSAndroid Build Coastguard Worker };
37