syscalls: Rearrange sigwait syscall tests
v2 cover syscalls: Rearrange sigwait syscall tests
Hi,
As suggested by you I have tried to rearrange stuff here and I was able to fix the linking issues reported earlier by doing following:
-LDLIBS += -lltpsigwait
+LDLIBS := -lltpsigwait $(LDLIBS)
And so here is the proper series now, all working fine.
This is rebased over the earlier series which is under review (specifically the following patch,
[PATCH V7 10/19] syscalls/rt_sigtimedwait: Add support for time64 tests).
V2:
- Fixed build issues with proper ordering of libraries.
--
Viresh
Viresh Kumar (3):
syscalls: sigwaitinfo: Suppress all warnings around unused parameter
syscalls: sigwaitinfo: Remove SUCCEED_OR_DIE() macro
syscalls: sigwait: Separate out code to relevant folders
include/libsigwait.h | 45 ++ libs/libltpsigwait/Makefile | 11 + libs/libltpsigwait/sigwait.c | 428 +++++++++++++++++ testcases/kernel/syscalls/rt_sigtimedwait/Makefile | 10 +- .../syscalls/rt_sigtimedwait/rt_sigtimedwait01.c | 78 ++++ testcases/kernel/syscalls/sigtimedwait/Makefile | 9 +- .../kernel/syscalls/sigtimedwait/sigtimedwait01.c | 37 ++ testcases/kernel/syscalls/sigwait/Makefile | 9 +- testcases/kernel/syscalls/sigwait/sigwait01.c | 37 ++ testcases/kernel/syscalls/sigwaitinfo/Makefile | 4 +- .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 511 +-------------------- 11 files changed, 662 insertions(+), 517 deletions(-) create mode 100644 include/libsigwait.h create mode 100644 libs/libltpsigwait/Makefile create mode 100644 libs/libltpsigwait/sigwait.c create mode 100644 testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c create mode 100644 testcases/kernel/syscalls/sigtimedwait/sigtimedwait01.c create mode 100644 testcases/kernel/syscalls/sigwait/sigwait01.c
Signature · 1 line
2.14.1
PATCH v2 1/3 syscalls: sigwaitinfo: Suppress all warnings around unused parameter
Suppress the warnings using LTP_ATTRIBUTE_UNUSED.
--- .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-)
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +15 -11
@@ -50,7 +50,7 @@ static void report_success_cond(const char *func, int line,#define REPORT_SUCCESS (exp_return, exp_errno) \ REPORT_SUCCESS_COND(exp_return, exp_errno, 1, ""); -static void empty_handler (int sig) +static void empty_handler(int sig LTP_ATTRIBUTE_UNUSED) { }
@@ -74,7 +74,7 @@ static int my_sigwait(const sigset_t * set, siginfo_t * info,#ifdef TEST_SIGWAITINFO static int my_sigwaitinfo (const sigset_t * set,siginfo_t * info, -void *timeout) + void *timeout LTP_ATTRIBUTE_UNUSED) {return sigwaitinfo (set, info); }
@@ -106,7 +106,8 @@ static int my_rt_sigtimedwait_time64(const sigset_t * set, siginfo_t * info,#endif #endif -void test_empty_set (swi_func sigwaitinfo,int signo,enum tst_ts_type type) +void test_empty_set (swi_func sigwaitinfo,int signo, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {sigset_t sigs;siginfo_t si;
@@ -150,7 +151,7 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type)* by POSIX; but works for non-ignored signals under Linux */ void test_unmasked_matching (swi_func sigwaitinfo,int signo, -enum tst_ts_type type) + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {sigset_t sigs;siginfo_t si;
@@ -172,7 +173,7 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo, }void test_unmasked_matching_noinfo (swi_func sigwaitinfo,int signo, -enum tst_ts_type type) + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {sigset_t sigs;pid_t child;
@@ -190,7 +191,7 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo, }void test_masked_matching (swi_func sigwaitinfo,int signo, -enum tst_ts_type type) + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {sigset_t sigs, oldmask;siginfo_t si;
@@ -229,7 +230,7 @@ void test_masked_matching(swi_func sigwaitinfo, int signo, }void test_masked_matching_rt (swi_func sigwaitinfo,int signo, -enum tst_ts_type type) + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {sigset_t sigs, oldmask;siginfo_t si;
@@ -281,7 +282,7 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo, }void test_masked_matching_noinfo (swi_func sigwaitinfo,int signo, -enum tst_ts_type type) + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {sigset_t sigs, oldmask;pid_t child;
@@ -316,7 +317,8 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,SAFE_WAIT (NULL ); } -void test_bad_address (swi_func sigwaitinfo,int signo,enum tst_ts_type type) +void test_bad_address (swi_func sigwaitinfo,int signo, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {sigset_t sigs, oldmask;pid_t child;
@@ -345,7 +347,8 @@ void test_bad_address(swi_func sigwaitinfo, int signo, enum tst_ts_type type)SAFE_WAIT (NULL ); } -void test_bad_address2 (swi_func sigwaitinfo,int signo,enum tst_ts_type type) +void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {pid_t pid;int status;
@@ -391,7 +394,8 @@ void test_bad_address2(swi_func sigwaitinfo, int signo, enum tst_ts_type type) } } -void test_bad_address3 (swi_func sigwaitinfo,int signo,enum tst_ts_type type) +void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {sigset_t sigs;SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs);
Signature · 1 line
2.14.1
PATCH v2 2/3 syscalls: sigwaitinfo: Remove SUCCEED_OR_DIE() macro
In reply to Viresh KumarThe macro makes it less readable and there isn't a great deal of code it is trying to remove. Get rid of it.
--- .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 156 ++++++++++++++------- 1 file changed, 109 insertions(+), 47 deletions(-)
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +109 -47
@@ -10,13 +10,6 @@#include "lapi/syscalls.h" #include "tst_sig_proc.h" -#define SUCCEED_OR_DIE (syscall, message, ...) \ - (errno = 0, \ - ({int ret=syscall(__VA_ARGS__); \ - if (ret==-1) \ - tst_brk(TBROK|TERRNO, message);\ - ret;})) -/* Report success iff TST_RET and TST_ERR are equal to exp_return and exp_errno, resp., and cond is true. If cond is not true, report condition_errmsg
@@ -113,7 +106,10 @@ void test_empty_set(swi_func sigwaitinfo, int signo,siginfo_t si;pid_t child; -SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs); +TEST (sigemptyset (&sigs)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigemptyset() failed" ); +/* Run a child that will wake us up */ child =create_sig_proc (signo,INT_MAX ,100000 );
@@ -135,7 +131,9 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type)tst_ts_set_sec (&ts,1 );tst_ts_set_nsec (&ts,0 ); -SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs); +TEST (sigemptyset (&sigs)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigemptyset() failed" );/* Run a child that will wake us up */ child =create_sig_proc (signo,INT_MAX ,100000 );
@@ -157,8 +155,13 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo,siginfo_t si;pid_t child; -SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs); -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs, signo); +TEST (sigemptyset (&sigs)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigemptyset() failed" ); + +TEST (sigaddset (&sigs, signo)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" );/* Run a child that will wake us up */ child =create_sig_proc (signo,INT_MAX ,100000 );
@@ -178,8 +181,14 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo,sigset_t sigs;pid_t child; -SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs); -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs, signo); +TEST (sigemptyset (&sigs)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigemptyset() failed" ); + +TEST (sigaddset (&sigs, signo)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); +/* Run a child that will wake us up */ child =create_sig_proc (signo,INT_MAX ,100000 );
@@ -197,16 +206,27 @@ void test_masked_matching(swi_func sigwaitinfo, int signo,siginfo_t si;pid_t child; -SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs); -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs, signo); +TEST (sigemptyset (&sigs)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigemptyset() failed" ); + +TEST (sigaddset (&sigs, signo)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); +/* let's not get interrupted by our dying child */ -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs,SIGCHLD ); +TEST (sigaddset (&sigs,SIGCHLD )); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); -SUCCEED_OR_DIE (sigprocmask,"sigprocmask failed" ,SIG_SETMASK , &sigs, - &oldmask); +TEST (sigprocmask (SIG_SETMASK , &sigs, &oldmask)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigprocmask() failed" );/* don't wait on a SIGCHLD */ -SUCCEED_OR_DIE (sigdelset,"sigaddset failed" , &sigs,SIGCHLD ); +TEST (sigdelset (&sigs,SIGCHLD )); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigdelset() failed" );/* Run a child that will wake us up */ child =create_sig_proc (signo,1 ,0 );
@@ -216,8 +236,9 @@ void test_masked_matching(swi_func sigwaitinfo, int signo, && si.si_code ==SI_USER && si.si_signo == signo, "Struct siginfo mismatch"); -SUCCEED_OR_DIE (sigprocmask,"restoring original signal mask failed" , -SIG_SETMASK , &oldmask, &oldmask); +TEST (sigprocmask (SIG_SETMASK , &oldmask, &oldmask)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"restoring original signal mask failed" );if (sigismember (&oldmask, signo))tst_res (TPASS ,"sigwaitinfo restored the original mask" );
@@ -239,17 +260,31 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo, signo =SIGRTMIN +1 ; -SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs); -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs, signo); -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs, signo +1 ); +TEST (sigemptyset (&sigs)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigemptyset() failed" ); + +TEST (sigaddset (&sigs, signo)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); + +TEST (sigaddset (&sigs, signo +1 )); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); +/* let's not get interrupted by our dying child */ -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs,SIGCHLD ); +TEST (sigaddset (&sigs,SIGCHLD )); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); -SUCCEED_OR_DIE (sigprocmask,"sigprocmask failed" ,SIG_SETMASK , &sigs, - &oldmask); +TEST (sigprocmask (SIG_SETMASK , &sigs, &oldmask)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigprocmask() failed" );/* don't wait on a SIGCHLD */ -SUCCEED_OR_DIE (sigdelset,"sigdelset failed" , &sigs,SIGCHLD ); +TEST (sigdelset (&sigs,SIGCHLD )); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigdelset() failed" );/* Run a child that will wake us up */ child[0 ] =create_sig_proc (signo,1 ,0 );
@@ -271,8 +306,9 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo, && si.si_signo == signo +1 , "Struct siginfo mismatch"); -SUCCEED_OR_DIE (sigprocmask,"restoring original signal mask failed" , -SIG_SETMASK , &oldmask, &oldmask); +TEST (sigprocmask (SIG_SETMASK , &oldmask, &oldmask)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"restoring original signal mask failed" );if (sigismember (&oldmask, signo))tst_res (TPASS ,"sigwaitinfo restored the original mask" );
@@ -287,16 +323,27 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,sigset_t sigs, oldmask;pid_t child; -SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs); -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs, signo); +TEST (sigemptyset (&sigs)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigemptyset() failed" ); + +TEST (sigaddset (&sigs, signo)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); +/* let's not get interrupted by our dying child */ -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs,SIGCHLD ); +TEST (sigaddset (&sigs,SIGCHLD )); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); -SUCCEED_OR_DIE (sigprocmask,"sigprocmask failed" ,SIG_SETMASK , &sigs, - &oldmask); +TEST (sigprocmask (SIG_SETMASK , &sigs, &oldmask)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigprocmask() failed" );/* don't wait on a SIGCHLD */ -SUCCEED_OR_DIE (sigdelset,"sigaddset failed" , &sigs,SIGCHLD ); +TEST (sigdelset (&sigs,SIGCHLD )); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigdelset() failed" );/* Run a child that will wake us up */ child =create_sig_proc (signo,1 ,0 );
@@ -304,8 +351,9 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,TEST (sigwaitinfo (&sigs,NULL ,NULL ));REPORT_SUCCESS (signo,0 ); -SUCCEED_OR_DIE (sigprocmask,"restoring original signal mask failed" , -SIG_SETMASK , &oldmask, &oldmask); +TEST (sigprocmask (SIG_SETMASK , &oldmask, &oldmask)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"restoring original signal mask failed" );if (sigismember (&oldmask, signo))tst_res (TPASS ,"sigwaitinfo restored the original mask" );
@@ -323,16 +371,27 @@ void test_bad_address(swi_func sigwaitinfo, int signo,sigset_t sigs, oldmask;pid_t child; -SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs); -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs, signo); +TEST (sigemptyset (&sigs)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigemptyset() failed" ); + +TEST (sigaddset (&sigs, signo)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); +/* let's not get interrupted by our dying child */ -SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs,SIGCHLD ); +TEST (sigaddset (&sigs,SIGCHLD )); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigaddset() failed" ); -SUCCEED_OR_DIE (sigprocmask,"sigprocmask failed" ,SIG_SETMASK , &sigs, - &oldmask); +TEST (sigprocmask (SIG_SETMASK , &sigs, &oldmask)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigprocmask() failed" );/* don't wait on a SIGCHLD */ -SUCCEED_OR_DIE (sigdelset,"sigaddset failed" , &sigs,SIGCHLD ); +TEST (sigdelset (&sigs,SIGCHLD )); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigdelset() failed" );/* Run a child that will wake us up */ child =create_sig_proc (signo,1 ,0 );
@@ -340,8 +399,9 @@ void test_bad_address(swi_func sigwaitinfo, int signo,TEST (sigwaitinfo (&sigs, (void *)1 ,NULL ));REPORT_SUCCESS (-1 ,EFAULT ); -SUCCEED_OR_DIE (sigprocmask,"sigprocmask failed" ,SIG_SETMASK , &oldmask, - &oldmask); +TEST (sigprocmask (SIG_SETMASK , &oldmask, &oldmask)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigprocmask() failed" );SAFE_KILL (child,SIGTERM );SAFE_WAIT (NULL );
@@ -398,7 +458,9 @@ void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, enum tst_ts_type type LTP_ATTRIBUTE_UNUSED) {sigset_t sigs; -SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs); +TEST (sigemptyset (&sigs)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"sigemptyset() failed" );TEST (sigwaitinfo (&sigs,NULL , (void *)1 ));REPORT_SUCCESS (-1 ,EFAULT );
Signature · 1 line
2.14.1
PATCH v2 2/3 syscalls: sigwaitinfo: Remove SUCCEED_OR_DIE() macro
Hi!
Quoted 2 lines
The macro makes it less readable and there isn't a great deal of code it is trying to remove. Get rid of it.
Looking at the code we may as well add SAFE_SIGEMPTYSET() and SAFE_SIGADDSET() instead, what do you think?
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 2/3 syscalls: sigwaitinfo: Remove SUCCEED_OR_DIE() macro
Hi!
Quoted 5 lines
Quoted 2 lines
The macro makes it less readable and there isn't a great deal of code it is trying to remove. Get rid of it.
Looking at the code we may as well add
SAFE_SIGEMPTYSET()andSAFE_SIGADDSET()instead, what do you think?
Looking at the patch that separates the files, it may be easier to apply that and do this on the top of that...
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 3/3 syscalls: sigwait: Separate out code to relevant folders
In reply to Viresh KumarThe way it is implemented currently is very confusing, all the source code is present in one file which is referenced from 4 directories to test different syscalls. The relevant source gets build magically based on some flag passed in Makefile.
Move the common part to a new library and the relevant part to their syscall folders.
--- include/libsigwait.h | 45 ++ libs/libltpsigwait/Makefile | 11 + libs/libltpsigwait/sigwait.c | 428 +++++++++++++++ testcases/kernel/syscalls/rt_sigtimedwait/Makefile | 10 +- .../syscalls/rt_sigtimedwait/rt_sigtimedwait01.c | 78 +++ testcases/kernel/syscalls/sigtimedwait/Makefile | 9 +- .../kernel/syscalls/sigtimedwait/sigtimedwait01.c | 37 ++ testcases/kernel/syscalls/sigwait/Makefile | 9 +- testcases/kernel/syscalls/sigwait/sigwait01.c | 37 ++ testcases/kernel/syscalls/sigwaitinfo/Makefile | 4 +- .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 575 +-------------------- 11 files changed, 661 insertions(+), 582 deletions(-) create mode 100644 include/libsigwait.h create mode 100644 libs/libltpsigwait/Makefile create mode 100644 libs/libltpsigwait/sigwait.c create mode 100644 testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c create mode 100644 testcases/kernel/syscalls/sigtimedwait/sigtimedwait01.c create mode 100644 testcases/kernel/syscalls/sigwait/sigwait01.c
include/libsigwait.h new file +45 -0
@@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Linaro Limited. All rights reserved. +* Author: Viresh Kumar <[email protected]> +*/ + +#ifndef SIGWAIT_H__ +#define SIGWAIT_H__ + +#include "tst_test.h" +#include "tst_timer.h" +#include <signal.h> + +/* swi: sigwaitinfo() */ +typedef int (*swi_func ) (const sigset_t * set,siginfo_t * info, +void * timeout); +typedef void (*test_func ) (swi_func ,int ,enum tst_ts_type type); + +struct sigwait_test_desc { +test_func tf; +int signo; +}; + +void test_empty_set (swi_func sigwaitinfo,int signo, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); +void test_timeout (swi_func sigwaitinfo,int signo,enum tst_ts_type type); +void test_unmasked_matching (swi_func sigwaitinfo,int signo, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); +void test_unmasked_matching_noinfo (swi_func sigwaitinfo,int signo, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); +void test_masked_matching (swi_func sigwaitinfo,int signo, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); +void test_masked_matching_rt (swi_func sigwaitinfo,int signo, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); +void test_masked_matching_noinfo (swi_func sigwaitinfo,int signo, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); +void test_bad_address (swi_func sigwaitinfo,int signo, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); +void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); +void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED, + enum tst_ts_type type LTP_ATTRIBUTE_UNUSED); +void sigwait_setup (void ); +void sigwait_cleanup (void ); +#endif /* SIGWAIT_H__ */
libs/libltpsigwait/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2020 Viresh Kumar <[email protected]> + +top_srcdir ?= ../.. + +include $(top_srcdir)/include/mk/env_pre.mk + +INTERNAL_LIB := libltpsigwait.a + +include $(top_srcdir)/include/mk/lib.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
libs/libltpsigwait/sigwait.c new file +428 -0
428 lines not on this page · raw message
testcases/kernel/syscalls/rt_sigtimedwait/Makefile +3 -7
@@ -3,14 +3,10 @@ top_srcdir ?= ../../../.. -include $(top_srcdir)/include/mk/testcases.mk - -CPPFLAGS += -DTEST_RT_SIGTIMEDWAIT +LTPLIBS = ltpsigwait -rt_sigtimedwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c - $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION) +include $(top_srcdir)/include/mk/testcases.mk -MAKE_TARGETS := rt_sigtimedwait01 +LDLIBS := -lltpsigwait $(LDLIBS) include $(top_srcdir)/include/mk/generic_leaf_target.mk -
testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c new file +78 -0
78 lines not on this page · raw message
testcases/kernel/syscalls/sigtimedwait/Makefile +3 -6
@@ -3,13 +3,10 @@ top_srcdir ?= ../../../.. -include $(top_srcdir)/include/mk/testcases.mk - -CPPFLAGS += -DTEST_SIGTIMEDWAIT +LTPLIBS = ltpsigwait -sigtimedwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c - $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION) +include $(top_srcdir)/include/mk/testcases.mk -MAKE_TARGETS := sigtimedwait01 +LDLIBS := -lltpsigwait $(LDLIBS) include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/sigtimedwait/sigtimedwait01.c new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Copyright (c) Jiri Palecek<[email protected]>, 2009 */ + +#include "libsigwait.h" + +static int my_sigtimedwait (const sigset_t * set,siginfo_t * info, +void *timeout) +{ +return sigtimedwait (set, info, timeout); +} + +struct sigwait_test_desc tests[] = { + { test_empty_set,SIGUSR1 }, + { test_unmasked_matching,SIGUSR1 }, + { test_masked_matching,SIGUSR1 }, + { test_unmasked_matching_noinfo,SIGUSR1 }, + { test_masked_matching_noinfo,SIGUSR1 }, + { test_bad_address,SIGUSR1 }, + { test_bad_address2,SIGUSR1 }, + { test_bad_address3,SIGUSR1 }, + { test_timeout,0 }, +}; + +static void run (unsigned int i) +{ +struct sigwait_test_desc *tc = &tests[i]; + + tc->tf (my_sigtimedwait, tc->signo,TST_LIBC_TIMESPEC ); +} + +static struct tst_test test = { + .test= run, + .tcnt =ARRAY_SIZE (tests), + .setup = sigwait_setup, + .cleanup = sigwait_cleanup, + .forks_child =1 , +};
testcases/kernel/syscalls/sigwait/Makefile +3 -6
@@ -3,13 +3,10 @@ top_srcdir ?= ../../../.. -include $(top_srcdir)/include/mk/testcases.mk - -CPPFLAGS += -DTEST_SIGWAIT +LTPLIBS = ltpsigwait -sigwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c - $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION) +include $(top_srcdir)/include/mk/testcases.mk -MAKE_TARGETS := sigwait01 +LDLIBS := -lltpsigwait $(LDLIBS) include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/sigwait/sigwait01.c new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Copyright (c) Jiri Palecek<[email protected]>, 2009 */ + +#include "libsigwait.h" + +static int my_sigwait (const sigset_t * set, + siginfo_t * info LTP_ATTRIBUTE_UNUSED, + void *timeout LTP_ATTRIBUTE_UNUSED) +{ +int ret; +int err =sigwait (set, &ret); + +if (err ==0 ) +return ret; + errno = err; +return -1 ; +} + +struct sigwait_test_desc tests[] = { + { test_unmasked_matching_noinfo,SIGUSR1 }, + { test_masked_matching_noinfo,SIGUSR1 }, +}; + +static void run (unsigned int i) +{ +struct sigwait_test_desc *tc = &tests[i]; + + tc->tf (my_sigwait, tc->signo,TST_LIBC_TIMESPEC ); +} + +static struct tst_test test = { + .test= run, + .tcnt =ARRAY_SIZE (tests), + .setup = sigwait_setup, + .cleanup = sigwait_cleanup, + .forks_child =1 , +};
testcases/kernel/syscalls/sigwaitinfo/Makefile +3 -1
@@ -3,8 +3,10 @@ top_srcdir ?= ../../../.. +LTPLIBS = ltpsigwait + include $(top_srcdir)/include/mk/testcases.mk -CPPFLAGS += -DTEST_SIGWAITINFO +LDLIBS := -lltpsigwait $(LDLIBS) include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +13 -562
597 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v2 3/3 syscalls: sigwait: Separate out code to relevant folders
Hi!
Applied, thanks.
The library still could use some improvements, but the code is much better after this patchset.
A few things for followup:
* Add the SAFE_SIG* macros and use them
* Remove the useless alarm() in test setup and cleanup as the new library maintains timeouts already
* Get rid of the ugly REPORT_SUCCESS() functions
Signature · 2 lines
Cyril Hrubis [email protected]