All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls: fix some failure on arch X86_64
@ 2009-11-10  9:38 liubo
  2009-11-11  1:28 ` liubo
  2009-11-11  4:33 ` Mike Frysinger
  0 siblings, 2 replies; 34+ messages in thread
From: liubo @ 2009-11-10  9:38 UTC (permalink / raw)
  To: ltp-list

1) rt_sigaction
    "sigaction" has the structure:
 
 struct sigaction {
         __sighandler_t sa_handler;
         unsigned long sa_flags;
  #ifdef SA_RESTORER
          __sigrestore_t sa_restorer;
  #endif
          sigset_t sa_mask;               /* mask last for extensibility */
 };

    However, on arch x86_64, if we directly get to call rt_sigaction,
the argument "sa_restorer" will not be fulfilled, and this will lead
 to segment fault.
    on arch x86_64, if sa_restorer is not set, kernel will lead to segment fault. 
In other arch, if sa_restorer is not set, kernel can do the correct work.
    To avoid this segment fault, we use glibc function
"int sigaction(...);" instead, which can fulfill the argument "sa_restorer".

2) rt_sigprocmask
    This failure contains two aspects,
the first is the segment fault as described in 1),
the second is that testcase uses a unknown signal 33 for test,
and this will lead sigaction cannot bind signal 33 to the action.

    So, we attempt to use a known signal instead, such as 34.

This patch fixed these failures.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>

---
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |    4 ++++
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   12 ++++++++----
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |    4 ++++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index 27af970..1522ac4 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -154,7 +154,11 @@ set_handler(int sig, int sig_to_mask, int mask_flags)
                 sa.sa_flags = mask_flags;
                 sigemptyset(&sa.sa_mask);
                 sigaddset(&sa.sa_mask, sig_to_mask);
+		#ifndef __x86_64__
                 TEST(syscall(__NR_rt_sigaction,sig, &sa, &oldaction,SIGSETSIZE));
+		#else
+		TEST(sigaction(sig, &sa, &oldaction));
+		#endif
         if (TEST_RETURN == 0) {
                 return 0;
         } else {
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 6398a28..31258e9 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -154,7 +154,7 @@ int main(int ac, char **av) {
                         	cleanup();
 				tst_exit();
 			}
-			TEST(sigaddset(&set, 33));
+			TEST(sigaddset(&set, 34));
 			if(TEST_RETURN == -1){
 				tst_resm(TFAIL,"Call to sigaddset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
@@ -163,7 +163,11 @@ int main(int ac, char **av) {
 			
 			/* call rt_sigaction() */
 			act.sa_handler = sig_handler;
-                        TEST(syscall(__NR_rt_sigaction, 33, &act, &oact, 8));
+			#ifndef __x86_64__
+                        TEST(syscall(__NR_rt_sigaction, 34, &act, &oact, 8));
+			#else
+			TEST(sigaction(34, &act, &oact));
+			#endif
 			if(TEST_RETURN != 0){
 				tst_resm(TFAIL,"Call to rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         	cleanup();
@@ -178,7 +182,7 @@ int main(int ac, char **av) {
 			}
 			
 			else {
-				TEST(kill(getpid(), 33));
+				TEST(kill(getpid(), 34));
 				if(TEST_RETURN != 0){
 					tst_resm(TFAIL,"Call to kill() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         		cleanup();
@@ -198,7 +202,7 @@ int main(int ac, char **av) {
                         			cleanup();
 						tst_exit();
 					}
-					TEST(sigismember(&oset, 33));
+					TEST(sigismember(&oset, 34));
 					if(TEST_RETURN == 0 ){
 						tst_resm(TFAIL,"call sigismember() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
                         			cleanup();
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 416a7c9..6132622 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -142,7 +142,11 @@ int main(int ac, char **av) {
 			struct sigaction act, oact;
 		        act.sa_handler = sig_handler;
 			
+			#ifndef __x86_64__
 			TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, 8));
+			#else
+			TEST(sigaction(SIGALRM, &act, &oact));
+			#endif
 			if(TEST_RETURN == -1){
 		        	tst_resm(TFAIL,"rt_sigaction() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
 				cleanup();
-- 
1.6.2.2

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 34+ messages in thread
* [LTP] [PATCH] syscalls: fix some failure on arch X86_64
@ 2009-12-09  7:34 liubo
  2009-12-09 12:14 ` Subrata Modak
  2009-12-18 16:03 ` Subrata Modak
  0 siblings, 2 replies; 34+ messages in thread
From: liubo @ 2009-12-09  7:34 UTC (permalink / raw)
  To: ltp-list

Here is the patch, which contains lots of adjustments 
on style, so it might be a bit huge.

Testcase 1. 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.

Testcase 2. 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.

Testcase 3. rt_sigsuspend01
There exists the same problem as rt_sigaction01.

This patch fixed these failure.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>

---
 include/ltp_signal.h                               |  152 --------
 include/rt_signal.h                                |   60 ++++
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |  364 +++++++++-----------
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |  331 ++++++++++--------
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |  168 +++++----
 5 files changed, 499 insertions(+), 576 deletions(-)
 delete mode 100644 include/ltp_signal.h
 create mode 100644 include/rt_signal.h

diff --git a/include/ltp_signal.h b/include/ltp_signal.h
deleted file mode 100644
index 5e9a198..0000000
--- a/include/ltp_signal.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2009 Cisco Systems, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- */
-
-#ifndef __LTP_SIGNAL_H
-#define __LTP_SIGNAL_H
-
-#include <errno.h>
-#include <signal.h>
-#include <stdio.h>
-#include "config.h"
-
-#define SIGSETSIZE (_NSIG / 8)
-
-#ifdef LTP_RT_SIG_TEST
-
-extern int  expected_signal_number;
-
-#if defined(__x86_64__)
-
-/*
- * From asm/signal.h -- this value isn't exported anywhere outside of glibc and
- * asm/signal.h and is only required for the rt_sig* function family because
- * sigaction(2), et all, appends this if necessary to
- * (struct sigaction).sa_flags. HEH.
- *
- * I do #undef though, just in case...
- */
-#undef SA_RESTORER
-#define SA_RESTORER	0x04000000
-
-/* 
- * From .../arch/x86/kernel/signal.c:448 --
- *
- * x86-64 should always use SA_RESTORER.
- *
- * -- thus SA_RESTORER must always be defined along with
- * (struct sigaction).sa_restorer.
- */
-#define ARCH_SPECIFIC_RT_SIGACTION_SETUP(__sa) __sa.sa_flags |= SA_RESTORER; __sa.sa_restorer = dummy_restorer;
-/* defined(__x86_64) */
-#else
-#define ARCH_SPECIFIC_RT_SIGACTION_SETUP(__sa)
-#endif
-
-/*
- * To help direct sigsegv_sigaction_handler in determining whether or not the
- * segfault was valid.
- */
-extern int  expected_signal_number;
-
-/* 
- * A dummy sa_restorer function, because we have to have it if SA_RESTORER is
- * required.
- */
-inline void
-dummy_restorer(void) {
-	tst_resm(TINFO, "%s called", __func__);
-}
-
-/* 
- * SIGSEGV will be thrown if an overflow occurs, or some other undesired
- * precondition. Let's catch it so the test will at least proceed and not
- * completely bomb the heck out.
- */
-inline void
-sigsegv_sigaction_handler(int signum, siginfo_t *siginfo, void *ucontext) {
-
-	/*
-	 * Backwards compatibility is a pain; I think that's what's driving
-	 * the implicit sa_restorer BS on x86_64, and the reason why mips* and
-	 * ppc* only has a sigaction handler (not rt_sigaction).
-	 *
-	 * GG for backwards compatibility and lack of documentation on an
-	 * internal syscall...
-	 */
-#ifdef __x86_64__
-	if (expected_signal_number == SIGRTMIN) {
-		tst_resm(TINFO, "SIGRTMIN segfaults on x86_64 (known issue).");
-	} else {
-#endif
-	tst_brkm(TBROK | TERRNO, NULL,
-		"Uncaught SIGSEGV; please validate whether or not test meets "
-		"functional requirements as per do_signal and callees in "
-		"$KERN_SRC/arch/<arch>/kernel/signal.c is concerned");
-
-#ifdef __x86_64__
-	}
-#endif
-}
-
-/* 
- * Catch SIGSEGV just in case one of the rt_sigaction calls tosses up a SIGSEGV
- * at the kernel level because of an -EFAULT was tossed by a caller. What a
- * PITA :].
- */
-inline int
-setup_sigsegv_sigaction_handler()
-{
-	int rc = -1;
-	struct sigaction sa;
-	sigset_t sigset;
-
-	/* 
-	 * Catch SIGSEGV just in case one of the rt_sigaction calls tosses up a
-	 * SIGSEGV at the kernel level because of an -EFAULT was tossed by a
-	 * caller. What a PITA :].
-	 */
-	sa.sa_sigaction = (void *)sigsegv_sigaction_handler;
-	/* We want the handler to persist, so don't do SA_RESETHAND... */
-	sa.sa_flags = SA_SIGINFO;
-
-	if (sigemptyset(&sa.sa_mask) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			"Failed to call sigemptyset for SIGSEGV");
-	} else if (sigaddset(&sigset, SIGSEGV) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			"Failed to do sigaddset for SIGSEGV");
-	} else if (sigaction(SIGSEGV, &sa, (struct sigaction *) NULL) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			"Failed to setup sighandler for SIGSEGV");
-	} else {
-		rc = 0;
-	}
-
-	return rc;
-
-}
-
-#endif /* RT_SIG_TEST */
-
-#endif
diff --git a/include/rt_signal.h b/include/rt_signal.h
new file mode 100644
index 0000000..be64deb
--- /dev/null
+++ b/include/rt_signal.h
@@ -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 <liubo2009@cn.fujitsu.com>                                  */
+/*                                                                            */
+/******************************************************************************/
+
+#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;
+}
+
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index 6e937d2..d30f204 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -1,266 +1,216 @@
 /******************************************************************************/
-/* Copyright (c) Crackerjack Project., 2007				   */
-/*									    */
+/* Copyright (c) Crackerjack Project., 2007                                   */
+/*                                                                            */
 /* 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	       */
+/* 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    */
-/*									    */
+/*                                                                            */
 /******************************************************************************/
 /******************************************************************************/
-/*									    */
-/* File:	rt_sigaction01.c					      */
-/*									    */
-/* Description: This tests the rt_sigaction() syscall			 */
+/*                                                                            */
+/* File:        rt_sigaction01.c                                              */
+/*                                                                            */
+/* Description: This tests the rt_sigaction() syscall                         */
 /*		rt_sigaction alters an action taken by a process on receipt   */
-/* 		of a particular signal. The action is specified by the	*/
+/* 		of a particular signal. The action is specified by the        */
 /*		sigaction structure. The previous action on the signal is     */
-/*		saved in oact.sigsetsize should indicate the size of a	*/
-/*		sigset_t type.		       			      */
-/*									    */
-/* Usage:  <for command-line>						 */
-/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]			*/
-/*      where,  -c n : Run n copies concurrently.			     */
-/*	      -e   : Turn on errno logging.				 */
-/*	      -i n : Execute test n times.				  */
-/*	      -I x : Execute test for x seconds.			    */
-/*	      -P x : Pause for x seconds between iterations.		*/
-/*	      -t   : Turn on syscall timing.				*/
-/*									    */
-/* Total Tests: 1							     */
-/*									    */
-/* Test Name:   rt_sigaction01					     */
-/* History:     Porting from Crackerjack to LTP is done by		    */
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>			*/
+/*		saved in oact.sigsetsize should indicate the size of a        */
+/*		sigset_t type.                       			      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   rt_sigaction01                                             */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <signal.h>
 #include <errno.h>
-#include <sys/types.h>
+#include <sys/syscall.h>
 #include <string.h>
-#include "config.h"
 
 /* Harness Specific Include Files. */
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
-#define LTP_RT_SIG_TEST
-#include "ltp_signal.h"
+
+#ifdef __x86_64__
+#include "rt_signal.h"
+#endif
+
+/*
+ * For all but __mips__:
+ *
+ * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 2.
+ *
+ * For __mips__:
+ *
+ * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 4.
+ *
+ * See asm/compat.h under the kernel source for more details.
+ *
+ * Multiply that by a fudge factor of 4 and you have your SIGSETSIZE.
+ */
+#if defined (__mips__)
+#define SIGSETSIZE 16
+#else
+#define SIGSETSIZE 8
+#endif
 
 /* Extern Global Variables */
-extern int Tst_count;	   /* counter for tst_xxx routines.	 */
-extern char *TESTDIR;	   /* temporary dir created by tst_tmpdir() */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
 
 /* Global Variables */
 char *TCID = "rt_sigaction01";  /* Test program identifier.*/
-int  expected_signal_number = 0;
-int  pass_count = 0;
 int  testno;
-int  TST_TOTAL = 1;		   /* total number of tests in this file.   */
-
-int test_flags[] = {
-	SA_RESETHAND|SA_SIGINFO,
-	SA_RESETHAND,
-	SA_RESETHAND|SA_SIGINFO,
-	SA_RESETHAND|SA_SIGINFO,
-	SA_NOMASK
-};
-char *test_flags_list[] = {
-	"SA_RESETHAND|SA_SIGINFO",
-	"SA_RESETHAND",
-	"SA_RESETHAND|SA_SIGINFO",
-	"SA_RESETHAND|SA_SIGINFO",
-	"SA_NOMASK"
-};
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
 
 /* Extern Global Functions */
 /******************************************************************************/
-/*									    */
-/* Function:    cleanup						       */
-/*									    */
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
 /* Description: Performs all one time clean up for this test on successful    */
-/*	      completion,  premature exit or  failure. Closes all temporary */
-/*	      files, removes all temporary directories exits the test with  */
-/*	      appropriate return code by calling tst_exit() function.       */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
 /* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*	      On success - Exits calling tst_exit(). With '0' return code.  */
-/*									    */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
 /******************************************************************************/
-static void cleanup() {
+extern void cleanup() 
+{
 	/* Remove tmp dir and all files in it */
 	TEST_CLEANUP;
 	tst_rmdir();
+
+	/* Exit with appropriate return code. */
+	tst_exit();
 }
 
 /* Local  Functions */
 /******************************************************************************/
-/*									    */
-/* Function:    setup							 */
-/*									    */
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
 /* Description: Performs all one time setup for this test. This function is   */
-/*	      typically used to capture signals, create temporary dirs      */
-/*	      and temporary files that may be used in the course of this    */
-/*	      test.							 */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
-/* Return:      On failure - Exits by calling cleanup().		      */
-/*	      On success - returns 0.				       */
-/*									    */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
 /******************************************************************************/
-void
-setup()
+void setup() 
 {
-	(void) setup_sigsegv_sigaction_handler();
-	/* Wait for SIGUSR1 if requested */
-	TEST_PAUSE;
+	/* 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};
+char *test_flags_list[] = {"SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK"};
+
 void
 handler(int sig)
 {
-	tst_resm(TINFO, "Signal handler (non-sigaction) called with signal number %d", sig);
-	pass_count++;
+        tst_resm(TINFO,"Signal Handler Called with signal number %d\n",sig);
+        return;
 }
-
-void
-sigaction_handler(int sig, siginfo_t *siginfo, void *ucontext) {
-	tst_resm(TINFO, "Signal handler (sigaction) called with signal number %d", sig);
-	if (sig == expected_signal_number)
-		pass_count++;
-}
-
 int
 set_handler(int sig, int mask_flags)
 {
-	int rc = -1;
-	struct sigaction sa;
-
-	//memset(&sa, 0, SIGSETSIZE);
-
-	sa.sa_flags = mask_flags;
-
-	ARCH_SPECIFIC_RT_SIGACTION_SETUP(sa);
-
-#if HAVE_STRUCT_SIGACTION_SA_SIGACTION
-	/*
-         *  SA_SIGINFO (since Linux 2.2)
-         *        The  signal  handler  takes  3  arguments, not one.  In this
-         *        case, sa_sigaction should  be  set  instead  of  sa_handler.
-         *        This flag is only meaningful when establishing a signal han-
-         *        dler.
-         *
-	 */
-	if (sa.sa_flags & SA_SIGINFO)
-		sa.sa_sigaction = (void *) sigaction_handler;
-	else
+#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_handler = (void *) handler;
-
-	if (sigemptyset(&sa.sa_mask) < 0) {
-		tst_resm(TINFO, "sigemptyset(..) failed");
-	} else if (sigaddset(&sa.sa_mask, sig) < 0) {
-		tst_resm(TFAIL | TINFO, "sigaddset(..) failed");
-	} else if (syscall(__NR_rt_sigaction, sig, &sa, (struct sigaction*) NULL, SIGSETSIZE)) {
-		tst_resm(TFAIL | TERRNO, "rt_sigaction(%d, ..) failed", sig);
-	} else {
-		rc = 0;
-	}
-	return rc;
+	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;
 }
 
-int
-main(int ac, char **av) {
 
-	char *msg;	/* message returned from parse_opts */
-
-	/* parse standard options */
-	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
-		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
-
-	setup();
-
-#if HAVE_STRUCT_SIGACTION_SA_SIGACTION
-	int flag;
-	int last_pass_count;
-	int num_tests_per_signal = sizeof(test_flags) / sizeof(*test_flags);
-	int tests_passed;
-	int lc;		/* loop counter */
-
-	tst_resm(TINFO, "Will run %d tests per signal in set [%d, %d]",
-			num_tests_per_signal, SIGRTMIN, SIGRTMAX);
-
-	/* Check looping state if -i option given */
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-
-		Tst_count = 0;
-
-		for (testno = 0; testno < TST_TOTAL; ++testno) {
-
-			/* 34 (NPTL) or 35 (LinuxThreads) to 65 (or 128 on mips). */
-			for (expected_signal_number = SIGRTMIN; expected_signal_number <= SIGRTMAX; expected_signal_number++) { 
-
-				last_pass_count = pass_count;
-
-				tst_resm(TINFO, "signal: %d ", expected_signal_number);
-
-			 	for (flag = 0; flag < num_tests_per_signal; flag++) {
-
-					if (set_handler(expected_signal_number, test_flags[flag]) == 0) {
-
-						tst_resm(TINFO,
-							"\tsa.sa_flags = %s",
-							test_flags_list[flag]);
-
-						if (kill(getpid(), expected_signal_number) < 0) {
-							tst_resm(TINFO | TERRNO, "kill failed");
-						}
-
-		       			}
-
-				}
-
-				tests_passed = ((pass_count - last_pass_count) ==
-						 num_tests_per_signal);
-
-				tst_resm(tests_passed ? TPASS : TFAIL,
-					"tests %s for signal = %d",
-					tests_passed ? "passed" : "failed",
-					expected_signal_number);
-
-			}
-
-		}
-
-	}
-#else
-	tst_brkm(TCONF, NULL,
-			"Your architecture doesn't support this test (no "
-			"sa_sigaction field in struct sigaction).");
+int main(int ac, char **av) {
+	int signal, flag;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+                
+			for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++){//signal for 34 to 65 
+#ifdef __x86_64__
+				sig_initial(signal);
 #endif
+				for(flag=0; flag<5;flag++) {
+	                        	 TEST(set_handler(signal, test_flags[flag]));
+						 if (TEST_RETURN == 0) {
+        					tst_resm(TINFO,"signal: %d ", signal);
+        					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
+        					tst_resm(TINFO, "sa.sa_flags = %s ",test_flags_list[flag]);
+						kill(getpid(),signal);
+			                         } else {
+                 	   				tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+                       				}
+                			}
+		 	printf("\n");	
+        		}
+
+
+
+                }
+        }	
 	cleanup();
-	tst_exit();
-
+        tst_exit();
 }
+
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 2e51176..8bcdc78 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -1,26 +1,26 @@
 /******************************************************************************/
-/* Copyright (c) Crackerjack Project., 2007				      */
-/*									      */
+/* Copyright (c) Crackerjack Project., 2007                                   */
+/*                                                                            */
 /* 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		      */
+/* 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    */
-/*									      */
+/*                                                                            */
 /******************************************************************************/
 /******************************************************************************/
-/*									      */
-/* File:	rt_sigprocmask01.c					      */
-/*									      */
-/* Description: This tests the rt_sigprocmask() syscall			      */
+/*                                                                            */
+/* File:        rt_sigprocmask01.c                                              */
+/*                                                                            */
+/* Description: This tests the rt_sigprocmask() syscall                       */
 /*		rt_sigprocmask changes the list of currently blocked signals. */
 /*		The set value stores the signal mask of the pending signals.  */
 /*		The previous action on the signal is saved in oact. The value */
@@ -37,170 +37,211 @@
 /*		SIG_SETMASK						      */
 /*		    The set of blocked signals is set to the set argument.    */
 /*		    sigsetsize should indicate the size of a sigset_t type.   */
-/*									      */
-/* Usage:  <for command-line>						      */
-/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]		      */
-/*      where,  -c n : Run n copies concurrently.			      */
-/*	      -e   : Turn on errno logging.				      */
-/*	      -i n : Execute test n times.				      */
-/*	      -I x : Execute test for x seconds.			      */
-/*	      -P x : Pause for x seconds between iterations.		      */
-/*	      -t   : Turn on syscall timing.				      */
-/*									      */
-/* Total Tests: 1							      */
-/*									      */
-/* Test Name:   rt_sigprocmask01					      */
-/* History:     Porting from Crackerjack to LTP is done by		      */
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>			      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                      */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   rt_sigprocmask01                                              */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
 #include <stdio.h>
+#include <signal.h>
 #include <errno.h>
 
 /* Harness Specific Include Files. */
-#include "ltp_signal.h"
 #include "test.h"
 #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()	      */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
 
 /* Global Variables */
-char *TCID = "rt_sigprocmask01";	/* Test program identifier.	      */
-int  TST_TOTAL = 8;			/* total number of tests in this file.*/
+char *TCID = "rt_sigprocmask01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 8;                   /* total number of tests in this file.   */
 
 /* Extern Global Functions */
 /******************************************************************************/
-/*									      */
-/* Function:    cleanup							      */
-/*									      */
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
 /* Description: Performs all one time clean up for this test on successful    */
-/*	      completion,  premature exit or  failure. Closes all temporary   */
-/*	      files, removes all temporary directories exits the test with    */
-/*	      appropriate return code by calling tst_exit() function.	      */
-/*									      */
-/* Input:       None.							      */
-/*									      */
-/* Output:      None.							      */
-/*									      */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
 /* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*	      On success - Exits calling tst_exit(). With '0' return code.    */
-/*									      */
+/*              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();
+        /* 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 */
 /******************************************************************************/
-/*									      */
-/* Function:    setup							      */
-/*									      */
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
 /* Description: Performs all one time setup for this test. This function is   */
-/*	      typically used to capture signals, create temporary dirs	      */
-/*	      and temporary files that may be used in the course of this      */
-/*	      test.							      */
-/*									      */
-/* Input:       None.							      */
-/*									      */
-/* Output:      None.							      */
-/*									      */
-/* Return:      On failure - Exits by calling cleanup().		      */
-/*	      On success - returns 0.					      */
-/*									      */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
 /******************************************************************************/
 void setup() {
-	/* Capture signals if any */
-	/* Create temporary directories */
-	TEST_PAUSE;
-	tst_tmpdir();
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
 }
 
 int sig_count = 0;
 
 void sig_handler(int sig)
 {
-	sig_count++;
+        sig_count++;
 }
 
 int main(int ac, char **av) {
-	struct sigaction act, oact;
-	sigset_t set, oset;
-	int lc;		 /* loop counter */
-	char *msg;	      /* message returned from parse_opts */
+#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 */
 	
-	/* parse standard options */
-	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
-		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
-
-	setup();
-
-	Tst_count = 0;
-	TEST(sigemptyset(&set));
-	if (TEST_RETURN == -1) {
-		tst_resm(TFAIL | TTERRNO, "sigemptyset() failed");
-		cleanup();
-		tst_exit();
-	}
-	TEST(sigaddset(&set, SIGRTMIN));
-	if (TEST_RETURN == -1){
-		tst_resm(TFAIL | TTERRNO, "sigaddset() failed");
-		cleanup();
-		tst_exit();
-	}
-	
-	/* call rt_sigaction() */
-	act.sa_handler = sig_handler;
-	TEST(syscall(__NR_rt_sigaction, SIGRTMIN, &act, &oact,
-		SIGSETSIZE));
-	if (TEST_RETURN != 0){
-		tst_resm(TFAIL | TTERRNO,"rt_sigaction() failed");
-	}
-	/* call rt_sigprocmask() to block signal # SIGRTMIN */
-	TEST(syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set, &oset, SIGSETSIZE));
-	if (TEST_RETURN == -1) {
-		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
-	}
-	TEST(kill(getpid(), SIGRTMIN));
-	if (TEST_RETURN != 0){
-		tst_brkm(TFAIL | TTERRNO, cleanup, "kill() failed");
-	}
-	if (sig_count) {
-		tst_brkm(TFAIL | TTERRNO, cleanup,
-			"rt_sigprocmask() failed to change the "
-			"process's signal mask");
-	}
-	/* call rt_sigpending() */
-	TEST(syscall(__NR_rt_sigpending, &oset, SIGSETSIZE));
-	if (TEST_RETURN == -1) {
-		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigpending() failed");
-	}
-	TEST(sigismember(&oset, SIGRTMIN));
-	if (TEST_RETURN == 0) {
-		tst_brkm(TFAIL | TTERRNO, cleanup, "sigismember() failed");
-	}
-	/* call rt_sigprocmask() to unblock signal#33 */
-	TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, &set, &oset, SIGSETSIZE));
-	if (TEST_RETURN == -1) {
-		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
-	}
-	if (sig_count) {
-		tst_resm(TPASS, "rt_sigprocmask() PASSED");
-	} else {
-		tst_resm(TFAIL | TTERRNO,
-			"rt_sigprocmask() "
-			"functionality failed");
-	}
-
-	cleanup();
-	tst_exit();
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
 
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			TEST(sigemptyset(&set));
+			if(TEST_RETURN == -1){
+				tst_resm(TFAIL,"Call to sigemptyset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        	cleanup();
+				tst_exit();
+			}
+			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() */
+                        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#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));
+                        	cleanup();
+				tst_exit();
+			}
+			
+			else {
+				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();
+					tst_exit();
+					
+				}
+				if(sig_count){
+					tst_resm(TFAIL,"FAIL --- rt_sigprocmask() fail to change the process's signal mask, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        		cleanup();
+					tst_exit();
+				}
+				else {
+					/* call rt_sigpending() */
+					TEST(syscall(__NR_rt_sigpending, &oset, 8));
+					if(TEST_RETURN == -1){
+						tst_resm(TFAIL,"call rt_sigpending() failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        			cleanup();
+						tst_exit();
+					}
+					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#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));
+                        			cleanup();
+						tst_exit();
+					}
+					if(sig_count) {
+						tst_resm(TPASS,"rt_sigprocmask() PASSED");
+                        			cleanup();
+						tst_exit();
+					}
+		                        else {
+						tst_resm(TFAIL,"rt_sigprocmask() functionality failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+		                                cleanup();
+						tst_exit();
+		                        }
+
+				}
+			}
+
+                }
+	Tst_count++;
+        }	
+        tst_exit();
 }
+
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index fcb5b0b..84f2967 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -18,12 +18,12 @@
 /******************************************************************************	*/
 /******************************************************************************	*/
 /*                                                                            	*/
-/* File:        rt_sigsuspend01.c                                           	*/
+/* File:        rt_sigsuspend01.c                                           	      	*/
 /*                                                                            	*/
-/* Description: This tests the rt_sigsuspend() syscall.                      	*/
+/* Description: This tests the rt_sigsuspend() syscall.                      	      	*/
 /*		                                                               	*/
 /* Usage:  <for command-line>                                                 	*/
-/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     	*/
+/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     		*/
 /*      where,  -c n : Run n copies concurrently.                             	*/
 /*              -e   : Turn on errno logging.                                 	*/
 /*              -i n : Execute test n times.                                  	*/
@@ -33,15 +33,11 @@
 /*                                                                            	*/
 /* Total Tests: 2                                                             	*/
 /*                                                                            	*/
-/* Test Name:   rt_sigsuspend01                                             	*/
+/* Test Name:   rt_sigsuspend01                                             		*/
 /* History:     Porting from Crackerjack to LTP is done by                    	*/
 /*              Manas Kumar Nayak maknayak@in.ibm.com>                        	*/
 /********************************************************************************/
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
 #include <stdio.h>
 #include <signal.h>
 #include <errno.h>
@@ -50,16 +46,19 @@
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
-#include "ltp_signal.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() */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
 
 /* Global Variables */
 char *TCID = "rt_sigsuspend01";  /* Test program identifier.*/
 int  testno;
-int  TST_TOTAL = 4;              /* total number of tests in this file.   */
+int  TST_TOTAL =4;                   /* total number of tests in this file.   */
 
 /* Extern Global Functions */
 /******************************************************************************/
@@ -69,20 +68,23 @@ int  TST_TOTAL = 4;              /* total number of tests in this file.   */
 /* Description: Performs all one time clean up for this test on successful    */
 /*              completion,  premature exit or  failure. Closes all temporary */
 /*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
+/*              appropriate TEST_RETURNurn code by calling tst_exit() function.       */
 /*                                                                            */
 /* Input:       None.                                                         */
 /*                                                                            */
 /* Output:      None.                                                         */
 /*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' TEST_RETURNurn code.   */
+/*              On success - Exits calling tst_exit(). With '0' TEST_RETURNurn code.  */
 /*                                                                            */
 /******************************************************************************/
-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 TEST_RETURNurn code. */
+        tst_exit();
 }
 
 /* Local  Functions */
@@ -100,14 +102,14 @@ void cleanup() {
 /* Output:      None.                                                         */
 /*                                                                            */
 /* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - Returns 0.					      */
+/*              On success - TEST_RETURNurns 0.                                       */
 /*                                                                            */
 /******************************************************************************/
 void setup() {
-/* Capture signals if any */
-/* Create temporary directories */
-TEST_PAUSE;
-tst_tmpdir();
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
 }
 
 
@@ -120,55 +122,77 @@ void sig_handler(int sig)
 int main(int ac, char **av) {
 	
 	sigset_t set, set1, set2;
-	char *msg;		/* message returned from parse_opts */
+	int lc;                 /* loop counter */
+        char *msg;              /* message TEST_RETURNurned from parse_opts */
 	
-	/* parse standard options */
-	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
-		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
-
-	setup();
-
-	Tst_count = 0;
-	TEST(sigemptyset(&set));
-	if (TEST_RETURN == -1){
-		tst_brkm(TFAIL | TTERRNO, cleanup, "sigemptyset() failed");
-	}
-	struct sigaction act, oact;
-	act.sa_handler = sig_handler;
-			
-	TEST(syscall(__NR_rt_sigaction, SIGALRM, &act, &oact, SIGSETSIZE));
-	if (TEST_RETURN == -1){
-	       	tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigaction() failed");
-	}
-	TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set1, SIGSETSIZE));
-	if (TEST_RETURN == -1){
-		tst_brkm(TFAIL | TTERRNO, cleanup, "rt_sigprocmask() failed");
-		cleanup();
-		tst_exit();
-	}
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			TEST(sigemptyset(&set));
+			if(TEST_RETURN == -1){
+				tst_resm(TFAIL,"sigemptyset() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+				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));
+				cleanup();
+				tst_exit();
+			}
+			TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set1, 8));
+			if(TEST_RETURN == -1){
+		        	tst_resm(TFAIL,"rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+				cleanup();
+				tst_exit();
+			}
 			
-	TEST(alarm(5));
-	int result;
-	TEST(result = syscall(__NR_rt_sigsuspend, &set, SIGSETSIZE));
-	TEST(alarm(0));
-	if (result == -1 && TEST_ERRNO != EINTR) {
-		TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set2,
-				SIGSETSIZE));
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL | TTERRNO, "rt_sigprocmask() failed");
-		} else if (set1.__val[0] != set2.__val[0]) {
-			tst_resm(TFAIL | TTERRNO,
-				"rt_sigsuspend failed to preserve signal mask");
-	        } else {
-			tst_resm(TPASS, "rt_sigsuspend PASSED");
-		}
-	} else {
-		tst_resm(TFAIL | TTERRNO, "rt_sigsuspend failed");
-	}
-
+			TEST(alarm(5));
+		        int result;
+			TEST(result = syscall(__NR_rt_sigsuspend, &set, 8));
+		        TEST(alarm(0));
+			if((result == -1) && (TEST_ERRNO != EINTR)){
+				TEST(syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0, &set2, 8));
+				if(TEST_RETURN == -1){
+		        		tst_resm(TFAIL,"rt_sigprocmask() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+					cleanup();
+					tst_exit();
+				} else if(set1.__val[0] != set2.__val[0]){
+		                        tst_resm(TFAIL," rt_sigsuspend failed to preserve signal mask,errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+					cleanup();
+					tst_exit();
+			        } else {
+		                        tst_resm(TPASS,"rt_sigsuspend PASSED");
+		                }
+		        }else{
+		             tst_resm(TFAIL," rt_sigsuspend failed ,errrno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+	                     cleanup();
+			     tst_exit();
+			}
+		
+	
+                }
+	 }
 	cleanup();
-	tst_exit();
-
+        tst_exit();
 }
+
-- 
1.6.2.2










------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 34+ messages in thread
* [LTP] [PATCH] syscalls: fix some failure on arch X86_64
@ 2010-02-22  5:21 liubo
  2010-02-22  7:56 ` Garrett Cooper
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2010-02-22  5:21 UTC (permalink / raw)
  To: ltp-list

- 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.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>

---
 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

diff --git a/include/rt_signal.h b/include/rt_signal.h
new file mode 100644
index 0000000..ea1e7e3
--- /dev/null
+++ b/include/rt_signal.h
@@ -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 <liubo2009@cn.fujitsu.com>                                  */
+/*                                                                            */
+/******************************************************************************/
+
+#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
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index ffc5fa2..d30f204 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -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) {
                 
 			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]));
+#ifdef __x86_64__
+				sig_initial(signal);
+#endif
+				for(flag=0; flag<5;flag++) {
+	                        	 TEST(set_handler(signal, test_flags[flag]));
 						 if (TEST_RETURN == 0) {
         					tst_resm(TINFO,"signal: %d ", signal);
         					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 6398a28..8bcdc78 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -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));
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 416a7c9..84f2967 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -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));
-- 
1.6.2.2





------------------------------------------------------------------------------
Download Intel&#174; 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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 34+ messages in thread
* [LTP] [PATCH] syscalls: fix some failure on arch X86_64
@ 2010-02-22  9:20 liubo
  2010-02-22 14:45 ` Rishikesh K Rajak
  0 siblings, 1 reply; 34+ messages in thread
From: liubo @ 2010-02-22  9:20 UTC (permalink / raw)
  To: ltp-list

- 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+1 
to replace 33.

- rt_sigsuspend01
There exists the same problem as rt_sigaction01.

This patch fixed these failure.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>

---
 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

diff --git a/include/rt_signal.h b/include/rt_signal.h
new file mode 100644
index 0000000..ea1e7e3
--- /dev/null
+++ b/include/rt_signal.h
@@ -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 <liubo2009@cn.fujitsu.com>                                  */
+/*                                                                            */
+/******************************************************************************/
+
+#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
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index ffc5fa2..c8f5d5f 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -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;
 }
 
 
@@ -167,6 +174,7 @@ int main(int ac, char **av) {
 	int signal, flag;
         int lc;                 /* loop counter */
         char *msg;              /* message returned from parse_opts */
+	int fc;			/* flag counter */
 	
         /* parse standard options */
         if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
@@ -179,11 +187,16 @@ int main(int ac, char **av) {
         /* Check looping state if -i option given */
         for (lc = 0; TEST_LOOPING(lc); ++lc) {
                 Tst_count = 0;
-                for (testno = 0; testno < TST_TOTAL; ++testno) {
+		fc = sizeof (test_flags) / sizeof (test_flags[0]);
+
+		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]));
+#ifdef __x86_64__
+				sig_initial(signal);
+#endif
+				for(flag=0; flag<fc;flag++) {
+	                        	 TEST(set_handler(signal, test_flags[flag]));
 						 if (TEST_RETURN == 0) {
         					tst_resm(TINFO,"signal: %d ", signal);
         					tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN );
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 6398a28..5b292b2 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -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));
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 416a7c9..84f2967 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -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));
-- 
1.6.2.2




------------------------------------------------------------------------------
Download Intel&#174; 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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2010-02-27  4:12 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-10  9:38 [LTP] [PATCH] syscalls: fix some failure on arch X86_64 liubo
2009-11-11  1:28 ` liubo
2009-11-11  4:14   ` Garrett Cooper
2009-11-11  4:30     ` Wei Yongjun
2009-11-11  5:22     ` liubo
2009-11-11  4:33 ` Mike Frysinger
2009-11-11  5:03   ` Wei Yongjun
2009-11-16  8:13     ` Subrata Modak
2009-11-16  8:53       ` liubo
2009-11-26 11:11         ` Garrett Cooper
2009-11-27  5:33           ` liubo
2009-11-27  6:49             ` Garrett Cooper
2009-11-27  8:50               ` Garrett Cooper
2009-11-27 10:07                 ` liubo
2009-11-27 22:18                   ` Garrett Cooper
2009-11-29  1:22                     ` Wei Yongjun
2009-12-01  0:00                       ` Garrett Cooper
2009-12-09  7:29                         ` liubo
2009-12-09  7:34 liubo
2009-12-09 12:14 ` Subrata Modak
2009-12-18 16:03 ` Subrata Modak
2009-12-22  2:51   ` Garrett Cooper
2009-12-22 13:12     ` liubo
2010-02-22  5:21 liubo
2010-02-22  7:56 ` Garrett Cooper
2010-02-22  9:08   ` liubo
2010-02-22 18:05     ` Garrett Cooper
2010-02-23  0:59       ` liubo
2010-02-25  7:26         ` liubo
2010-02-25 10:00           ` Garrett Cooper
2010-02-26  0:35             ` liubo
2010-02-27  4:12               ` Garrett Cooper
2010-02-22  9:20 liubo
2010-02-22 14:45 ` Rishikesh K Rajak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.