syscalls/futex: Merge futex_wait_bitset tests
PATCH 1/8 syscalls/futex: Merge futex_wait_bitset tests
We can handle them easily in a single test, lets do it.
--- runtest/syscalls | 1 - testcases/kernel/syscalls/futex/.gitignore | 1 - testcases/kernel/syscalls/futex/Makefile | 1 - .../kernel/syscalls/futex/futex_wait_bitset.h | 75 ------------------- .../syscalls/futex/futex_wait_bitset01.c | 73 +++++++++++++++++- .../syscalls/futex/futex_wait_bitset02.c | 18 ----- 6 files changed, 71 insertions(+), 98 deletions(-) delete mode 100644 testcases/kernel/syscalls/futex/futex_wait_bitset.h delete mode 100644 testcases/kernel/syscalls/futex/futex_wait_bitset02.c
runtest/syscalls +0 -1
@@ -1663,7 +1663,6 @@ futex_wake02 futex_wake02 futex_wake03 futex_wake03 futex_wake04 futex_wake04 futex_wait_bitset01 futex_wait_bitset01 -futex_wait_bitset02 futex_wait_bitset02 memfd_create01 memfd_create01 memfd_create02 memfd_create02
testcases/kernel/syscalls/futex/.gitignore +0 -1
@@ -6,7 +6,6 @@ /futex_wait04 /futex_wait05 /futex_wait_bitset01 -/futex_wait_bitset02 /futex_wake01 /futex_wake02 /futex_wake03
testcases/kernel/syscalls/futex/Makefile +0 -1
@@ -12,7 +12,6 @@ futex_wake02: CFLAGS+=-pthread futex_wake04: CFLAGS+=-pthread futex_wait05: LDLIBS+=-lrt futex_wait_bitset01: LDLIBS+=-lrt -futex_wait_bitset02: LDLIBS+=-lrt include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/futex/futex_wait_bitset.h deleted +0 -75
75 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wait_bitset01.c +71 -2
78 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wait_bitset02.c deleted +0 -18
@@ -1,18 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* Copyright (C) 2015 Cyril Hrubis <[email protected]> -* -* 1. Block on a bitset futex and wait for timeout, the difference between -* normal futex and bitset futex is that that the later have absolute timeout. -* 2. Check that the futex waited for expected time. -*/ - -#include <errno.h> - -#include "tst_test.h" -#include "tst_timer.h" -#include "futextest.h" - -#define USE_CLOCK CLOCK_REALTIME - -#include "futex_wait_bitset.h"
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH 2/8 syscalls/futex: Add support for time64 tests
This adds support for time64 tests to the existing futex() syscall tests.
--- include/tst_timer.h | 12 ++ .../syscalls/futex/futex_cmp_requeue01.c | 35 ++++- .../syscalls/futex/futex_cmp_requeue02.c | 25 +++- testcases/kernel/syscalls/futex/futex_utils.h | 52 +++++-- .../kernel/syscalls/futex/futex_wait01.c | 60 +++++--- .../kernel/syscalls/futex/futex_wait02.c | 83 +++++------ .../kernel/syscalls/futex/futex_wait03.c | 70 ++++++---- .../kernel/syscalls/futex/futex_wait04.c | 64 ++++++--- .../kernel/syscalls/futex/futex_wait05.c | 2 +- .../syscalls/futex/futex_wait_bitset01.c | 50 +++++-- .../kernel/syscalls/futex/futex_wake01.c | 52 ++++--- .../kernel/syscalls/futex/futex_wake02.c | 80 ++++++----- .../kernel/syscalls/futex/futex_wake03.c | 92 ++++++------ .../kernel/syscalls/futex/futex_wake04.c | 132 ++++++++++-------- testcases/kernel/syscalls/futex/futextest.h | 111 +++++++++------ 15 files changed, 588 insertions(+), 332 deletions(-)
include/tst_timer.h +12 -0
@@ -243,6 +243,18 @@ static inline int sys_clock_nanosleep64(clockid_t clk_id, int flags, request, remain); } +static inline int sys_futex (int *uaddr,int futex_op,int val,void *to, +int *uaddr2,int val3) +{ +return tst_syscall (__NR_futex, uaddr, futex_op, val, to, uaddr2, val3); +} + +static inline int sys_futex_time64 (int *uaddr,int futex_op,int val,void *to, +int *uaddr2,int val3) +{ +return tst_syscall (__NR_futex_time64, uaddr, futex_op, val, to, uaddr2, val3); +} +static inline int libc_sched_rr_get_interval (pid_t pid,void *ts) {return sched_rr_get_interval (pid, ts);
testcases/kernel/syscalls/futex/futex_cmp_requeue01.c +29 -6
@@ -18,6 +18,7 @@#include "tst_timer_test.h" #include "tst_test.h" #include "futextest.h" +#include "lapi/abisize.h" struct shared_data {futex_t futexes[2 ];
@@ -42,14 +43,33 @@ static struct tcase { {1000, 300, 500}, }; +static struct test_variants { +enum futex_fn_type fntype; +enum tst_ts_type tstype; +char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype =FUTEX_FN_FUTEX , .tstype =TST_KERN_OLD_TIMESPEC , .desc ="syscall with kernel spec32" }, +#endif + +#if defined(TST_ABI64) + { .fntype =FUTEX_FN_FUTEX , .tstype =TST_KERN_TIMESPEC , .desc ="syscall with kernel spec64" }, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype =FUTEX_FN_FUTEX64 , .tstype =TST_KERN_TIMESPEC , .desc ="syscall time64 with kernel spec64" }, +#endif +}; +static void do_child (void ) { +struct test_variants *tv = &variants[tst_variant]; +struct tst_ts usec =tst_ts_from_ms (tv->tstype, max_sleep_ms);int slept_for_ms =0 ; -struct timespec usec =tst_timespec_from_ms (max_sleep_ms);int pid =getpid ();int ret =0 ; -if (futex_wait (&sd->futexes[0 ], sd->futexes[0 ], &usec,0 ) ==-1 ) { +if (futex_wait (tv->fntype, &sd->futexes[0 ], sd->futexes[0 ], &usec,0 ) ==-1 ) {if (errno ==EAGAIN ) {/* spurious wakeup or signal */ tst_atomic_inc (&sd->spurious);
@@ -72,6 +92,7 @@ static void do_child(void)static void verify_futex_cmp_requeue (unsigned int n) { +struct test_variants *tv = &variants[tst_variant];int num_requeues =0 , num_waits =0 , num_total =0 ;int i, status, spurious, woken_up;struct tcase *tc = &tcases[n];
@@ -104,8 +125,8 @@ static void verify_futex_cmp_requeue(unsigned int n)* specifies an upper limit on the number of waiters that are requeued. * Returns the total number of waiters that were woken up or requeued. */ -TEST (futex_cmp_requeue (&sd->futexes[0 ], sd->futexes[0 ], &sd->futexes[1 ], - tc->set_wakes, tc->set_requeues,0 )); +TEST (futex_cmp_requeue (tv->fntype, &sd->futexes[0 ], sd->futexes[0 ], + &sd->futexes[1 ], tc->set_wakes, tc->set_requeues,0 ));/* Fail if more than requested wakes + requeues were returned */ if (TST_RET > exp_ret) {
@@ -115,8 +136,8 @@ static void verify_futex_cmp_requeue(unsigned int n)tst_res (TINFO ,"futex_cmp_requeue() returned %ld" ,TST_RET ); } - num_requeues =futex_wake (&sd->futexes[1 ], tc->num_waiters,0 ); - num_waits =futex_wake (&sd->futexes[0 ], tc->num_waiters,0 ); + num_requeues =futex_wake (tv->fntype, &sd->futexes[1 ], tc->num_waiters,0 ); + num_waits =futex_wake (tv->fntype, &sd->futexes[0 ], tc->num_waiters,0 );tst_atomic_store (1 , &sd->test_done);for (i =0 ; i < tc->num_waiters; i++) {
@@ -178,6 +199,7 @@ static void verify_futex_cmp_requeue(unsigned int n)static void setup (void ) { +tst_res (TINFO ,"Testing variant: %s" , variants[tst_variant].desc); max_sleep_ms =tst_multiply_timeout (5000 ); sd = SAFE_MMAP(NULL, sizeof(*sd), PROT_READ | PROT_WRITE,
@@ -198,5 +220,6 @@ static struct tst_test test = { .cleanup = cleanup, .tcnt = ARRAY_SIZE(tcases), .test = verify_futex_cmp_requeue, + .test_variants = ARRAY_SIZE(variants), .forks_child = 1, };
testcases/kernel/syscalls/futex/futex_cmp_requeue02.c +23 -2
@@ -18,6 +18,7 @@#include "tst_test.h" #include "futextest.h" +#include "lapi/abisize.h" static futex_t *futexes;
@@ -32,12 +33,30 @@ static struct tcase { {1, 1, FUTEX_INITIALIZER + 1, EAGAIN}, }; +static struct test_variants { +enum futex_fn_type fntype; +char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype =FUTEX_FN_FUTEX , .desc ="syscall with kernel spec32" }, +#endif + +#if defined(TST_ABI64) + { .fntype =FUTEX_FN_FUTEX , .desc ="syscall with kernel spec64" }, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype =FUTEX_FN_FUTEX64 , .desc ="syscall time64 with kernel spec64" }, +#endif +}; +static void verify_futex_cmp_requeue (unsigned int n) { +struct test_variants *tv = &variants[tst_variant];struct tcase *tc = &tcases[n]; -TEST (futex_cmp_requeue (&futexes[0 ], tc->exp_val, &futexes[1 ], - tc->set_wakes, tc->set_requeues,0 )); +TEST (futex_cmp_requeue (tv->fntype, &futexes[0 ], tc->exp_val, + &futexes[1 ], tc->set_wakes, tc->set_requeues,0 ));if (TST_RET !=-1 ) {tst_res (TFAIL ,"futex_cmp_requeue() succeeded unexpectedly" );return ;
@@ -55,6 +74,7 @@ static void verify_futex_cmp_requeue(unsigned int n)static void setup (void ) { +tst_res (TINFO ,"Testing variant: %s" , variants[tst_variant].desc); futexes =SAFE_MMAP (NULL ,sizeof (futex_t) *2 ,PROT_READ |PROT_WRITE ,MAP_ANONYMOUS |MAP_SHARED ,-1 ,0 );
@@ -73,6 +93,7 @@ static struct tst_test test = { .cleanup = cleanup, .test = verify_futex_cmp_requeue, .tcnt = ARRAY_SIZE(tcases), + .test_variants = ARRAY_SIZE(variants), .tags = (const struct tst_tag []) { {"CVE" ,"2018-6927" }, {"linux-git" ,"fbe0e839d1e2" },
testcases/kernel/syscalls/futex/futex_utils.h +42 -10
86 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wait01.c +39 -21
94 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wait02.c +44 -39
124 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wait03.c +43 -27
106 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wait04.c +41 -23
81 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wait05.c +1 -1
@@ -19,7 +19,7 @@ int sample_fn(int clk_id, long long usec)futex_t futex =FUTEX_INITIALIZER ;tst_timer_start (clk_id); -TEST (futex_wait (&futex, futex, &to,0 )); +TEST (syscall (SYS_futex, &futex,FUTEX_WAIT , futex, &to,NULL ,0 ));tst_timer_stop ();tst_timer_sample ();
testcases/kernel/syscalls/futex/futex_wait_bitset01.c +40 -10
97 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wake01.c +32 -20
74 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wake02.c +47 -33
154 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wake03.c +52 -40
148 lines not on this page · raw message
testcases/kernel/syscalls/futex/futex_wake04.c +74 -58
232 lines not on this page · raw message
testcases/kernel/syscalls/futex/futextest.h +69 -42
214 lines not on this page · raw message
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH 2/8 syscalls/futex: Add support for time64 tests
Hi,
FYI, 2nd and 6th patch didn't apply cleanly.
Trivial fixes, but for anybody who is lazy to repeat the work here it's done:
https://github.com/pevik/ltp/tree/Viresh_Kumar/futex_wait_bitset.v1
Kind regards,
Petr
PATCH 2/8 syscalls/futex: Add support for time64 tests
Quoted 5 lines · Petr Vorel
Hi,
FYI, 2nd and 6th patch didn't apply cleanly.
Trivial fixes, but for anybody who is lazy to repeat the work here it's done:
https://github.com/pevik/ltp/tree/Viresh_Kumar/futex_wait_bitset.v1
I was wondering on why it won't rebase properly, unless I tried to do it again the way you have it. I forgot to mention that these patches were based on the earlier patches I sent and so there was some dependency in tst_timer.h. If you apply following series first, you won't get these rebase issues.
[PATCH 1/4] syscalls/timer_gettime: Add support for time64 tests
Will it be easier if I resend all my patches again in a single series ? I can also add the new tests I have converted then.
Signature · 1 line
viresh
PATCH 2/8 syscalls/futex: Add support for time64 tests
Quoted 13 lines · Viresh Kumar
Quoted 5 lines · Petr Vorel
Hi,
FYI, 2nd and 6th patch didn't apply cleanly.
Trivial fixes, but for anybody who is lazy to repeat the work here it's done:
https://github.com/pevik/ltp/tree/Viresh_Kumar/futex_wait_bitset.v1I was wondering on why it won't rebase properly, unless I tried to do it again the way you have it. I forgot to mention that these patches were based on the earlier patches I sent and so there was some dependency in
tst_timer.h. If you apply following series first, you won't get these rebase issues.
Quoted 4 lines
[PATCH 1/4] syscalls/timer_gettime: Add support for time64 tests
Will it be easier if I resend all my patches again in a single series ? I can also add the new tests I have converted then.
Okay, I cleaned up the GPL licensing thing and resent everything in a single series. That should simplify everyone's life.
Signature · 1 line
viresh
PATCH 2/8 syscalls/futex: Add support for time64 tests
Hi Viresh,
Quoted 5 lines
Quoted 2 lines
Will it be easier if I resend all my patches again in a single series ? I can also add the new tests I have converted then.
Okay, I cleaned up the GPL licensing thing and resent everything in a single series. That should simplify everyone's life.
Thanks a lot!
It might not make it to this release (freeze should be from Monday and probably nobody from reviewers work on the weekend + there is a bank holiday today for some countries).
Kind regards,
Petr
PATCH 2/8 syscalls/futex: Add support for time64 tests
Quoted 3 lines · Petr Vorel
It might not make it to this release (freeze should be from Monday and probably nobody from reviewers work on the weekend + there is a bank holiday today for some countries).
That should be fine. I just wanted to post everything I had planned for LTP :)
I may not have any more significant patches after this. :)
Signature · 1 line
viresh
PATCH 2/8 syscalls/futex: Add support for time64 tests
In reply to Viresh KumarQuoted 4 lines
This adds support for time64 tests to the existing
futex()syscall tests.Signed-off-by Viresh Kumar <[email protected]>
Nice!
I'd personally drop that bogus GPL text and replace it with SPDX, but that's unimportant and can be done later.
BTW I guess it's already git freeze before release, otherwise I'd merge these two.
Kind regards,
Petr
PATCH 3/8 syscalls/io_pgetevents: Add support for time64 tests
In reply to Viresh KumarThis adds support for time64 tests to the existing io_pgetevents() syscall tests.
While at it, also pass mode to SAFE_OPEN() to avoid any errors when the tests are run for multiple variants together.
Also get rid of an extra copy of local fd variable, which is incorrect.
--- include/lapi/io_pgetevents.h | 15 +++-- .../syscalls/io_pgetevents/io_pgetevents01.c | 41 ++++++++++++- .../syscalls/io_pgetevents/io_pgetevents02.c | 59 +++++++++++++++---- 3 files changed, 97 insertions(+), 18 deletions(-)
include/lapi/io_pgetevents.h +10 -5
@@ -16,15 +16,20 @@#ifdef HAVE_LIBAIO #include <libaio.h> -#ifndef HAVE_IO_PGETEVENTS -int io_pgetevents (io_context_t ctx,long min_nr,long max_nr, -struct io_event *events,struct timespec *timeout, -sigset_t *sigmask) +static inline int sys_io_pgetevents (io_context_t ctx,long min_nr,long max_nr, +struct io_event *events,void *timeout,sigset_t *sigmask) {return tst_syscall (__NR_io_pgetevents, ctx, min_nr, max_nr, events, timeout, sigmask); } -#endif /* HAVE_IO_PGETEVENTS */ + +static inline int sys_io_pgetevents_time64 (io_context_t ctx,long min_nr,long max_nr, +struct io_event *events,void *timeout,sigset_t *sigmask) +{ +return tst_syscall (__NR_io_pgetevents_time64, ctx, min_nr, max_nr, + events, timeout, sigmask); +} +#endif /* HAVE_LIBAIO */ #endif /* IO_PGETEVENTS_H */
testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c +38 -3
81 lines not on this page · raw message
testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c +49 -10
107 lines not on this page · raw message
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH 4/8 syscalls/sigwaitinfo: Migrate to new test framework
In reply to Viresh KumarThis migrates the sigwaitinfo tests to use the new test framework.
--- .../syscalls/sigwaitinfo/sigwaitinfo01.c | 184 ++++++++---------- 1 file changed, 81 insertions(+), 103 deletions(-)
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +81 -103
@@ -20,74 +20,58 @@* with this program; if not, write the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "test.h" +#include "tst_test.h" #include <errno.h> +#include <stdlib.h> #include <signal.h> -#include "../utils/include_j_h.h" -#include "../utils/common_j_h.c" #include <limits.h> #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_brkm(TBROK|TERRNO, cleanup, message);\ + tst_brk(TBROK|TERRNO, message);\ ret;})) -/* Report success iff TEST_RETURN and TEST_ERRNO are equal to +/* 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 */ -static void report_success_cond (const char *func,const char *file,int line, +static void report_success_cond (const char *func,int line,long exp_return,int exp_errno,int condition,char *condition_errmsg) { -if (exp_return ==TEST_RETURN - && (exp_return !=-1 || exp_errno ==TEST_ERRNO )) +if (exp_return ==TST_RET + && (exp_return !=-1 || exp_errno ==TST_ERR ))if (condition) -tst_resm (TPASS ,"Test passed" ); +tst_res (TPASS ,"%s (%d): Test passed" , func, line);else -tst_resm (TFAIL ,"%s (%s: %d): %s" , func, file, line, +tst_res (TFAIL ,"%s (%d): %s" , func, line, condition_errmsg); -else if (TEST_RETURN !=-1 ) -tst_resm (TFAIL , -"%s (%s: %d): Unexpected return value; expected %ld, got %ld" , - func, file, line, exp_return,TEST_RETURN ); +else if (TST_RET !=-1 ) +tst_res (TFAIL , +"%s (%d): Unexpected return value; expected %ld, got %ld" , + func, line, exp_return,TST_RET );else -tst_resm (TFAIL |TTERRNO ,"%s (%s: %d): Unexpected failure" , - func, file, line); +tst_res (TFAIL |TTERRNO ,"%s (%d): Unexpected failure" , + func, line); }#define REPORT_SUCCESS_COND (exp_return, exp_errno, condition, condition_errmsg) \ - report_success_cond(__FUNCTION__, __FILE__, __LINE__, exp_return, exp_errno, condition, condition_errmsg); + report_success_cond(__FUNCTION__, __LINE__, exp_return, exp_errno, condition, condition_errmsg); -/* Report success iff TEST_RETURN and TEST_ERRNO are equal to +/* Report success iff TST_RET and TST_ERR are equal to exp_return and exp_errno, resp. */ #define REPORT_SUCCESS (exp_return, exp_errno) \ REPORT_SUCCESS_COND(exp_return, exp_errno, 1, ""); -static void cleanup (void ); -static void empty_handler (int sig) { } -static void setup (void ) -{ -tst_sig (FORK ,DEF_HANDLER , cleanup); -signal (SIGUSR1 , empty_handler); -signal (SIGALRM , empty_handler); -signal (SIGUSR2 ,SIG_IGN ); - -TEST_PAUSE ; -} - -static void cleanup (void ) -{ -} -typedef int (*swi_func ) (const sigset_t * set,siginfo_t * info,struct timespec * timeout);typedef void (*test_func ) (swi_func ,int );
@@ -110,7 +94,6 @@ static int my_sigwait(const sigset_t * set, siginfo_t * info,static int my_sigwaitinfo (const sigset_t * set,siginfo_t * info,struct timespec *timeout) { -return sigwaitinfo (set, info); }#endif
@@ -119,7 +102,6 @@ static int my_sigwaitinfo(const sigset_t * set, siginfo_t * info,static int my_sigtimedwait (const sigset_t * set,siginfo_t * info,struct timespec *timeout) { -return sigtimedwait (set, info, timeout); }#endif
@@ -129,7 +111,7 @@ static int my_rt_sigtimedwait(const sigset_t * set, siginfo_t * info, struct timespec *timeout) {/* _NSIG is always the right number of bits of signal map for all arches */ -return ltp_syscall (__NR_rt_sigtimedwait, set, info, timeout, _NSIG/8 ); +return tst_syscall (__NR_rt_sigtimedwait, set, info, timeout, _NSIG/8 ); }#endif
@@ -141,12 +123,13 @@ void test_empty_set(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs);/* Run a child that will wake us up */ - child =create_sig_proc (100000 , signo,UINT_MAX ); + child =create_sig_proc (signo,INT_MAX ,100000 );TEST (sigwaitinfo (&sigs, &si,NULL ));REPORT_SUCCESS (-1 ,EINTR ); -kill (child,SIGTERM ); +SAFE_KILL (child,SIGTERM ); +SAFE_WAIT (NULL ); }void test_timeout (swi_func sigwaitinfo,int signo)
@@ -159,12 +142,13 @@ void test_timeout(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs);/* Run a child that will wake us up */ - child =create_sig_proc (100000 , signo,UINT_MAX ); + child =create_sig_proc (signo,INT_MAX ,100000 );TEST (sigwaitinfo (&sigs, &si, &ts));REPORT_SUCCESS (-1 ,EAGAIN ); -kill (child,SIGTERM ); +SAFE_KILL (child,SIGTERM ); +SAFE_WAIT (NULL ); }/* Note: sigwait-ing for a signal that is not blocked is unspecified
@@ -180,14 +164,15 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs, signo);/* Run a child that will wake us up */ - child =create_sig_proc (100000 , signo,UINT_MAX ); + child =create_sig_proc (signo,INT_MAX ,100000 );TEST (sigwaitinfo (&sigs, &si,NULL ));REPORT_SUCCESS_COND (signo,0 , si.si_pid == child && si.si_code ==SI_USER && si.si_signo == signo,"Struct siginfo mismatch" ); -kill (child,SIGTERM ); +SAFE_KILL (child,SIGTERM ); +SAFE_WAIT (NULL ); }void test_unmasked_matching_noinfo (swi_func sigwaitinfo,int signo)
@@ -198,12 +183,13 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs);SUCCEED_OR_DIE (sigaddset,"sigaddset failed" , &sigs, signo);/* Run a child that will wake us up */ - child =create_sig_proc (100000 , signo,UINT_MAX ); + child =create_sig_proc (signo,INT_MAX ,100000 );TEST (sigwaitinfo (&sigs,NULL ,NULL ));REPORT_SUCCESS (signo,0 ); -kill (child,SIGTERM ); +SAFE_KILL (child,SIGTERM ); +SAFE_WAIT (NULL ); }void test_masked_matching (swi_func sigwaitinfo,int signo)
@@ -224,7 +210,7 @@ void test_masked_matching(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigdelset,"sigaddset failed" , &sigs,SIGCHLD );/* Run a child that will wake us up */ - child =create_sig_proc (0 , signo,1 ); + child =create_sig_proc (signo,1 ,0 );TEST (sigwaitinfo (&sigs, &si,NULL )); REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
@@ -234,13 +220,14 @@ void test_masked_matching(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigprocmask,"restoring original signal mask failed" ,SIG_SETMASK , &oldmask, &oldmask); - tst_count--; -if (sigismember (&oldmask, signo)) -tst_resm (TPASS ,"sigwaitinfo restored the original mask" ); +tst_res (TPASS ,"sigwaitinfo restored the original mask" );else -tst_resm (TFAIL , +tst_res (TFAIL ,"sigwaitinfo failed to restore the original mask" ); + +SAFE_KILL (child,SIGTERM ); +SAFE_WAIT (NULL ); }void test_masked_matching_rt (swi_func sigwaitinfo,int signo)
@@ -265,12 +252,12 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigdelset,"sigdelset failed" , &sigs,SIGCHLD );/* Run a child that will wake us up */ - child[0 ] =create_sig_proc (0 , signo,1 ); - child[1 ] =create_sig_proc (0 , signo +1 ,1 ); + child[0 ] =create_sig_proc (signo,1 ,0 ); + child[1 ] =create_sig_proc (signo +1 ,1 ,0 );/* Ensure that the signals have been sent */ -waitpid (child[0 ], &status,0 ); -waitpid (child[1 ], &status,0 ); +SAFE_WAITPID (child[0 ], &status,0 ); +SAFE_WAITPID (child[1 ], &status,0 );TEST (sigwaitinfo (&sigs, &si,NULL )); REPORT_SUCCESS_COND(signo, 0, si.si_pid == child[0]
@@ -278,7 +265,6 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo) && si.si_signo == signo, "Struct siginfo mismatch");/* eat the other signal */ - tst_count--;TEST (sigwaitinfo (&sigs, &si,NULL ));REPORT_SUCCESS_COND (signo +1 ,0 , si.si_pid == child[1 ] && si.si_code == SI_USER
@@ -288,12 +274,10 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigprocmask,"restoring original signal mask failed" ,SIG_SETMASK , &oldmask, &oldmask); - tst_count--; -if (sigismember (&oldmask, signo)) -tst_resm (TPASS ,"sigwaitinfo restored the original mask" ); +tst_res (TPASS ,"sigwaitinfo restored the original mask" );else -tst_resm (TFAIL , +tst_res (TFAIL ,"sigwaitinfo failed to restore the original mask" ); }
@@ -314,7 +298,7 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigdelset,"sigaddset failed" , &sigs,SIGCHLD );/* Run a child that will wake us up */ - child =create_sig_proc (0 , signo,1 ); + child =create_sig_proc (signo,1 ,0 );TEST (sigwaitinfo (&sigs,NULL ,NULL ));REPORT_SUCCESS (signo,0 );
@@ -322,14 +306,14 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigprocmask,"restoring original signal mask failed" ,SIG_SETMASK , &oldmask, &oldmask); - tst_count--; -if (sigismember (&oldmask, signo)) -tst_resm (TPASS ,"sigwaitinfo restored the original mask" ); +tst_res (TPASS ,"sigwaitinfo restored the original mask" );else -tst_resm (TFAIL , +tst_res (TFAIL ,"sigwaitinfo failed to restore the original mask" ); +SAFE_KILL (child,SIGTERM ); +SAFE_WAIT (NULL ); }void test_bad_address (swi_func sigwaitinfo,int signo)
@@ -349,7 +333,7 @@ void test_bad_address(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigdelset,"sigaddset failed" , &sigs,SIGCHLD );/* Run a child that will wake us up */ - child =create_sig_proc (0 , signo,1 ); + child =create_sig_proc (signo,1 ,0 );TEST (sigwaitinfo (&sigs, (void *)1 ,NULL ));REPORT_SUCCESS (-1 ,EFAULT );
@@ -357,7 +341,8 @@ void test_bad_address(swi_func sigwaitinfo, int signo)SUCCEED_OR_DIE (sigprocmask,"sigprocmask failed" ,SIG_SETMASK , &oldmask, &oldmask); -kill (child,SIGTERM ); +SAFE_KILL (child,SIGTERM ); +SAFE_WAIT (NULL ); }void test_bad_address2 (swi_func sigwaitinfo,int signo)
@@ -367,7 +352,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo)switch (pid =fork ()) {case -1 : -tst_brkm (TBROK |TERRNO ,NULL ,"fork() failed" ); +tst_brk (TBROK |TERRNO ,"fork() failed" );case 0 :signal (SIGSEGV ,SIG_DFL );
@@ -377,31 +362,31 @@ void test_bad_address2(swi_func sigwaitinfo, int signo)*/ TEST (sigwaitinfo ((void *)1 ,NULL ,NULL )); -if (TEST_RETURN ==-1 &&TEST_ERRNO ==EFAULT ) +if (TST_RET ==-1 &&TST_ERR ==EFAULT )_exit (0 ); -tst_resm (TINFO |TTERRNO ,"swi_func returned: %ld" , -TEST_RETURN ); +tst_res (TINFO |TTERRNO ,"swi_func returned: %ld" , +TST_RET );_exit (1 );break ;default :break ; } -SUCCEED_OR_DIE (waitpid,"waitpid failed" , pid, &status,0 ); +SAFE_WAITPID (pid, &status,0 );if ((WIFSIGNALED (status) &&WTERMSIG (status) ==SIGSEGV ) || (WIFEXITED (status) &&WEXITSTATUS (status) ==0 )) { -tst_resm (TPASS ,"Test passed" ); +tst_res (TPASS ,"Test passed" );return ; }if (WIFEXITED (status)) { -tst_resm (TFAIL ,"Unrecognised child exit code: %d" , +tst_res (TFAIL ,"Unrecognised child exit code: %d" ,WEXITSTATUS (status)); }if (WIFSIGNALED (status)) { -tst_resm (TFAIL ,"Unrecognised child termsig: %d" , +tst_res (TFAIL ,"Unrecognised child termsig: %d" ,WTERMSIG (status)); } }
@@ -474,38 +459,31 @@ struct test_desc {#endif }; -#if definedTEST_SIGWAITINFO -const char *TCID ="sigwaitinfo01" ; -#elif definedTEST_RT_SIGTIMEDWAIT -const char *TCID ="rt_sigtimedwait01" ; -#elif definedTEST_SIGTIMEDWAIT -const char *TCID ="sigtimedwait01" ; -#elif definedTEST_SIGWAIT -const char *TCID ="sigwait01" ; -#endif - -int TST_TOTAL =ARRAY_SIZE (tests); - -int main (int argc,char **argv) +static void run (unsigned int i) { -unsigned i; -int lc; +struct test_desc *tc = &tests[i]; -tst_parse_opts (argc, argv,NULL ,NULL ); - -setup (); + tc->tf (tc->swi, tc->signo); +} -for (lc =0 ;TEST_LOOPING (lc); ++lc) { - tst_count =0 ; +static void setup (void ) +{ +signal (SIGUSR1 , empty_handler); +signal (SIGALRM , empty_handler); +signal (SIGUSR2 ,SIG_IGN ); -for (i =0 ; i <ARRAY_SIZE (tests); i++) { -alarm (10 );/* arrange a 10 second timeout */ -tst_resm (TINFO ,"%p, %d" , tests[i].swi, tests[i].signo); - tests[i].tf (tests[i].swi, tests[i].signo); - } -alarm (0 ); - } +alarm (10 );/* arrange a 10 second timeout */ +} -cleanup (); -tst_exit (); +static void cleanup (void ) +{ +alarm (0 ); } + +static struct tst_test test = { + .test= run, + .tcnt =ARRAY_SIZE (tests), + .setup = setup, + .cleanup = cleanup, + .forks_child =1 , +};
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH 5/8 syscalls/rt_sigtimedwait: Add support for time64 tests
In reply to Viresh KumarThis adds support for time64 tests to the existing rt_sigtimedwait() syscall tests.
--- .../syscalls/sigwaitinfo/sigwaitinfo01.c | 118 +++++++++++++----- 1 file changed, 86 insertions(+), 32 deletions(-)
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +86 -32
@@ -21,11 +21,13 @@* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tst_test.h" +#include "tst_timer.h" #include <errno.h> #include <stdlib.h> #include <signal.h> #include <limits.h> #include "lapi/syscalls.h" +#include "lapi/abisize.h" #include "tst_sig_proc.h" #define SUCCEED_OR_DIE (syscall, message, ...) \
@@ -73,12 +75,12 @@ static void empty_handler(int sig) }typedef int (*swi_func ) (const sigset_t * set,siginfo_t * info, -struct timespec * timeout); -typedef void (*test_func ) (swi_func ,int ); +void * timeout); +typedef void (*test_func ) (swi_func ,int ,enum tst_ts_type type);#ifdef TEST_SIGWAIT static int my_sigwait (const sigset_t * set,siginfo_t * info, -struct timespec *timeout) +void *timeout) {int ret;int err =sigwait (set, &ret);
@@ -92,7 +94,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, -struct timespec *timeout) +void *timeout) {return sigwaitinfo (set, info); }
@@ -100,7 +102,7 @@ static int my_sigwaitinfo(const sigset_t * set, siginfo_t * info,#ifdef TEST_SIGTIMEDWAIT static int my_sigtimedwait (const sigset_t * set,siginfo_t * info, -struct timespec *timeout) +void *timeout) {return sigtimedwait (set, info, timeout); }
@@ -108,14 +110,23 @@ static int my_sigtimedwait(const sigset_t * set, siginfo_t * info,#ifdef TEST_RT_SIGTIMEDWAIT static int my_rt_sigtimedwait (const sigset_t * set,siginfo_t * info, -struct timespec *timeout) +void *timeout) {/* _NSIG is always the right number of bits of signal map for all arches */ return tst_syscall (__NR_rt_sigtimedwait, set, info, timeout, _NSIG/8 ); } + +#if (__NR_rt_sigtimedwait_time64 != __LTP__NR_INVALID_SYSCALL) +static int my_rt_sigtimedwait_time64 (const sigset_t * set,siginfo_t * info, +void *timeout) +{ +/* _NSIG is always the right number of bits of signal map for all arches */ +return tst_syscall (__NR_rt_sigtimedwait_time64, set, info, timeout, _NSIG/8 ); +} +#endif #endif -void test_empty_set (swi_func sigwaitinfo,int signo) +void test_empty_set (swi_func sigwaitinfo,int signo,enum tst_ts_type type) {sigset_t sigs;siginfo_t si;
@@ -132,19 +143,23 @@ void test_empty_set(swi_func sigwaitinfo, int signo)SAFE_WAIT (NULL ); } -void test_timeout (swi_func sigwaitinfo,int signo) +void test_timeout (swi_func sigwaitinfo,int signo,enum tst_ts_type type) {sigset_t sigs;siginfo_t si;pid_t child; -struct timespec ts = {.tv_sec =1 }; +struct tst_ts ts; + + ts.type = type; +tst_ts_set_sec (&ts,1 ); +tst_ts_set_nsec (&ts,0 );SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs);/* Run a child that will wake us up */ child =create_sig_proc (signo,INT_MAX ,100000 ); -TEST (sigwaitinfo (&sigs, &si, &ts)); +TEST (sigwaitinfo (&sigs, &si,tst_ts_get (&ts)));REPORT_SUCCESS (-1 ,EAGAIN );SAFE_KILL (child,SIGTERM );
@@ -154,7 +169,8 @@ void test_timeout(swi_func sigwaitinfo, int signo)/* Note: sigwait-ing for a signal that is not blocked is unspecified * by POSIX; but works for non-ignored signals under Linux */ -void test_unmasked_matching (swi_func sigwaitinfo,int signo) +void test_unmasked_matching (swi_func sigwaitinfo,int signo, +enum tst_ts_type type) {sigset_t sigs;siginfo_t si;
@@ -175,7 +191,8 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo)SAFE_WAIT (NULL ); } -void test_unmasked_matching_noinfo (swi_func sigwaitinfo,int signo) +void test_unmasked_matching_noinfo (swi_func sigwaitinfo,int signo, +enum tst_ts_type type) {sigset_t sigs;pid_t child;
@@ -192,7 +209,8 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo)SAFE_WAIT (NULL ); } -void test_masked_matching (swi_func sigwaitinfo,int signo) +void test_masked_matching (swi_func sigwaitinfo,int signo, +enum tst_ts_type type) {sigset_t sigs, oldmask;siginfo_t si;
@@ -230,7 +248,8 @@ void test_masked_matching(swi_func sigwaitinfo, int signo)SAFE_WAIT (NULL ); } -void test_masked_matching_rt (swi_func sigwaitinfo,int signo) +void test_masked_matching_rt (swi_func sigwaitinfo,int signo, +enum tst_ts_type type) {sigset_t sigs, oldmask;siginfo_t si;
@@ -281,7 +300,8 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo) "sigwaitinfo failed to restore the original mask"); } -void test_masked_matching_noinfo (swi_func sigwaitinfo,int signo) +void test_masked_matching_noinfo (swi_func sigwaitinfo,int signo, +enum tst_ts_type type) {sigset_t sigs, oldmask;pid_t child;
@@ -316,7 +336,7 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo)SAFE_WAIT (NULL ); } -void test_bad_address (swi_func sigwaitinfo,int signo) +void test_bad_address (swi_func sigwaitinfo,int signo,enum tst_ts_type type) {sigset_t sigs, oldmask;pid_t child;
@@ -345,7 +365,7 @@ void test_bad_address(swi_func sigwaitinfo, int signo)SAFE_WAIT (NULL ); } -void test_bad_address2 (swi_func sigwaitinfo,int signo) +void test_bad_address2 (swi_func sigwaitinfo,int signo,enum tst_ts_type type) {pid_t pid;int status;
@@ -391,7 +411,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo) } } -void test_bad_address3 (swi_func sigwaitinfo,int signo) +void test_bad_address3 (swi_func sigwaitinfo,int signo,enum tst_ts_type type) {sigset_t sigs;SUCCEED_OR_DIE (sigemptyset,"sigemptyset failed" , &sigs);
@@ -407,28 +427,28 @@ struct test_desc { } tests[] = {#ifdef TEST_RT_SIGTIMEDWAIT { - test_empty_set, my_rt_sigtimedwait, SIGUSR1}, { - test_unmasked_matching, my_rt_sigtimedwait, SIGUSR1}, { - test_masked_matching, my_rt_sigtimedwait, SIGUSR1}, { - test_unmasked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1}, { - test_masked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1}, { - test_bad_address, my_rt_sigtimedwait, SIGUSR1}, { - test_bad_address2, my_rt_sigtimedwait, SIGUSR1}, { - test_bad_address3, my_rt_sigtimedwait, SIGUSR1}, { - test_timeout, my_rt_sigtimedwait, 0}, + test_empty_set, NULL, SIGUSR1}, { + test_unmasked_matching, NULL, SIGUSR1}, { + test_masked_matching, NULL, SIGUSR1}, { + test_unmasked_matching_noinfo, NULL, SIGUSR1}, { + test_masked_matching_noinfo, NULL, SIGUSR1}, { + test_bad_address, NULL, SIGUSR1}, { + test_bad_address2, NULL, SIGUSR1}, { + test_bad_address3, NULL, SIGUSR1}, { + test_timeout, NULL, 0},/* Special cases */ /* 1: sigwaitinfo does respond to ignored signal */ { - test_masked_matching, my_rt_sigtimedwait, SIGUSR2}, + test_masked_matching, NULL, SIGUSR2},/* 2: An ignored signal doesn't cause sigwaitinfo to return EINTR */ { - test_timeout, my_rt_sigtimedwait, SIGUSR2}, + test_timeout, NULL, SIGUSR2},/* 3: The handler is not called when the signal is waited for by sigwaitinfo */ { - test_masked_matching, my_rt_sigtimedwait, SIGTERM}, + test_masked_matching, NULL, SIGTERM},/* 4: Simultaneous realtime signals are delivered in the order of increasing signal number */ { - test_masked_matching_rt, my_rt_sigtimedwait, -1}, + test_masked_matching_rt, NULL, -1}, #endif #if defined TEST_SIGWAIT {
@@ -459,15 +479,48 @@ struct test_desc {#endif }; +static struct test_variants { +swi_func swi; +enum tst_ts_type type; +char *desc; +} variants[] = { +#ifdef TEST_RT_SIGTIMEDWAIT + +#if defined(TST_ABI32) + { .swi = my_rt_sigtimedwait, .type =TST_LIBC_TIMESPEC , .desc ="syscall with libc spec" }, + { .swi = my_rt_sigtimedwait, .type =TST_KERN_OLD_TIMESPEC , .desc ="syscall with kernel spec32" }, +#endif + +#if defined(TST_ABI64) + { .swi = my_rt_sigtimedwait, .type =TST_KERN_TIMESPEC , .desc ="syscall with kernel spec64" }, +#endif + +#if (__NR_rt_sigtimedwait_time64 != __LTP__NR_INVALID_SYSCALL) + { .swi = my_rt_sigtimedwait_time64, .type =TST_KERN_TIMESPEC , .desc ="syscall time64 with kernel spec64" }, +#endif + +#else /* !TEST_RT_SIGTIMEDWAIT */ + + { .swi =NULL , .type =TST_LIBC_TIMESPEC , .desc ="syscall with libc spec" }, + +#endif /* TEST_RT_SIGTIMEDWAIT */ +}; +static void run (unsigned int i) { +struct test_variants *tv = &variants[tst_variant];struct test_desc *tc = &tests[i]; +swi_func swi; - tc->tf (tc->swi, tc->signo); + swi = tv->swi ? tv->swi : tc->swi; + + tc->tf (swi, tc->signo, tv->type); }static void setup (void ) { +tst_res (TINFO ,"Testing variant: %s" , variants[tst_variant].desc); +signal (SIGUSR1 , empty_handler);signal (SIGALRM , empty_handler);signal (SIGUSR2 ,SIG_IGN );
@@ -483,6 +536,7 @@ static void cleanup(void)static struct tst_test test = { .test= run, .tcnt =ARRAY_SIZE (tests), + .test_variants =ARRAY_SIZE (variants), .setup = setup, .cleanup = cleanup, .forks_child =1 ,
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH 6/8 syscalls/mq_timed{send|receive}: Add support for time64 tests
In reply to Viresh KumarThis adds support for time64 tests to the existing mq_timed{send|receive}() syscall tests.
--- include/tst_timer.h | 41 +++++++++ .../mq_timedreceive/mq_timedreceive01.c | 83 ++++++++++++++---- .../syscalls/mq_timedsend/mq_timedsend01.c | 87 +++++++++++++++---- testcases/kernel/syscalls/utils/mq_timed.h | 28 +++--- 4 files changed, 189 insertions(+), 50 deletions(-)
include/tst_timer.h +41 -0
@@ -14,6 +14,7 @@#include <sched.h> #include <sys/time.h> +#include <mqueue.h> #include <time.h> #include "tst_test.h" #include "lapi/common_timers.h"
@@ -255,6 +256,46 @@ static inline int sys_futex_time64(int *uaddr, int futex_op, int val, void *to,return tst_syscall (__NR_futex_time64, uaddr, futex_op, val, to, uaddr2, val3); } +static inline int libc_mq_timedsend (mqd_t mqdes,const char *msg_ptr, +size_t msg_len,unsigned int msg_prio,void *abs_timeout) +{ +return mq_timedsend (mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); +} + +static inline int sys_mq_timedsend (mqd_t mqdes,const char *msg_ptr, +size_t msg_len,unsigned int msg_prio,void *abs_timeout) +{ +return tst_syscall (__NR_mq_timedsend, mqdes, msg_ptr, msg_len, msg_prio, + abs_timeout); +} + +static inline int sys_mq_timedsend64 (mqd_t mqdes,const char *msg_ptr, +size_t msg_len,unsigned int msg_prio,void *abs_timeout) +{ +return tst_syscall (__NR_mq_timedsend_time64, mqdes, msg_ptr, msg_len, + msg_prio, abs_timeout); +} + +static inline ssize_t libc_mq_timedreceive (mqd_t mqdes,char *msg_ptr, +size_t msg_len,unsigned int *msg_prio,void *abs_timeout) +{ +return mq_timedreceive (mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); +} + +static inline ssize_t sys_mq_timedreceive (mqd_t mqdes,char *msg_ptr, +size_t msg_len,unsigned int *msg_prio,void *abs_timeout) +{ +return tst_syscall (__NR_mq_timedreceive, mqdes, msg_ptr, msg_len, + msg_prio, abs_timeout); +} + +static inline ssize_t sys_mq_timedreceive64 (mqd_t mqdes,char *msg_ptr, +size_t msg_len,unsigned int *msg_prio,void *abs_timeout) +{ +return tst_syscall (__NR_mq_timedreceive_time64, mqdes, msg_ptr, msg_len, + msg_prio, abs_timeout); +} +static inline int libc_sched_rr_get_interval (pid_t pid,void *ts) {return sched_rr_get_interval (pid, ts);
testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c +67 -16
169 lines not on this page · raw message
testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c +69 -18
191 lines not on this page · raw message
testcases/kernel/syscalls/utils/mq_timed.h +12 -16
@@ -19,12 +19,15 @@#define MQ_TIMED_H #include "mq.h" +#include "tst_timer.h" struct test_case {int *fd;unsigned int len;unsigned int prio; -struct timespec *rq; +struct tst_ts *rq; +long tv_sec; +long tv_nsec;int invalid_msg;int send;int signal;
@@ -33,27 +36,20 @@ struct test_case {int err; }; -static pid_t set_sig (struct timespec *ts) +static pid_t set_sig (struct tst_ts *ts, +int (*gettime)(clockid_t clk_id,void *ts)) { -clock_gettime (CLOCK_REALTIME , ts); - ts->tv_sec +=3 ; +gettime (CLOCK_REALTIME ,tst_ts_get (ts)); + *ts =tst_ts_add_us (*ts,3000000 );return create_sig_proc (SIGINT ,40 ,200000 ); } -static void set_timeout (struct timespec *ts) +static void set_timeout (struct tst_ts *ts, +int (*gettime)(clockid_t clk_id,void *ts)) { -clock_gettime (CLOCK_REALTIME , ts); - ts->tv_nsec +=50000000 ; - ts->tv_sec += ts->tv_nsec /1000000000 ; - ts->tv_nsec %=1000000000 ; -} - -static void send_msg (int fd,int len,int prio) -{ -if (mq_timedsend (fd, smsg, len, prio, - &((struct timespec ){0 })) <0 ) -tst_brk (TBROK |TERRNO ,"mq_timedsend failed" ); +gettime (CLOCK_REALTIME ,tst_ts_get (ts)); + *ts =tst_ts_add_us (*ts,50000 ); }static void kill_pid (pid_t pid)
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH 7/8 syscalls/recvmmsg: Add support for time64 tests
In reply to Viresh KumarThis adds support for time64 tests to the existing recvmmsg() syscall tests.
--- .../kernel/syscalls/sendmmsg/sendmmsg01.c | 45 +++++++++++---- .../kernel/syscalls/sendmmsg/sendmmsg_var.h | 55 ++++++++----------- 2 files changed, 58 insertions(+), 42 deletions(-)
testcases/kernel/syscalls/sendmmsg/sendmmsg01.c +35 -10
@@ -14,8 +14,8 @@#include "tst_test.h" #include "lapi/socket.h" #include "tst_safe_macros.h" -#include "sendmmsg_var.h" +#include "lapi/abisize.h" #define BUFSIZE 16#define VLEN 2
@@ -25,27 +25,52 @@ static int receive_sockfd;static struct mmsghdr *snd_msg, *rcv_msg;static struct iovec *snd1, *snd2, *rcv1, *rcv2; +static struct test_variants { +int (*receive)(int sockfd,struct mmsghdr *msgvec,unsigned int vlen, +unsigned int flags,void *timeout); +int (*send)(int sockfd,struct mmsghdr *msgvec,unsigned int vlen, +unsigned int flags); +enum tst_ts_type type; +char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .receive = libc_recvmmsg, .send = libc_sendmmsg, .type =TST_LIBC_TIMESPEC , .desc ="vDSO or syscall with libc spec" }, + { .receive = sys_recvmmsg, .send = sys_sendmmsg, .type =TST_LIBC_TIMESPEC , .desc ="syscall with libc spec" }, + { .receive = sys_recvmmsg, .send = sys_sendmmsg, .type =TST_KERN_OLD_TIMESPEC , .desc ="syscall with kernel spec32" }, +#endif + +#if defined(TST_ABI64) + { .receive = sys_recvmmsg, .send = sys_sendmmsg, .type =TST_KERN_TIMESPEC , .desc ="syscall with kernel spec64" }, +#endif + +#if (__NR_recvmmsg_time64 != __LTP__NR_INVALID_SYSCALL) + { .receive = sys_recvmmsg64, .send = sys_sendmmsg, .type =TST_KERN_TIMESPEC , .desc ="syscall time64 with kernel spec64" }, +#endif +}; +static void run (void ) { -struct timespec timeout; +struct test_variants *tv = &variants[tst_variant]; +struct tst_ts timeout;int retval; - retval =do_sendmmsg (send_sockfd, snd_msg,VLEN ,0 ); + retval = tv->send (send_sockfd, snd_msg,VLEN ,0 );if (retval <0 || snd_msg[0 ].msg_len !=6 || snd_msg[1 ].msg_len !=6 ) { -tst_res (TFAIL |TTERRNO ,"sendmmsg failed" ); +tst_res (TFAIL |TTERRNO ,"sendmmsg() failed" );return ; }memset (rcv1->iov_base,0 , rcv1->iov_len);memset (rcv2->iov_base,0 , rcv2->iov_len); - timeout.tv_sec =1 ; - timeout.tv_nsec =0 ; + timeout.type = tv->type; +tst_ts_set_sec (&timeout,1 ); +tst_ts_set_nsec (&timeout,0 ); - retval =do_recvmmsg (receive_sockfd, rcv_msg,VLEN ,0 , &timeout); + retval = tv->receive (receive_sockfd, rcv_msg,VLEN ,0 ,tst_ts_get (&timeout));if (retval ==-1 ) { -tst_res (TFAIL |TTERRNO ,"recvmmsg failed" ); +tst_res (TFAIL |TTERRNO ,"recvmmsg() failed" );return ; }if (retval !=2 ) {
@@ -96,7 +121,7 @@ static void setup(void) rcv_msg[1 ].msg_hdr.msg_iov = rcv2; rcv_msg[1 ].msg_hdr.msg_iovlen =1 ; -test_info (); +tst_res (TINFO ,"Testing variant: %s" , variants[tst_variant].desc); }static void cleanup (void )
@@ -111,7 +136,7 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, - .test_variants = TEST_VARIANTS, + .test_variants = ARRAY_SIZE(variants), .bufs = (struct tst_buffers []) { {&snd1, .iov_sizes = (int []){3 ,3 ,-1 }}, {&snd2, .iov_sizes = (int []){6 ,-1 }},
testcases/kernel/syscalls/sendmmsg/sendmmsg_var.h +23 -32
78 lines not on this page · raw message
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH 8/8 syscalls/ppoll: Add support for time64 tests
In reply to Viresh KumarThis adds support for time64 tests to the existing ppoll() syscall tests.
Note that the O_EXCL flag is removed from SAFE_OPEN() calls as it made the tests failed when run for the second variant as the file existed.
--- testcases/kernel/syscalls/ppoll/ppoll01.c | 76 ++++++++++++++++++----- 1 file changed, 60 insertions(+), 16 deletions(-)
testcases/kernel/syscalls/ppoll/ppoll01.c +60 -16
@@ -21,6 +21,8 @@#include "ltp_signal.h" #include "tst_sig_proc.h" #include "tst_test.h" +#include "tst_timer.h" +#include "lapi/abisize.h" /* Older versions of glibc don't publish this constant's value. */ #ifndef POLLRDHUP
@@ -38,7 +40,7 @@ struct test_case {unsigned int nfds;/* nfds ppoll parameter */ sigset_t *sigmask;/* sigmask ppoll parameter */ sigset_t *sigmask_cur;/* sigmask set for current process */ -struct timespec *ts;/* ts ppoll parameter */ +struct tst_ts *ts;/* ts ppoll parameter */ struct pollfd *fds;/* fds ppoll parameter */ int sigint_count;/* if > 0, spawn process to send SIGINT */ /* 'count' times to current process */
@@ -60,14 +62,7 @@ static int fd1 = -1;static sigset_t sigmask_empty, sigmask_sigint;static struct pollfd fds_good[1 ], fds_already_closed[1 ]; -static struct timespec ts_short = { - .tv_sec =0 , - .tv_nsec =200000000 , -}; -static struct timespec ts_long = { - .tv_sec =2 , - .tv_nsec =0 , -}; +static struct tst_ts ts_short, ts_long;/* Test cases *
@@ -160,14 +155,57 @@ static struct test_case tcase[] = { }, }; +static inline int libc_ppoll (struct pollfd *fds,nfds_t nfds,void *tmo_p, +const sigset_t *sigmask,size_t sigsetsize) +{ +return ppoll (fds, nfds, tmo_p, sigmask); +} + +static inline int sys_ppoll (struct pollfd *fds,nfds_t nfds,void *tmo_p, +const sigset_t *sigmask,size_t sigsetsize) +{ +return tst_syscall (__NR_ppoll, fds, nfds, tmo_p, sigmask, sigsetsize); +} + +static inline int sys_ppoll_time64 (struct pollfd *fds,nfds_t nfds,void *tmo_p, +const sigset_t *sigmask,size_t sigsetsize) +{ +return tst_syscall (__NR_ppoll_time64, fds, nfds, tmo_p, sigmask, + sigsetsize); +} + +static struct test_variants { +int (*ppoll)(struct pollfd *fds,nfds_t nfds,void *tmo_p, +const sigset_t *sigmask,size_t sigsetsize); + +enum tst_ts_type type; +char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .ppoll = libc_ppoll, .type =TST_LIBC_TIMESPEC , .desc ="vDSO or syscall with libc spec" }, + { .ppoll = sys_ppoll, .type =TST_LIBC_TIMESPEC , .desc ="syscall with libc spec" }, + { .ppoll = sys_ppoll, .type =TST_KERN_OLD_TIMESPEC , .desc ="syscall with kernel spec32" }, +#endif + +#if defined(TST_ABI64) + { .ppoll = sys_ppoll, .type =TST_KERN_TIMESPEC , .desc ="syscall with kernel spec64" }, +#endif + +#if (__NR_ppoll_time64 != __LTP__NR_INVALID_SYSCALL) + { .ppoll = sys_ppoll_time64, .type =TST_KERN_TIMESPEC , .desc ="syscall time64 with kernel spec64" }, +#endif +}; + static void sighandler(int sig LTP_ATTRIBUTE_UNUSED) { }static void setup (void ) { +struct test_variants *tv = &variants[tst_variant];int fd2; +tst_res (TINFO ,"Testing variant: %s" , tv->desc);SAFE_SIGNAL (SIGINT , sighandler);if (sigemptyset (&sigmask_empty) ==-1 )
@@ -177,18 +215,22 @@ static void setup(void)if (sigaddset (&sigmask_sigint,SIGINT ) ==-1 )tst_brk (TBROK |TERRNO ,"sigaddset" ); - fd1 =SAFE_OPEN ("testfile1" ,O_CREAT |O_EXCL |O_RDWR , -S_IRUSR |S_IWUSR ); + fd1 =SAFE_OPEN ("testfile1" ,O_CREAT |O_RDWR ,S_IRUSR |S_IWUSR ); fds_good[0 ].fd = fd1; fds_good[0 ].events =POLLIN |POLLPRI |POLLOUT |POLLRDHUP ; fds_good[0 ].revents =0 ; - fd2 =SAFE_OPEN ("testfile2" ,O_CREAT |O_EXCL |O_RDWR , -S_IRUSR |S_IWUSR ); + fd2 =SAFE_OPEN ("testfile2" ,O_CREAT |O_RDWR ,S_IRUSR |S_IWUSR ); fds_already_closed[0 ].fd = fd2; fds_already_closed[0 ].events =POLLIN |POLLPRI |POLLOUT |POLLRDHUP ; fds_already_closed[0 ].revents =0 ;SAFE_CLOSE (fd2); + + ts_short.type = ts_long.type = tv->type; +tst_ts_set_sec (&ts_short,0 ); +tst_ts_set_nsec (&ts_short,200000000 ); +tst_ts_set_sec (&ts_long,2 ); +tst_ts_set_nsec (&ts_long,0 ); }static void cleanup (void )
@@ -199,10 +241,11 @@ static void cleanup(void)static void do_test (unsigned int i) { +struct test_variants *tv = &variants[tst_variant];pid_t pid =0 ;int sys_ret, sys_errno =0 , dummy;struct test_case *tc = &tcase[i]; -struct timespec ts, *tsp =NULL ; +struct tst_ts ts, *tsp =NULL ;if (tc->ts) {memcpy (&ts, tc->ts,sizeof (ts));
@@ -223,8 +266,8 @@ static void do_test(unsigned int i)/* test */ errno =0 ; - sys_ret =tst_syscall (__NR_ppoll, tc->fds, tc->nfds, tsp, - tc->sigmask,SIGSETSIZE ); + sys_ret = tv->ppoll (tc->fds, tc->nfds,tst_ts_get (tsp), tc->sigmask, +SIGSETSIZE ); sys_errno = errno;/* cleanup */
@@ -261,6 +304,7 @@ static void do_test(unsigned int i)static struct tst_test test = { .tcnt =ARRAY_SIZE (tcase), .test = do_test, + .test_variants =ARRAY_SIZE (variants), .setup = setup, .cleanup = cleanup, .forks_child =1 ,
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH 1/8 syscalls/futex: Merge futex_wait_bitset tests
In reply to Viresh KumarHi Viresh,
Quoted 3 lines
We can handle them easily in a single test, lets do it.
Signed-off-by Viresh Kumar <[email protected]>
LGTM.
Kind regards,
Petr