* [LTP] [PATCH] mprotect02: fix error of the case need sighandler()
@ 2011-01-20 8:00 Peng Haitao
2011-01-20 9:28 ` Garrett Cooper
0 siblings, 1 reply; 6+ messages in thread
From: Peng Haitao @ 2011-01-20 8:00 UTC (permalink / raw)
To: Garrett Cooper; +Cc: ltp-list
Hi Garrett,
The case expect the signal "SIGSEGV", so should add sighandler().
Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>
---
testcases/kernel/syscalls/mprotect/mprotect02.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/testcases/kernel/syscalls/mprotect/mprotect02.c b/testcases/kernel/syscalls/mprotect/mprotect02.c
index ebc4bcc..36c41de 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect02.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect02.c
@@ -198,12 +198,21 @@ 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);
+ tst_sig(FORK, sighandler, NULL);
TEST_PAUSE;
--
1.7.3.1
--
Best Regards,
Peng Haitao
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] mprotect02: fix error of the case need sighandler()
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
0 siblings, 1 reply; 6+ messages in thread
From: Garrett Cooper @ 2011-01-20 9:28 UTC (permalink / raw)
To: Peng Haitao; +Cc: ltp-list
On Thu, Jan 20, 2011 at 12:00 AM, Peng Haitao <penght@cn.fujitsu.com> wrote:
> Hi Garrett,
>
> The case expect the signal "SIGSEGV", so should add sighandler().
For the first portion of the testcase, yes. For the second part of the
testcase, no.
Thanks,
-Garrett
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] mprotect02: fix error of the case need sighandler()
2011-01-20 9:28 ` Garrett Cooper
@ 2011-01-21 3:55 ` Peng Haitao
2011-01-21 4:00 ` Garrett Cooper
0 siblings, 1 reply; 6+ messages in thread
From: Peng Haitao @ 2011-01-21 3:55 UTC (permalink / raw)
To: Garrett Cooper; +Cc: ltp-list
Hi Garrett,
Garrett Cooper said the following on 2011-1-20 17:28:
>> The case expect the signal "SIGSEGV", so should add sighandler().
>
> For the first portion of the testcase, yes. For the second part of the
> testcase, no.
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.
Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>
---
testcases/kernel/syscalls/mprotect/mprotect02.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/testcases/kernel/syscalls/mprotect/mprotect02.c b/testcases/kernel/syscalls/mprotect/mprotect02.c
index ebc4bcc..c0a5d8b 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect02.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect02.c
@@ -129,6 +129,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,12 +201,21 @@ 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);
+ tst_sig(FORK, sighandler, NULL);
TEST_PAUSE;
--
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] mprotect02: fix error of the case need sighandler()
2011-01-21 3:55 ` Peng Haitao
@ 2011-01-21 4:00 ` Garrett Cooper
2011-01-21 5:38 ` Peng Haitao
0 siblings, 1 reply; 6+ messages in thread
From: Garrett Cooper @ 2011-01-21 4:00 UTC (permalink / raw)
To: Peng Haitao; +Cc: ltp-list
On Thu, Jan 20, 2011 at 7:55 PM, Peng Haitao <penght@cn.fujitsu.com> wrote:
> Hi Garrett,
>
> Garrett Cooper said the following on 2011-1-20 17:28:
>>> The case expect the signal "SIGSEGV", so should add sighandler().
>>
>> For the first portion of the testcase, yes. For the second part of the
>> testcase, no.
>
> 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,
-Garrett
------------------------------------------------------------------------------
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] mprotect02: fix error of the case need sighandler()
2011-01-21 4:00 ` Garrett Cooper
@ 2011-01-21 5:38 ` Peng Haitao
2011-01-21 8:29 ` Garrett Cooper
0 siblings, 1 reply; 6+ messages in thread
From: Peng Haitao @ 2011-01-21 5:38 UTC (permalink / raw)
To: Garrett Cooper; +Cc: ltp-list
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] mprotect02: fix error of the case need sighandler()
2011-01-21 5:38 ` Peng Haitao
@ 2011-01-21 8:29 ` Garrett Cooper
0 siblings, 0 replies; 6+ messages in thread
From: Garrett Cooper @ 2011-01-21 8:29 UTC (permalink / raw)
To: Peng Haitao; +Cc: ltp-list
On Thu, Jan 20, 2011 at 9:38 PM, Peng Haitao <penght@cn.fujitsu.com> wrote:
> 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.
I fixed it in a different way from what you did and it appears to
work well now (I simplified the test by not using tst_sig, as it kept
on segfaulting in the parent process when I used tst_sig).
Thanks,
-Garrett
------------------------------------------------------------------------------
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-01-21 8:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2011-01-21 8:29 ` Garrett Cooper
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.