All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Haitao <penght@cn.fujitsu.com>
To: Garrett Cooper <yanegomi@gmail.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] mprotect02: fix error of the case need sighandler()
Date: Fri, 21 Jan 2011 13:38:51 +0800	[thread overview]
Message-ID: <4D391BEB.9070508@cn.fujitsu.com> (raw)
In-Reply-To: <AANLkTimPKEHGOc4-UQXxSZoNJi5UQD1wB1L2n3iUznhE@mail.gmail.com>

Hi Garrett,

Garrett Cooper said the following on 2011-1-21 12:00:
>> This is OK, but the default signal handler is invoked when an unexpected signal
>> is caught. so I think we should add sighandler(). Furthermore, the default
>> signal handler make the child process exit 2, but the case expect the child
>> process exit 1, this will cause the case fail.
>>
>> The following patch will reinitialize signal handler.
> 
>     This won't work if the number of test loops is > 1 (it will reset
> the handler back to the default and fail on the next iteration).

Thanks for your comment.

The following patch will initialize signal handler to sighandler() in loops starting,
and reinitialize default signal handle in the second part.

Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>
---
 testcases/kernel/syscalls/mprotect/mprotect02.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/mprotect/mprotect02.c b/testcases/kernel/syscalls/mprotect/mprotect02.c
index ebc4bcc..f27d2da 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect02.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect02.c
@@ -65,6 +65,7 @@
 
 void cleanup(void);
 void setup(void);
+void sighandler(int);
 
 char *TCID = "mprotect02";
 int TST_TOTAL = 1;
@@ -93,6 +94,9 @@ int main(int ac, char **av)
 	/* The following loop checks looping state if -i option given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 
+		/* Initialization signal handler */
+		tst_sig(FORK, sighandler, NULL);
+
 		/* reset Tst_count in case we are looping */
 		Tst_count = 0;
 
@@ -129,6 +133,9 @@ int main(int ac, char **av)
 			tst_brkm(TBROK, cleanup, "child failed");
 		 }
 
+		/* Re-Initialization signal handler */
+		tst_sig(FORK, DEF_HANDLER, NULL);
+
 		/*
 		 * Change the protection to WRITE.
 		 */
@@ -198,13 +205,20 @@ int main()
 
 #endif /* UCLINUX */
 
+void sighandler(int sig)
+{
+	tst_resm(TINFO, "received signal: %d", sig);
+	if (sig == SIGSEGV)
+		exit(1);
+	else
+		tst_brkm(TBROK, 0, "Unexpected signal %d received.", sig);
+}
+
 /*
  * setup() - performs all ONE TIME setup for this test
  */
 void setup()
 {
-	tst_sig(FORK, DEF_HANDLER, NULL);
-
 	TEST_PAUSE;
 
 	tst_tmpdir();		/* create a temporary directory, cd to it */
-- 
1.7.3.1


-- 
Best Regards,
Peng Haitao


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2011-01-21  5:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-20  8:00 [LTP] [PATCH] mprotect02: fix error of the case need sighandler() Peng Haitao
2011-01-20  9:28 ` Garrett Cooper
2011-01-21  3:55   ` Peng Haitao
2011-01-21  4:00     ` Garrett Cooper
2011-01-21  5:38       ` Peng Haitao [this message]
2011-01-21  8:29         ` Garrett Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D391BEB.9070508@cn.fujitsu.com \
    --to=penght@cn.fujitsu.com \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=yanegomi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.