syscalls: fix some failure on arch X86_64
PATCH 1/1 syscalls: fix some failure on arch X86_64
- rt_sigaction01
On arch x86_64, if we directly get to call syscall rt_sigaction, there will be "segment fault".
1) One reason is that we must supply the flag of "SA_RESTORER" and the correct pointer to the fuction "restorer", according to the kernel code.
2) The other reason is that default syscall rt_sigaction use kernel "sigaction" structure, which is different with normal "sigaction" structure.
So,
1) We manage to find the address of the function "restorer" by using glibc function "sigaction", which might be something tricky. Then we add these arguments to make test run correctly.
2) We also use kernel "sigaction" structure to fit realtime syscall __NR_rt_sigaction.
- rt_sigprocmask01
First, there exsits the same problem as rt_sigaction01. Second, this testcase uses a unchanged signal number 33, which may diff among different archs and lead to error "unknown signal".
So, we use a macro TEST_SIG which refers to SIGRTMIN to replace 33.
- rt_sigsuspend01
There exists the same problem as rt_sigaction01.
This patch fixed these failure.
--- include/rt_signal.h | 60 ++++++++++++++++++ .../kernel/syscalls/rt_sigaction/rt_sigaction01.c | 64 +++++++++++-------- .../syscalls/rt_sigprocmask/rt_sigprocmask01.c | 32 +++++++--- .../syscalls/rt_sigsuspend/rt_sigsuspend01.c | 13 ++++- 4 files changed, 132 insertions(+), 37 deletions(-) create mode 100644 include/rt_signal.h
include/rt_signal.h new file +60 -0
@@ -0,0 +1,60 @@ +/******************************************************************************/ +/* */ +/* Copyright (c) 2009 FUJITSU LIMITED */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/* Author: Liu Bo <[email protected]> */ +/* */ +/******************************************************************************/ + +#ifndef __LTP_SIGNAL_H +#define __LTP_SIGNAL_H + +/* We do not globally define the SA_RESTORER flag so do it here. */ +#define HAVE_SA_RESTORER +#define SA_RESTORER 0x04000000 + +struct kernel_sigaction { +__sighandler_t k_sa_handler; +unsigned long sa_flags; +void (*sa_restorer) (void ); +sigset_t sa_mask; +}; + +void (*restore_rt) (void ); + +void +handler_h (void ) +{ +return ; +} + +/* initial restore_rt for x86_64 */ +void +sig_initial (int sig) +{ +struct sigaction act, oact; + + act.sa_handler = (void *)handler_h; +sigemptyset (&act.sa_mask); +sigaddset (&act.sa_mask, sig); +/* copy act.sa_restorer to kernel */ +sigaction (sig, &act, &oact); +/* copy oact.sa_restorer from kernel */ +sigaction (sig, &act, &oact); + restore_rt = oact.sa_restorer; +} +#endif
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +37 -27
97 lines not on this page · raw message
testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +23 -9
@@ -62,6 +62,12 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + +#define TEST_SIG SIGRTMIN +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */
@@ -131,7 +137,16 @@ void sig_handler(int sig) }int main (int ac,char **av) { -struct sigaction act, oact; +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (TEST_SIG ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else +struct sigaction act, oact; + act.sa_handler = sig_handler; +#endif sigset_t set, oset;int lc;/* loop counter */ char *msg;/* message returned from parse_opts */
@@ -154,22 +169,21 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigaddset (&set,33 )); +TEST (sigaddset (&set,TEST_SIG ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to sigaddset() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();tst_exit (); } - +/* call rt_sigaction() */ - act.sa_handler = sig_handler; -TEST (syscall (__NR_rt_sigaction,33 , &act, &oact,8 )); +TEST (syscall (__NR_rt_sigaction,TEST_SIG , &act, &oact,8 ));if (TEST_RETURN !=0 ){tst_resm (TFAIL ,"Call to rt_sigaction() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();tst_exit (); } -/* call rt_sigprocmask() to block signal#33 */ +/* call rt_sigprocmask() to block signal#SIGRTMIN */ TEST (syscall (__NR_rt_sigprocmask,SIG_BLOCK , &set, &oset,8 ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to rt_sigprocmask()**** Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));
@@ -178,7 +192,7 @@ int main(int ac, char **av) { }else { -TEST (kill (getpid (),33 )); +TEST (kill (getpid (),TEST_SIG ));if (TEST_RETURN !=0 ){tst_resm (TFAIL ,"Call to kill() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();
@@ -198,13 +212,13 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigismember (&oset,33 )); +TEST (sigismember (&oset,TEST_SIG ));if (TEST_RETURN ==0 ){tst_resm (TFAIL ,"call sigismember() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();tst_exit (); } -/* call rt_sigprocmask() to unblock signal#33 */ +/* call rt_sigprocmask() to unblock signal#SIGRTMIN */ TEST (syscall (__NR_rt_sigprocmask,SIG_UNBLOCK , &set, &oset,8 ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to rt_sigprocmask() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));
testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +12 -1
@@ -47,6 +47,10 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */
@@ -139,9 +143,16 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (SIGALRM ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else struct sigaction act, oact; act.sa_handler = sig_handler; - +#endif TEST (syscall (__NR_rt_sigaction,SIGALRM , &act, &oact,8 ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"rt_sigaction() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));
Signature · 16 lines
1.6.2.2 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
By and large this diff looks really good. My comments...
Quoted 18 lines · liubo
-
rt_sigaction01
On archx86_64, if we directly get to call syscallrt_sigaction, there will be "segment fault".
1) One reason is that we must supply the flag of "SA_RESTORER" and the correct pointer to the fuction "restorer", according to the kernel code.
2) The other reason is that default syscallrt_sigactionuse kernel "sigaction" structure, which is different with normal "sigaction" structure.So,
1) We manage to find the address of the function "restorer" by using glibc function "sigaction", which might be something tricky. Then we add these arguments to make test run correctly.
2) We also use kernel "sigaction" structure to fit realtime syscall__NR_rt_sigaction.
Quoted 8 lines
-
rt_sigprocmask01
First, there exsits the same problem asrt_sigaction01. Second, this testcase uses a unchanged signal number 33, which may diff among different archs and lead to error "unknown signal".So, we use a macro
TEST_SIGwhich refers to SIGRTMIN to replace 33.
The problem is that SIGRTMIN is actually signal 32, not signal 33, and here's a problematic comment to ponder over (from bits/signum.h):
/* These are the hard limits of the kernel. These values should not be
used directly at user level. */
#define __SIGRTMIN 32
#define __SIGRTMAX (_NSIG - 1)
I think the proper resolution would be to make the value SIGRTMIN+1.
Quoted 179 lines
-
rt_sigsuspend01
There exists the same problem asrt_sigaction01.This patch fixed these failure.
Signed-off-by Liu Bo <[email protected]>---
include/rt_signal.h | 60 ++++++++++++++++++.../kernel/syscalls/rt_sigaction/rt_sigaction01.c| 64 +++++++++++--------.../syscalls/rt_sigprocmask/rt_sigprocmask01.c| 32 +++++++---.../syscalls/rt_sigsuspend/rt_sigsuspend01.c| 13 ++++-4 files changed, 132 insertions(+), 37 deletions(-)create mode 100644
include/rt_signal.hinclude/rt_signal.h new file +60
-0@@ -0,0 +1,60 @@ +/******************************************************************************/ +/* */ +/* Copyright (c) 2009 FUJITSU LIMITED */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/* Author: Liu Bo <[email protected]> */ +/* */ +/******************************************************************************/ + +#ifndef __LTP_SIGNAL_H +#define __LTP_SIGNAL_H + +/* We do not globally define the SA_RESTORER flag so do it here. */ +#define HAVE_SA_RESTORER +#define SA_RESTORER 0x04000000 + +struct kernel_sigaction { + __sighandler_t k_sa_handler; + unsigned long sa_flags; + void (*sa_restorer) (void); + sigset_t sa_mask; +}; + +void (*restore_rt) (void ); + +void +handler_h (void ) +{ + return; +} + +/* initial restore_rt for x86_64 */ +void +sig_initial (int sig) +{ + struct sigaction act, oact; + + act.sa_handler = (void *)handler_h; + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask, sig); + /* copy act.sa_restorer to kernel */ + sigaction(sig, &act, &oact); + /* copy oact.sa_restorer from kernel */ + sigaction(sig, &act, &oact); + restore_rt = oact.sa_restorer; +} +#endif testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +17
-12@@ -55,6 +55,10 @@ #include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + /** For all but __mips__: * @@ -101,13 +105,14 @@ int TST_TOTAL = 1; /* total number of tests in this file. * /* On success - Exits calling tst_exit(). With '0' return code. */ /* */ /******************************************************************************/ -extern void cleanup () { - /* Remove tmp dir and all files in it */ - TEST_CLEANUP; - tst_rmdir(); +extern void cleanup () +{ + /* Remove tmp dir and all files in it */ + TEST_CLEANUP; + tst_rmdir(); - /* Exit with appropriate return code. */ - tst_exit(); + /* Exit with appropriate return code. */ + tst_exit(); } /* Local Functions */@@ -128,11 +133,12 @@ extern void cleanup() { /* On success - returns 0. */ /* */ /******************************************************************************/ -void setup () { - /* Capture signals if any */ - /* Create temporary directories */ - TEST_PAUSE; - tst_tmpdir(); +void setup () +{ + /* Capture signals if any */ + /* Create temporary directories */ + TEST_PAUSE; + tst_tmpdir(); } int test_flags[] = {SA_RESETHAND|SA_SIGINFO, SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO, SA_NOMASK};@@ -144,22 +150,23 @@ handler(int sig) tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig); return; } -int
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +1
-1-set_handler(int sig, int sig_to_mask, int mask_flags) +set_handler(int sig, int mask_flags){
- struct sigaction sa, oldaction;testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +14
-11- - sa.sa_sigaction = (void *)handler; - sa.sa_flags = mask_flags; - sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, sig_to_mask); - TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE)); - if (TEST_RETURN == 0) { - return 0; - } else { - return TEST_RETURN; - } +#ifdef __x86_64__ + struct kernel_sigaction sa, oldaction; + mask_flags |= SA_RESTORER; + sa.sa_restorer = restore_rt; + sa.k_sa_handler = (void *)handler; +#else + struct sigaction sa, oldaction; + sa.sa_handler = (void *)handler; +#endif + sa.sa_flags = mask_flags; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, sig); + TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE)); + return TEST_RETURN;}
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +0
-0@@ -182,8 +189,11 @@ int main(int ac, char **av) { for (testno = 0; testno < TST_TOTAL; ++testno) {for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65
- for(flag=0; flag<5;flag++) {
- TEST(set_handler(signal, 0, test_flags[flag]));
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c int main(int ac, char **av) { · line 196
Quoted 5 lines
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +5
-0+#ifdef __x86_64__ + sig_initial(signal); +#endif + for(flag=0; flag<5;flag++) { + TEST(set_handler(signal, test_flags[flag]));
I know this isn't your code change, but since you're here.. a better way to do this would be:
sizeof (test_flags) / sizeof (test_flags[0])
as this is a fixed array buffer.
Quoted 124 lines
if (
TEST_RETURN== 0) {
tst_resm(TINFO,"signal: %d ", signal);
tst_resm(TPASS, "rt_sigactioncall succeeded: result = %ld ",TEST_RETURN );testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +6
-0@@ -62,6 +62,12 @@ #include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + +#define TEST_SIG SIGRTMIN + /* Extern Global Variables */extern int
Tst_count; /* counter fortst_xxxroutines. */ extern char *TESTDIR; /* temporary dir created bytst_tmpdir()*/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +10
-1@@ -131,7 +137,16 @@ void sig_handler(int sig) } int main(int ac, char **av) { - struct sigaction act, oact; +#ifdef __x86_64__ + struct kernel_sigaction act, oact; + sig_initial(TEST_SIG); + act.sa_flags |= SA_RESTORER; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else + struct sigaction act, oact; + act.sa_handler = sig_handler; +#endif sigset_t set, oset;int lc; /* loop counter */
char *msg; /* message returned fromparse_opts*/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +7
-8@@ -154,22 +169,21 @@ int main(int ac, char **av) { cleanup(); tst_exit(); } - TEST(sigaddset(&set, 33)); + TEST(sigaddset(&set, TEST_SIG)); if(TEST_RETURN == -1){ tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup(); tst_exit(); } - + /* call rt_sigaction() */ - act.sa_handler = sig_handler; - TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8)); + TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact, 8)); if(TEST_RETURN != 0){ tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup(); tst_exit(); } - /* call rt_sigprocmask() to block signal#33 */ + /* call rt_sigprocmask() to block signal#SIGRTMIN */ TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8)); if(TEST_RETURN == -1){ tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));@@ -178,7 +192,7 @@ int main(int ac, char **av) { } else { - TEST(kill(getpid(), 33)); + TEST(kill(getpid(), TEST_SIG)); if(TEST_RETURN != 0){ tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup();@@ -198,13 +212,13 @@ int main(int ac, char **av) { cleanup(); tst_exit(); } - TEST(sigismember(&oset, 33)); + TEST(sigismember(&oset, TEST_SIG)); if(TEST_RETURN == 0 ){ tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup(); tst_exit(); } - /* call rt_sigprocmask() to unblock signal#33 */ + /* call rt_sigprocmask() to unblock signal#SIGRTMIN */ TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, 8)); if(TEST_RETURN == -1){ tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +4
-0@@ -47,6 +47,10 @@ #include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + /* Extern Global Variables */extern int
Tst_count; /* counter fortst_xxxroutines. */ extern char *TESTDIR; /* temporary dir created bytst_tmpdir()*/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +8
-2@@ -139,9 +143,16 @@ int main(int ac, char **av) { cleanup(); tst_exit(); } +#ifdef __x86_64__ + struct kernel_sigaction act, oact; + sig_initial(SIGALRM); + act.sa_flags |= SA_RESTORER; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else struct sigaction act, oact; act.sa_handler = sig_handler; - +#endif TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8)); if(TEST_RETURN == -1){ tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); --
Quoted 1 line
1.6.2.2
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 35 lines · Garrett Cooper
By and large this diff looks really good. My comments...
Quoted 18 lines · liubo
-
rt_sigaction01
On archx86_64, if we directly get to call syscallrt_sigaction, there will be "segment fault".
1) One reason is that we must supply the flag of "SA_RESTORER" and the correct pointer to the fuction "restorer", according to the kernel code.
2) The other reason is that default syscallrt_sigactionuse kernel "sigaction" structure, which is different with normal "sigaction" structure.So,
1) We manage to find the address of the function "restorer" by using glibc function "sigaction", which might be something tricky. Then we add these arguments to make test run correctly.
2) We also use kernel "sigaction" structure to fit realtime syscall__NR_rt_sigaction.Quoted 9 lines
-
rt_sigprocmask01
First, there exsits the same problem asrt_sigaction01. Second, this testcase uses a unchanged signal number 33, which may diff among different archs and lead to error "unknown signal".So, we use a macro
TEST_SIGwhich refers to SIGRTMIN to replace 33.The problem is that SIGRTMIN is actually signal 32, not signal 33, and here's a problematic comment to ponder over (from
bits/signum.h):
Quoted 8 lines
/* These are the hard limits of the kernel. These values should not be
used directly at user level. */
#define__SIGRTMIN32
#define__SIGRTMAX(_NSIG- 1)I think the proper resolution would be to make the value SIGRTMIN+1.
Hi, Garrett,
In fact, I'm confused about whether #33 signal is particularly needed here, in some of my boxes, SIGRTMIN actually refers #34 signal, that is, #33 is unreachable.
IMO, any realtime reachable signal can be used to pass the case here, and I pick SIGRTMIN by define a macro: #define TEST_SIG SIGRTMIN.
Of course, the value "SIGRTMIN+1" also pass the case, so I'll pick your value.
If you are free, looking forward to your explaination ...
Quoted 189 lines
Quoted 175 lines
-
rt_sigsuspend01
There exists the same problem asrt_sigaction01.This patch fixed these failure.
Signed-off-by Liu Bo <[email protected]>--- include/rt_signal.h | 60 ++++++++++++++++++ .../kernel/syscalls/rt_sigaction/rt_sigaction01.c | 64 +++++++++++-------- .../syscalls/rt_sigprocmask/rt_sigprocmask01.c | 32 +++++++--- .../syscalls/rt_sigsuspend/rt_sigsuspend01.c | 13 ++++- 4 files changed, 132 insertions(+), 37 deletions(-) create mode 100644 include/rt_signal.hinclude/rt_signal.h new file +60
-0@@ -0,0 +1,60 @@ +/******************************************************************************/ +/* */ +/* Copyright (c) 2009 FUJITSU LIMITED */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/* Author: Liu Bo <[email protected]> */ +/* */ +/******************************************************************************/ + +#ifndef __LTP_SIGNAL_H +#define __LTP_SIGNAL_H + +/* We do not globally define the SA_RESTORER flag so do it here. */ +#define HAVE_SA_RESTORER +#define SA_RESTORER 0x04000000 + +struct kernel_sigaction { +__sighandler_t k_sa_handler; +unsigned long sa_flags; +void (*sa_restorer) (void ); +sigset_t sa_mask; +}; + +void (*restore_rt) (void ); + +void +handler_h (void ) +{ +return ; +} + +/* initial restore_rt for x86_64 */ +void +sig_initial (int sig) +{ +struct sigaction act, oact; + + act.sa_handler = (void *)handler_h; +sigemptyset (&act.sa_mask); +sigaddset (&act.sa_mask, sig); +/* copy act.sa_restorer to kernel */ +sigaction (sig, &act, &oact); +/* copy oact.sa_restorer from kernel */ +sigaction (sig, &act, &oact); + restore_rt = oact.sa_restorer; +} +#endif testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +32
-25@@ -55,6 +55,10 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif +/* * For all but __mips__: * @@ -101,13 +105,14 @@ int TST_TOTAL = 1; /* total number of tests in this file. */* On success - Exits calling tst_exit(). With '0' return code. */ /* */ /******************************************************************************/ -extern void cleanup () { -/* Remove tmp dir and all files in it */ -TEST_CLEANUP ; -tst_rmdir (); +extern void cleanup () +{ +/* Remove tmp dir and all files in it */ +TEST_CLEANUP ; +tst_rmdir (); -/* Exit with appropriate return code. */ -tst_exit (); +/* Exit with appropriate return code. */ +tst_exit (); }/* Local Functions */ @@ -128,11 +133,12 @@ extern void cleanup() {/* On success - returns 0. */ /* */ /******************************************************************************/ -void setup () { -/* Capture signals if any */ -/* Create temporary directories */ -TEST_PAUSE ; -tst_tmpdir (); +void setup () +{ +/* Capture signals if any */ +/* Create temporary directories */ +TEST_PAUSE ; +tst_tmpdir (); }int test_flags[] = {SA_RESETHAND |SA_SIGINFO ,SA_RESETHAND ,SA_RESETHAND |SA_SIGINFO ,SA_RESETHAND |SA_SIGINFO ,SA_NOMASK };@@ -144,22 +150,23 @@ handler(int sig)tst_resm (TINFO ,"Signal Handler Called with signal number %d\n" ,sig);return ; } -int -set_handler (int sig,int sig_to_mask,int mask_flags) +set_handler (int sig,int mask_flags) { -struct sigaction sa, oldaction; - - sa.sa_sigaction = (void *)handler; - sa.sa_flags = mask_flags; -sigemptyset (&sa.sa_mask); -sigaddset (&sa.sa_mask, sig_to_mask); -TEST (syscall (__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE )); -if (TEST_RETURN ==0 ) { -return 0 ; - }else { -return TEST_RETURN ; - } +#ifdef __x86_64__ +struct kernel_sigaction sa, oldaction; + mask_flags |=SA_RESTORER ; + sa.sa_restorer = restore_rt; + sa.k_sa_handler = (void *)handler; +#else +struct sigaction sa, oldaction; + sa.sa_handler = (void *)handler; +#endif + sa.sa_flags = mask_flags; +sigemptyset (&sa.sa_mask); +sigaddset (&sa.sa_mask, sig); +TEST (syscall (__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE )); +return TEST_RETURN ; }@@ -182,8 +189,11 @@ int main(int ac, char **av) {for (testno =0 ; testno <TST_TOTAL ; ++testno) {testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c int main(int ac, char **av) { · line 197
Quoted 10 lines
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +5
-2for (signal =SIGRTMIN ; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65 -for (flag=0 ; flag<5 ;flag++) { -TEST (set_handler (signal,0 , test_flags[flag])); +#ifdef __x86_64__ +sig_initial (signal); +#endif +for (flag=0 ; flag<5 ;flag++) { +TEST (set_handler (signal, test_flags[flag]));I know this isn't your code change, but since you're here.. a better way to do this would be:
Quoted 4 lines
sizeof (
test_flags) / sizeof (test_flags[0])as this is a fixed array buffer.
Sure, this can increase codes's portability.
I'm generating a new version patch.
Thanks,
Liubo
Quoted 119 lines
Quoted 119 lines
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +0
-0if (TEST_RETURN ==0 ) {tst_resm (TINFO ,"signal: %d " , signal);tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +23
-9@@ -62,6 +62,12 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + +#define TEST_SIG SIGRTMIN +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */ @@ -131,7 +137,16 @@ void sig_handler(int sig) }int main (int ac,char **av) { -struct sigaction act, oact; +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (TEST_SIG ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else +struct sigaction act, oact; + act.sa_handler = sig_handler; +#endif sigset_t set, oset;int lc;/* loop counter */ char *msg;/* message returned from parse_opts */ @@ -154,22 +169,21 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigaddset (&set,33 )); +TEST (sigaddset (&set,TEST_SIG ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to sigaddset() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();tst_exit (); } - +/* call rt_sigaction() */ - act.sa_handler = sig_handler; -TEST (syscall (__NR_rt_sigaction,33 , &act, &oact,8 )); +TEST (syscall (__NR_rt_sigaction,TEST_SIG , &act, &oact,8 ));if (TEST_RETURN !=0 ){tst_resm (TFAIL ,"Call to rt_sigaction() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();tst_exit (); } -/* call rt_sigprocmask() to block signal#33 */ +/* call rt_sigprocmask() to block signal#SIGRTMIN */ TEST (syscall (__NR_rt_sigprocmask,SIG_BLOCK , &set, &oset,8 ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to rt_sigprocmask()**** Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));@@ -178,7 +192,7 @@ int main(int ac, char **av) { }else { -TEST (kill (getpid (),33 )); +TEST (kill (getpid (),TEST_SIG ));if (TEST_RETURN !=0 ){tst_resm (TFAIL ,"Call to kill() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();@@ -198,13 +212,13 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigismember (&oset,33 )); +TEST (sigismember (&oset,TEST_SIG ));if (TEST_RETURN ==0 ){tst_resm (TFAIL ,"call sigismember() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();tst_exit (); } -/* call rt_sigprocmask() to unblock signal#33 */ +/* call rt_sigprocmask() to unblock signal#SIGRTMIN */ TEST (syscall (__NR_rt_sigprocmask,SIG_UNBLOCK , &set, &oset,8 ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to rt_sigprocmask() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +11
-0@@ -47,6 +47,10 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */ @@ -139,9 +143,16 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (SIGALRM ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else struct sigaction act, oact; act.sa_handler = sig_handler;
Quoted 11 lines
Quoted 8 lines
testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +1
-2- +#endif TEST (syscall (__NR_rt_sigaction,SIGALRM , &act, &oact,8 ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"rt_sigaction() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO )); --1.6.2.2
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 53 lines · liubo
On 02/22/2010 03:56 PM, Garrett Cooper wrote:
By and large this diff looks really good. My comments...
On Sun, Feb 21, 2010 at 9:21 PM, liubo <[email protected]> wrote:
-
rt_sigaction01
On archx86_64, if we directly get to call syscallrt_sigaction, there will be "segment fault".
1) One reason is that we must supply the flag of "SA_RESTORER" and the correct pointer to the fuction "restorer", according to the kernel code.
2) The other reason is that default syscallrt_sigactionuse kernel "sigaction" structure, which is different with normal "sigaction" structure.So,
1) We manage to find the address of the function "restorer" by using glibc function "sigaction", which might be something tricky. Then we add these arguments to make test run correctly.
2) We also use kernel "sigaction" structure to fit realtime syscall__NR_rt_sigaction.-
rt_sigprocmask01
First, there exsits the same problem asrt_sigaction01. Second, this testcase uses a unchanged signal number 33, which may diff among different archs and lead to error "unknown signal".So, we use a macro
TEST_SIGwhich refers to SIGRTMIN to replace 33.The problem is that SIGRTMIN is actually signal 32, not signal 33, and here's a problematic comment to ponder over (from
bits/signum.h):/* These are the hard limits of the kernel. These values should not be
used directly at user level. */
#define__SIGRTMIN32
#define__SIGRTMAX(_NSIG- 1)I think the proper resolution would be to make the value SIGRTMIN+1.
Hi, Garrett,
In fact, I'm confused about whether #33 signal is particularly needed here, in some of my boxes, SIGRTMIN actually refers #34 signal, that is, #33 is unreachable.
Quoted 7 lines
IMO, any realtime reachable signal can be used to pass the case here, and I pick SIGRTMIN by define a macro: #define
TEST_SIGSIGRTMIN.Of course, the value "SIGRTMIN+1" also pass the case, so I'll pick your value.
If you are free, looking forward to your explaination ...
Several signals between the non-RT and non-reserved RT signals are used by [the now defunct] linuxthreads and nptl. See the following page which refers to a very old school copy of LTP :]...:
http://www.redhat.com/archives/phil-list/2003-April/msg00049.html
Quoted 221 lines
-
rt_sigsuspend01
There exists the same problem asrt_sigaction01.This patch fixed these failure.
Signed-off-by Liu Bo <[email protected]>---
include/rt_signal.h | 60
++++++++++++++++++
.../kernel/syscalls/rt_sigaction/rt_sigaction01.c | 64
+++++++++++--------
.../syscalls/rt_sigprocmask/rt_sigprocmask01.c | 32 +++++++---.../syscalls/rt_sigsuspend/rt_sigsuspend01.c| 13 ++++-4 files changed, 132 insertions(+), 37 deletions(-)create mode 100644
include/rt_signal.hinclude/rt_signal.h new file +2
-0@@ -0,0 +1,60 @@ +/******************************************************************************/ +/* */
+/* Copyright (c) 2009 FUJITSU LIMITED
*/
+/*
*/
+/* This program is free software; you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation; either version 2 of the License, or */
+/* (at your option) any later version.
*/
+/*
*/
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
+/* the GNU General Public License for more details.
*/
+/*
*/
+/* You should have received a copy of the GNU General Public License */
+/* along with this program; if not, write to the Free Software */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/*
*/
+/* Author: Liu Bo <[email protected]>
*/
+/*
*/include/rt_signal.h new file +40
-0+/******************************************************************************/ + +#ifndef __LTP_SIGNAL_H +#define __LTP_SIGNAL_H + +/* We do not globally define the SA_RESTORER flag so do it here. */ +#define HAVE_SA_RESTORER +#define SA_RESTORER 0x04000000 + +struct kernel_sigaction { + __sighandler_t k_sa_handler; + unsigned long sa_flags; + void (*sa_restorer) (void); + sigset_t sa_mask; +}; + +void (*restore_rt) (void ); + +void +handler_h (void ) +{ + return; +} + +/* initial restore_rt for x86_64 */ +void +sig_initial (int sig) +{ + struct sigaction act, oact; + + act.sa_handler = (void *)handler_h; + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask, sig); + /* copy act.sa_restorer to kernel */ + sigaction(sig, &act, &oact); + /* copy oact.sa_restorer from kernel */ + sigaction(sig, &act, &oact); + restore_rt = oact.sa_restorer; +} +#endif testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +4
-0@@ -55,6 +55,10 @@ #include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + /** For all but __mips__: * @@ -101,13 +105,14 @@ int TST_TOTAL = 1; /* total numberof tests in this file. *
/* On success - Exits callingtst_exit(). With '0' return code. */
/*
*/ /******************************************************************************/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +7
-6-extern void cleanup () { - /* Remove tmp dir and all files in it */ - TEST_CLEANUP; - tst_rmdir(); +extern void cleanup () +{ + /* Remove tmp dir and all files in it */ + TEST_CLEANUP; + tst_rmdir(); - /* Exit with appropriate return code. */ - tst_exit(); + /* Exit with appropriate return code. */ + tst_exit();}
/* Local Functions */
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +6
-5@@ -128,11 +133,12 @@ extern void cleanup() { /* On success - returns 0. */ /* */ /******************************************************************************/ -void setup () { - /* Capture signals if any */ - /* Create temporary directories */ - TEST_PAUSE; - tst_tmpdir(); +void setup () +{ + /* Capture signals if any */ + /* Create temporary directories */ + TEST_PAUSE; + tst_tmpdir(); }int test_flags[] = {SA_RESETHAND|SA_SIGINFO,
SA_RESETHAND, SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO,SA_NOMASK};testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +0
-1@@ -144,22 +150,23 @@ handler(int sig) tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig); return; } -int
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +1
-1-set_handler(int sig, int sig_to_mask, int mask_flags) +set_handler(int sig, int mask_flags){
- struct sigaction sa, oldaction;
-
- sa.sa_sigaction = (void *)handler;
- sa.sa_flags =mask_flags;
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask,sig_to_mask);
- TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
- if (TEST_RETURN== 0) {
- return 0;
- } else {
- returnTEST_RETURN;
- }testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +14
-0+#ifdef __x86_64__ + struct kernel_sigaction sa, oldaction; + mask_flags |= SA_RESTORER; + sa.sa_restorer = restore_rt; + sa.k_sa_handler = (void *)handler; +#else + struct sigaction sa, oldaction; + sa.sa_handler = (void *)handler; +#endif + sa.sa_flags = mask_flags; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, sig); + TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE)); + return TEST_RETURN;}
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +0
-0@@ -182,8 +189,11 @@ int main(int ac, char **av) { for (testno = 0; testno < TST_TOTAL; ++testno) { for (signal = SIGRTMIN; signal <= (SIGRTMAX );signal++){//signal for 34 to 65
- for(flag=0; flag<5;flag++) {
- TEST(set_handler(signal, 0, test_flags[flag]));testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +5
-0+#ifdef __x86_64__ + sig_initial(signal); +#endif + for(flag=0; flag<5;flag++) { + TEST(set_handler(signal,test_flags[flag]));
I know this isn't your code change, but since you're here.. a better way to do this would be:
Quoted 8 lines
sizeof (
test_flags) / sizeof (test_flags[0])as this is a fixed array buffer.
Sure, this can increase codes's portability.
I'm generating a new version patch.
The less we have to modify code in the future, the better... Cheers!
Quoted 139 lines
if (
TEST_RETURN== 0) {tst_resm(TINFO,"signal: %d ", signal);
tst_resm(TPASS, "rt_sigactioncall succeeded: result = %ld ",TEST_RETURN );testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +6
-0@@ -62,6 +62,12 @@ #include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + +#define TEST_SIG SIGRTMIN + /* Extern Global Variables */extern int
Tst_count; /* counter fortst_xxxroutines. */ extern char *TESTDIR; /* temporary dir created bytst_tmpdir()*/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +10
-1@@ -131,7 +137,16 @@ void sig_handler(int sig) } int main(int ac, char **av) { - struct sigaction act, oact; +#ifdef __x86_64__ + struct kernel_sigaction act, oact; + sig_initial(TEST_SIG); + act.sa_flags |= SA_RESTORER; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else + struct sigaction act, oact; + act.sa_handler = sig_handler; +#endif sigset_t set, oset;int lc; /* loop counter */
char *msg; /* message returned fromparse_opts*/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +4
-5@@ -154,22 +169,21 @@ int main(int ac, char **av) { cleanup(); tst_exit(); } - TEST(sigaddset(&set, 33)); + TEST(sigaddset(&set, TEST_SIG)); if(TEST_RETURN == -1){ tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup(); tst_exit(); } - + /* call rt_sigaction() */ - act.sa_handler = sig_handler; - TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8)); + TEST(syscall(__NR_rt_sigaction, TEST_SIG, &act, &oact,8 )); if(TEST_RETURN != 0){ tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup(); tst_exit(); } - /* call rt_sigprocmask() to block signal#33 */ + /* call rt_sigprocmask() to block signal#SIGRTMIN */
TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, 8));
if(TEST_RETURN == -1){tst_resm(TFAIL,"Call to rt_sigprocmask()**** Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +1
-1@@ -178,7 +192,7 @@ int main(int ac, char **av) { } else { - TEST(kill(getpid(), 33)); + TEST(kill(getpid(), TEST_SIG)); if(TEST_RETURN != 0){ tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));cleanup();
testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +1
-1@@ -198,13 +212,13 @@ int main(int ac, char **av) { cleanup(); tst_exit(); } - TEST(sigismember(&oset, 33)); + TEST(sigismember(&oset, TEST_SIG)); if(TEST_RETURN == 0 ){tst_resm(TFAIL,"call
sigismember()Failed, errno=%d : %s",TEST_ERRNO,strerror(TEST_ERRNO));cleanup();tst_exit();
}
- /* callrt_sigprocmask()to unblock signal#33 */
+ /* callrt_sigprocmask()to unblock signal#SIGRTMIN */
TEST(syscall(__NR_rt_sigprocmask,SIG_UNBLOCK, &set, &oset, 8));
if(TEST_RETURN == -1){tst_resm(TFAIL,"Call to rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +4
-0@@ -47,6 +47,10 @@ #include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + /* Extern Global Variables */extern int
Tst_count; /* counter fortst_xxxroutines. */ extern char *TESTDIR; /* temporary dir created bytst_tmpdir()*/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +8
-1@@ -139,9 +143,16 @@ int main(int ac, char **av) { cleanup(); tst_exit(); } +#ifdef __x86_64__ + struct kernel_sigaction act, oact; + sig_initial(SIGALRM); + act.sa_flags |= SA_RESTORER; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else struct sigaction act, oact; act.sa_handler = sig_handler; - +#endif TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,8 )); if(TEST_RETURN == -1){
Quoted 8 lines
tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO,
strerror(TEST_ERRNO));
--
1.6.2.2
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi, Garrett,
My revised patch has been "Acked/Tested-By: Rishikesh K Rajak<[email protected]>"
url: http://marc.info/?l=ltp-list&m=126683033423523&w=2
Thanks,
Liubo
Quoted 61 lines · Garrett Cooper
Quoted 59 lines · liubo
On 02/22/2010 03:56 PM, Garrett Cooper wrote:
By and large this diff looks really good. My comments...
On Sun, Feb 21, 2010 at 9:21 PM, liubo <[email protected]> wrote:
-
rt_sigaction01
On archx86_64, if we directly get to call syscallrt_sigaction, there will be "segment fault".
1) One reason is that we must supply the flag of "SA_RESTORER" and the correct pointer to the fuction "restorer", according to the kernel code.
2) The other reason is that default syscallrt_sigactionuse kernel "sigaction" structure, which is different with normal "sigaction" structure.So,
1) We manage to find the address of the function "restorer" by using glibc function "sigaction", which might be something tricky. Then we add these arguments to make test run correctly.
2) We also use kernel "sigaction" structure to fit realtime syscall__NR_rt_sigaction.-
rt_sigprocmask01
First, there exsits the same problem asrt_sigaction01. Second, this testcase uses a unchanged signal number 33, which may diff among different archs and lead to error "unknown signal".So, we use a macro
TEST_SIGwhich refers to SIGRTMIN to replace 33.The problem is that SIGRTMIN is actually signal 32, not signal 33, and here's a problematic comment to ponder over (from
bits/signum.h):/* These are the hard limits of the kernel. These values should not be
used directly at user level. */
#define__SIGRTMIN32
#define__SIGRTMAX(_NSIG- 1)I think the proper resolution would be to make the value SIGRTMIN+1.
Hi, Garrett,
In fact, I'm confused about whether #33 signal is particularly needed here, in some of my boxes, SIGRTMIN actually refers #34 signal, that is, #33 is unreachable.
IMO, any realtime reachable signal can be used to pass the case here, and I pick SIGRTMIN by define a macro: #define
TEST_SIGSIGRTMIN.Of course, the value "SIGRTMIN+1" also pass the case, so I'll pick your value.
Quoted 10 lines
Quoted 2 lines
If you are free, looking forward to your explaination ...
Several signals between the non-RT and non-reserved RT signals are used by [the now defunct] linuxthreads and nptl. See the following page which refers to a very old school copy of LTP :]...:
http://www.redhat.com/archives/phil-list/2003-April/msg00049.html
ok , got it.
Quoted 374 lines
Quoted 221 lines
-
rt_sigsuspend01
There exists the same problem asrt_sigaction01.This patch fixed these failure.
Signed-off-by Liu Bo <[email protected]>--- include/rt_signal.h | 60 ++++++++++++++++++ .../kernel/syscalls/rt_sigaction/rt_sigaction01.c | 64 +++++++++++-------- .../syscalls/rt_sigprocmask/rt_sigprocmask01.c | 32 +++++++--- .../syscalls/rt_sigsuspend/rt_sigsuspend01.c | 13 ++++- 4 files changed, 132 insertions(+), 37 deletions(-) create mode 100644 include/rt_signal.hinclude/rt_signal.h new file +60
-0@@ -0,0 +1,60 @@ +/******************************************************************************/ +/* */ +/* Copyright (c) 2009 FUJITSU LIMITED */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/* Author: Liu Bo <[email protected]> */ +/* */ +/******************************************************************************/ + +#ifndef __LTP_SIGNAL_H +#define __LTP_SIGNAL_H + +/* We do not globally define the SA_RESTORER flag so do it here. */ +#define HAVE_SA_RESTORER +#define SA_RESTORER 0x04000000 + +struct kernel_sigaction { +__sighandler_t k_sa_handler; +unsigned long sa_flags; +void (*sa_restorer) (void ); +sigset_t sa_mask; +}; + +void (*restore_rt) (void ); + +void +handler_h (void ) +{ +return ; +} + +/* initial restore_rt for x86_64 */ +void +sig_initial (int sig) +{ +struct sigaction act, oact; + + act.sa_handler = (void *)handler_h; +sigemptyset (&act.sa_mask); +sigaddset (&act.sa_mask, sig); +/* copy act.sa_restorer to kernel */ +sigaction (sig, &act, &oact); +/* copy oact.sa_restorer from kernel */ +sigaction (sig, &act, &oact); + restore_rt = oact.sa_restorer; +} +#endif testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +4
-0@@ -55,6 +55,10 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif +/* * For all but __mips__: * @@ -101,13 +105,14 @@ int TST_TOTAL = 1; /* total numberof tests in this file. *
/* On success - Exits callingtst_exit(). With '0' return
code. */
/*
*/
/******************************************************************************/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +13
-11-extern void cleanup () { -/* Remove tmp dir and all files in it */ -TEST_CLEANUP ; -tst_rmdir (); +extern void cleanup () +{ +/* Remove tmp dir and all files in it */ +TEST_CLEANUP ; +tst_rmdir (); -/* Exit with appropriate return code. */ -tst_exit (); +/* Exit with appropriate return code. */ +tst_exit (); }/* Local Functions */ @@ -128,11 +133,12 @@ extern void cleanup() {/* On success - returns 0. */ /* */ /******************************************************************************/ -void setup () { -/* Capture signals if any */ -/* Create temporary directories */ -TEST_PAUSE ; -tst_tmpdir (); +void setup () +{ +/* Capture signals if any */ +/* Create temporary directories */ +TEST_PAUSE ; +tst_tmpdir (); }int test_flags[] = {SA_RESETHAND|SA_SIGINFO,
SA_RESETHAND,
SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO,SA_NOMASK};testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +15
-14@@ -144,22 +150,23 @@ handler(int sig)tst_resm (TINFO ,"Signal Handler Called with signal number %d\n" ,sig);return ; } -int -set_handler (int sig,int sig_to_mask,int mask_flags) +set_handler (int sig,int mask_flags) { -struct sigaction sa, oldaction; - - sa.sa_sigaction = (void *)handler; - sa.sa_flags = mask_flags; -sigemptyset (&sa.sa_mask); -sigaddset (&sa.sa_mask, sig_to_mask); -TEST (syscall (__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE)); -if (TEST_RETURN ==0 ) { -return 0 ; - }else { -return TEST_RETURN ; - } +#ifdef __x86_64__ +struct kernel_sigaction sa, oldaction; + mask_flags |=SA_RESTORER ; + sa.sa_restorer = restore_rt; + sa.k_sa_handler = (void *)handler; +#else +struct sigaction sa, oldaction; + sa.sa_handler = (void *)handler; +#endif + sa.sa_flags = mask_flags; +sigemptyset (&sa.sa_mask); +sigaddset (&sa.sa_mask, sig); +TEST (syscall (__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE )); +return TEST_RETURN ; }@@ -182,8 +189,11 @@ int main(int ac, char **av) {for (testno =0 ; testno <TST_TOTAL ; ++testno) { for (signal = SIGRTMIN; signal <= (SIGRTMAX );signal++){//signal for 34 to 65
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +0
-2-for (flag=0 ; flag<5 ;flag++) { - TEST(set_handler(signal, 0,test_flags[flag]));
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +5
-0+#ifdef __x86_64__ +sig_initial (signal); +#endif +for (flag=0 ; flag<5 ;flag++) { + TEST(set_handler(signal,test_flags[flag]));
I know this isn't your code change, but since you're here.. a better way to do this would be:
Quoted 9 lines
sizeof (
test_flags) / sizeof (test_flags[0])as this is a fixed array buffer.
Sure, this can increase codes's portability.
I'm generating a new version patch.
The less we have to modify code in the future, the better... Cheers!
Quoted 140 lines
if (TEST_RETURN == 0) { tst_resm(TINFO,"signal: %d ",signal);
tst_resm(TPASS, "rt_sigaction
call succeeded: result = %ld ",TEST_RETURN );testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +20
-6@@ -62,6 +62,12 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + +#define TEST_SIG SIGRTMIN +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */ @@ -131,7 +137,16 @@ void sig_handler(int sig) }int main (int ac,char **av) { -struct sigaction act, oact; +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (TEST_SIG ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else +struct sigaction act, oact; + act.sa_handler = sig_handler; +#endif sigset_t set, oset;int lc;/* loop counter */ char *msg;/* message returned from parse_opts */ @@ -154,22 +169,21 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigaddset (&set,33 )); +TEST (sigaddset (&set,TEST_SIG ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));cleanup ();tst_exit (); } - +/* call rt_sigaction() */ - act.sa_handler = sig_handler; -TEST (syscall (__NR_rt_sigaction,33 , &act, &oact, 8)); +TEST (syscall (__NR_rt_sigaction,TEST_SIG , &act, &oact,8 ));if (TEST_RETURN !=0 ){ tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup();tst_exit (); } -/* call rt_sigprocmask() to block signal#33 */ +/* call rt_sigprocmask() to block signal#SIGRTMIN */ TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set,&oset, 8));
if(TEST_RETURN == -1){
tst_resm(TFAIL,"Call to rt_sigprocmask()****
Failed, errno=%d : %s",TEST_ERRNO,strerror(TEST_ERRNO));testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +1
-1@@ -178,7 +192,7 @@ int main(int ac, char **av) { } else { - TEST(kill(getpid(), 33)); +TEST (kill (getpid (),TEST_SIG )); if(TEST_RETURN != 0){ tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));cleanup();testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +1
-2@@ -198,13 +212,13 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigismember (&oset,33 )); +TEST (sigismember (&oset,TEST_SIG ));if (TEST_RETURN ==0 ){ tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup();tst_exit (); } -/* call rt_sigprocmask() to unblock signal#33 */
+ /* callrt_sigprocmask()to unblock
signal#SIGRTMIN */
TEST(syscall(__NR_rt_sigprocmask,SIG_UNBLOCK, &set, &oset, 8)); if(TEST_RETURN == -1){ tst_resm(TFAIL,"Call to
rt_sigprocmask()Failed, errno=%d : %s",TEST_ERRNO,strerror(TEST_ERRNO));testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +12
-1@@ -47,6 +47,10 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */ @@ -139,9 +143,16 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (SIGALRM ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else struct sigaction act, oact; act.sa_handler = sig_handler; - +#endif TEST (syscall (__NR_rt_sigaction,SIGALRM , &act, &oact,8 ));if (TEST_RETURN ==-1 ){tst_resm(TFAIL,"rt_sigaction() Failed,
Quoted 11 lines
Quoted 8 lines
errno=%d : %s",TEST_ERRNO,
strerror(TEST_ERRNO));
--
1.6.2.2
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi Garrett,
I figured that this patch has not been merged into ltp-cvs. Is there some else problems about this patch?
Thanks,
Liubo
Quoted 486 lines · liubo
Hi, Garrett,
My revised patch has been "Acked/Tested-By: Rishikesh K Rajak<[email protected]>"url: http://marc.info/?l=ltp-list&m=126683033423523&w=2
Thanks,
LiuboQuoted 62 lines · Garrett Cooper
Quoted 59 lines · liubo
On 02/22/2010 03:56 PM, Garrett Cooper wrote:
By and large this diff looks really good. My comments...
On Sun, Feb 21, 2010 at 9:21 PM, liubo <[email protected]> wrote:
-
rt_sigaction01
On archx86_64, if we directly get to call syscallrt_sigaction, there will be "segment fault".
1) One reason is that we must supply the flag of "SA_RESTORER" and the correct pointer to the fuction "restorer", according to the kernel code.
2) The other reason is that default syscallrt_sigactionuse kernel "sigaction" structure, which is different with normal "sigaction" structure.So,
1) We manage to find the address of the function "restorer" by using glibc function "sigaction", which might be something tricky. Then we add these arguments to make test run correctly.
2) We also use kernel "sigaction" structure to fit realtime syscall__NR_rt_sigaction.-
rt_sigprocmask01
First, there exsits the same problem asrt_sigaction01. Second, this testcase uses a unchanged signal number 33, which may diff among different archs and lead to error "unknown signal".So, we use a macro
TEST_SIGwhich refers to SIGRTMIN to replace 33.The problem is that SIGRTMIN is actually signal 32, not signal 33, and here's a problematic comment to ponder over (from
bits/signum.h):/* These are the hard limits of the kernel. These values should not be
used directly at user level. */
#define__SIGRTMIN32
#define__SIGRTMAX(_NSIG- 1)I think the proper resolution would be to make the value SIGRTMIN+1.
Hi, Garrett,
In fact, I'm confused about whether #33 signal is particularly needed here, in some of my boxes, SIGRTMIN actually refers #34 signal, that is, #33 is unreachable.
IMO, any realtime reachable signal can be used to pass the case here, and I pick SIGRTMIN by define a macro: #define
TEST_SIGSIGRTMIN.Of course, the value "SIGRTMIN+1" also pass the case, so I'll pick your value.
Quoted 11 lines
Quoted 3 lines
If you are free, looking forward to your explaination ...
Several signals between the non-RT and non-reserved RT signals are used by [the now defunct] linuxthreads and nptl. See the following page which refers to a very old school copy of LTP :]...:
http://www.redhat.com/archives/phil-list/2003-April/msg00049.html
ok , got it.
Quoted 376 lines
Quoted 221 lines
-
rt_sigsuspend01
There exists the same problem asrt_sigaction01.This patch fixed these failure.
Signed-off-by Liu Bo <[email protected]>--- include/rt_signal.h | 60 ++++++++++++++++++ .../kernel/syscalls/rt_sigaction/rt_sigaction01.c | 64 +++++++++++-------- .../syscalls/rt_sigprocmask/rt_sigprocmask01.c | 32 +++++++--- .../syscalls/rt_sigsuspend/rt_sigsuspend01.c | 13 ++++- 4 files changed, 132 insertions(+), 37 deletions(-) create mode 100644 include/rt_signal.hinclude/rt_signal.h new file +60
-0@@ -0,0 +1,60 @@ +/******************************************************************************/ +/* */ +/* Copyright (c) 2009 FUJITSU LIMITED */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/* Author: Liu Bo <[email protected]> */ +/* */ +/******************************************************************************/ + +#ifndef __LTP_SIGNAL_H +#define __LTP_SIGNAL_H + +/* We do not globally define the SA_RESTORER flag so do it here. */ +#define HAVE_SA_RESTORER +#define SA_RESTORER 0x04000000 + +struct kernel_sigaction { +__sighandler_t k_sa_handler; +unsigned long sa_flags; +void (*sa_restorer) (void ); +sigset_t sa_mask; +}; + +void (*restore_rt) (void ); + +void +handler_h (void ) +{ +return ; +} + +/* initial restore_rt for x86_64 */ +void +sig_initial (int sig) +{ +struct sigaction act, oact; + + act.sa_handler = (void *)handler_h; +sigemptyset (&act.sa_mask); +sigaddset (&act.sa_mask, sig); +/* copy act.sa_restorer to kernel */ +sigaction (sig, &act, &oact); +/* copy oact.sa_restorer from kernel */ +sigaction (sig, &act, &oact); + restore_rt = oact.sa_restorer; +} +#endif testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +4
-0@@ -55,6 +55,10 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif +/* * For all but __mips__: * @@ -101,13 +105,14 @@ int TST_TOTAL = 1; /* total numberof tests in this file. *
/* On success - Exits callingtst_exit(). With '0' return
code. */
/*
*/
/******************************************************************************/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +13
-11-extern void cleanup () { -/* Remove tmp dir and all files in it */ -TEST_CLEANUP ; -tst_rmdir (); +extern void cleanup () +{ +/* Remove tmp dir and all files in it */ +TEST_CLEANUP ; +tst_rmdir (); -/* Exit with appropriate return code. */ -tst_exit (); +/* Exit with appropriate return code. */ +tst_exit (); }/* Local Functions */ @@ -128,11 +133,12 @@ extern void cleanup() {/* On success - returns 0. */ /* */ /******************************************************************************/ -void setup () { -/* Capture signals if any */ -/* Create temporary directories */ -TEST_PAUSE ; -tst_tmpdir (); +void setup () +{ +/* Capture signals if any */ +/* Create temporary directories */ +TEST_PAUSE ; +tst_tmpdir (); }int test_flags[] = {SA_RESETHAND|SA_SIGINFO,
SA_RESETHAND,
SA_RESETHAND|SA_SIGINFO, SA_RESETHAND|SA_SIGINFO,SA_NOMASK};testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +15
-14@@ -144,22 +150,23 @@ handler(int sig)tst_resm (TINFO ,"Signal Handler Called with signal number %d\n" ,sig);return ; } -int -set_handler (int sig,int sig_to_mask,int mask_flags) +set_handler (int sig,int mask_flags) { -struct sigaction sa, oldaction; - - sa.sa_sigaction = (void *)handler; - sa.sa_flags = mask_flags; -sigemptyset (&sa.sa_mask); -sigaddset (&sa.sa_mask, sig_to_mask); -TEST (syscall (__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE)); -if (TEST_RETURN ==0 ) { -return 0 ; - }else { -return TEST_RETURN ; - } +#ifdef __x86_64__ +struct kernel_sigaction sa, oldaction; + mask_flags |=SA_RESTORER ; + sa.sa_restorer = restore_rt; + sa.k_sa_handler = (void *)handler; +#else +struct sigaction sa, oldaction; + sa.sa_handler = (void *)handler; +#endif + sa.sa_flags = mask_flags; +sigemptyset (&sa.sa_mask); +sigaddset (&sa.sa_mask, sig); +TEST (syscall (__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE )); +return TEST_RETURN ; }@@ -182,8 +189,11 @@ int main(int ac, char **av) {for (testno =0 ; testno <TST_TOTAL ; ++testno) { for (signal = SIGRTMIN; signal <= (SIGRTMAX );signal++){//signal for 34 to 65
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +0
-2-for (flag=0 ; flag<5 ;flag++) { - TEST(set_handler(signal, 0,test_flags[flag]));
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +5
-0+#ifdef __x86_64__ +sig_initial (signal); +#endif +for (flag=0 ; flag<5 ;flag++) { + TEST(set_handler(signal,test_flags[flag]));
I know this isn't your code change, but since you're here.. a better way to do this would be:
Quoted 10 lines
sizeof (
test_flags) / sizeof (test_flags[0])as this is a fixed array buffer.
Sure, this can increase codes's portability.
I'm generating a new version patch.
The less we have to modify code in the future, the better... Cheers!
Quoted 141 lines
if (TEST_RETURN == 0) { tst_resm(TINFO,"signal: %d ",signal);
tst_resm(TPASS, "rt_sigaction
call succeeded: result = %ld ",TEST_RETURN );testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +20
-6@@ -62,6 +62,12 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + +#define TEST_SIG SIGRTMIN +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */ @@ -131,7 +137,16 @@ void sig_handler(int sig) }int main (int ac,char **av) { -struct sigaction act, oact; +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (TEST_SIG ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else +struct sigaction act, oact; + act.sa_handler = sig_handler; +#endif sigset_t set, oset;int lc;/* loop counter */ char *msg;/* message returned from parse_opts */ @@ -154,22 +169,21 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigaddset (&set,33 )); +TEST (sigaddset (&set,TEST_SIG ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));cleanup ();tst_exit (); } - +/* call rt_sigaction() */ - act.sa_handler = sig_handler; -TEST (syscall (__NR_rt_sigaction,33 , &act, &oact, 8)); +TEST (syscall (__NR_rt_sigaction,TEST_SIG , &act, &oact,8 ));if (TEST_RETURN !=0 ){ tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup();tst_exit (); } -/* call rt_sigprocmask() to block signal#33 */ +/* call rt_sigprocmask() to block signal#SIGRTMIN */ TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set,&oset, 8));
if(TEST_RETURN == -1){
tst_resm(TFAIL,"Call to rt_sigprocmask()****
Failed, errno=%d : %s",TEST_ERRNO,strerror(TEST_ERRNO));testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +1
-1@@ -178,7 +192,7 @@ int main(int ac, char **av) { } else { - TEST(kill(getpid(), 33)); +TEST (kill (getpid (),TEST_SIG )); if(TEST_RETURN != 0){ tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));cleanup();testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +1
-2@@ -198,13 +212,13 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigismember (&oset,33 )); +TEST (sigismember (&oset,TEST_SIG ));if (TEST_RETURN ==0 ){ tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO)); cleanup();tst_exit (); } -/* call rt_sigprocmask() to unblock signal#33 */
+ /* callrt_sigprocmask()to unblock
signal#SIGRTMIN */
TEST(syscall(__NR_rt_sigprocmask,SIG_UNBLOCK, &set, &oset, 8)); if(TEST_RETURN == -1){ tst_resm(TFAIL,"Call to
rt_sigprocmask()Failed, errno=%d : %s",TEST_ERRNO,strerror(TEST_ERRNO));testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +12
-1@@ -47,6 +47,10 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */ @@ -139,9 +143,16 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (SIGALRM ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else struct sigaction act, oact; act.sa_handler = sig_handler; - +#endif TEST (syscall (__NR_rt_sigaction,SIGALRM , &act, &oact,8 ));if (TEST_RETURN ==-1 ){tst_resm(TFAIL,"rt_sigaction() Failed,
errno=%d : %s",TEST_ERRNO,strerror(TEST_ERRNO));Quoted 10 lines
Quoted 8 lines
--
1.6.2.2------------------------------------------------------------------------
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
------------------------------------------------------------------------
Quoted 5 lines
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 7 lines · liubo
Hi Garrett,
I figured that this patch has not been merged into ltp-cvs. Is there some else problems about this patch?
Thanks,
Liubo
I tried looking at it this weekend and got sidetracked (hint:
please provide me with a complete patchable diff, preferably as a file attachment).
Thanks!
-Garrett
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 11 lines · Garrett Cooper
Quoted 8 lines · liubo
Hi Garrett,
I figured that this patch has not been merged into ltp-cvs. Is there some else problems about this patch?
Thanks,
Liubo
Quoted 8 lines
I tried looking at it this weekend and got sidetracked (hint:
please provide me with a complete patchable diff, preferably as a file attachment).
Thanks!
-Garrett
Sure, see attachment.
Thanks,
Liubo
From 4c61e30a2006726346550d8627465e1b2e4050cf Mon Sep 17 00:00:00 2001
From: mapleapple <[email protected]>
Date: Mon, 22 Feb 2010 17:12:29 +0800
Subject: [PATCH] rt_sig
--- include/rt_signal.h | 60 +++++++++++++++++ .../kernel/syscalls/rt_sigaction/rt_sigaction01.c | 69 ++++++++++++-------- .../syscalls/rt_sigprocmask/rt_sigprocmask01.c | 32 +++++++--- .../syscalls/rt_sigsuspend/rt_sigsuspend01.c | 13 ++++- 4 files changed, 136 insertions(+), 38 deletions(-) create mode 100644 include/rt_signal.h
include/rt_signal.h new file +60 -0
@@ -0,0 +1,60 @@ +/******************************************************************************/ +/* */ +/* Copyright (c) 2009 FUJITSU LIMITED */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/* Author: Liu Bo <[email protected]> */ +/* */ +/******************************************************************************/ + +#ifndef __LTP_SIGNAL_H +#define __LTP_SIGNAL_H + +/* We do not globally define the SA_RESTORER flag so do it here. */ +#define HAVE_SA_RESTORER +#define SA_RESTORER 0x04000000 + +struct kernel_sigaction { +__sighandler_t k_sa_handler; +unsigned long sa_flags; +void (*sa_restorer) (void ); +sigset_t sa_mask; +}; + +void (*restore_rt) (void ); + +void +handler_h (void ) +{ +return ; +} + +/* initial restore_rt for x86_64 */ +void +sig_initial (int sig) +{ +struct sigaction act, oact; + + act.sa_handler = (void *)handler_h; +sigemptyset (&act.sa_mask); +sigaddset (&act.sa_mask, sig); +/* copy act.sa_restorer to kernel */ +sigaction (sig, &act, &oact); +/* copy oact.sa_restorer from kernel */ +sigaction (sig, &act, &oact); + restore_rt = oact.sa_restorer; +} +#endif
testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c +41 -28
110 lines not on this page · raw message
testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c +23 -9
@@ -62,6 +62,12 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif + +#define TEST_SIG SIGRTMIN+1 +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */
@@ -131,7 +137,16 @@ void sig_handler(int sig) }int main (int ac,char **av) { -struct sigaction act, oact; +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (TEST_SIG ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else +struct sigaction act, oact; + act.sa_handler = sig_handler; +#endif sigset_t set, oset;int lc;/* loop counter */ char *msg;/* message returned from parse_opts */
@@ -154,22 +169,21 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigaddset (&set,33 )); +TEST (sigaddset (&set,TEST_SIG ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to sigaddset() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();tst_exit (); } - +/* call rt_sigaction() */ - act.sa_handler = sig_handler; -TEST (syscall (__NR_rt_sigaction,33 , &act, &oact,8 )); +TEST (syscall (__NR_rt_sigaction,TEST_SIG , &act, &oact,8 ));if (TEST_RETURN !=0 ){tst_resm (TFAIL ,"Call to rt_sigaction() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();tst_exit (); } -/* call rt_sigprocmask() to block signal#33 */ +/* call rt_sigprocmask() to block signal#SIGRTMIN */ TEST (syscall (__NR_rt_sigprocmask,SIG_BLOCK , &set, &oset,8 ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to rt_sigprocmask()**** Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));
@@ -178,7 +192,7 @@ int main(int ac, char **av) { }else { -TEST (kill (getpid (),33 )); +TEST (kill (getpid (),TEST_SIG ));if (TEST_RETURN !=0 ){tst_resm (TFAIL ,"Call to kill() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();
@@ -198,13 +212,13 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } -TEST (sigismember (&oset,33 )); +TEST (sigismember (&oset,TEST_SIG ));if (TEST_RETURN ==0 ){tst_resm (TFAIL ,"call sigismember() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));cleanup ();tst_exit (); } -/* call rt_sigprocmask() to unblock signal#33 */ +/* call rt_sigprocmask() to unblock signal#SIGRTMIN */ TEST (syscall (__NR_rt_sigprocmask,SIG_UNBLOCK , &set, &oset,8 ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"Call to rt_sigprocmask() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));
testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +12 -1
@@ -47,6 +47,10 @@#include "usctest.h" #include "linux_syscall_numbers.h" +#ifdef __x86_64__ +#include "rt_signal.h" +#endif +/* Extern Global Variables */ extern int Tst_count;/* counter for tst_xxx routines. */ extern char *TESTDIR ;/* temporary dir created by tst_tmpdir() */
@@ -139,9 +143,16 @@ int main(int ac, char **av) {cleanup ();tst_exit (); } +#ifdef __x86_64__ +struct kernel_sigaction act, oact; +sig_initial (SIGALRM ); + act.sa_flags |=SA_RESTORER ; + act.sa_restorer = restore_rt; + act.k_sa_handler = sig_handler; +#else struct sigaction act, oact; act.sa_handler = sig_handler; - +#endif TEST (syscall (__NR_rt_sigaction,SIGALRM , &act, &oact,8 ));if (TEST_RETURN ==-1 ){tst_resm (TFAIL ,"rt_sigaction() Failed, errno=%d : %s" ,TEST_ERRNO ,strerror (TEST_ERRNO ));
Signature · 1 line
1.6.2.2
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 7 lines · liubo
On 02/25/2010 06:00 PM, Garrett Cooper wrote:
On Wed, Feb 24, 2010 at 11:26 PM, liubo <[email protected]> wrote:
Hi Garrett,
Quoted 8 lines
I figured that this patch has not been merged into ltp-cvs. Is there some else problems about this patch?
I tried looking at it this weekend and got sidetracked (hint:
please provide me with a complete patchable diff, preferably as a file attachment).Sure, see attachment.
All of these fixes have been merged into mainline ltp-dev.git.
Thank you very much for the help in tackling this issue! Cheers,
-Garrett
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list