From: chrubis@suse.cz
To: Xing Gu <gux.fnst@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH v3] mprotect/mprotect04.c: add PROT_NONE, PROT_EXEC flag test
Date: Tue, 25 Mar 2014 17:36:28 +0100 [thread overview]
Message-ID: <20140325163627.GC10754@rei> (raw)
In-Reply-To: <1394070844-20617-1-git-send-email-gux.fnst@cn.fujitsu.com>
Hi!
> +static void sighandler(int sig)
> +{
> + if (sig == SIGSEGV) {
> + sigsegv_caught = 1;
> + siglongjmp(env, 1);
> + } else {
> + tst_brkm(TBROK, cleanup, "received an unexpected signal: %d",
> + sig);
> + }
> +}
I've changed the code a bit to avoid the tst_brkm() in signal handler
and pushed the code (full diff below). Thanks.
diff --git a/testcases/kernel/syscalls/mprotect/mprotect04.c b/testcases/kernel/syscalls/mprotect/mprotect04.c
index 17ee73d..4ca7c02 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect04.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect04.c
@@ -54,7 +54,7 @@ static void (*testfunc[])(void) = { testfunc_protnone, testfunc_protexec };
char *TCID = "mprotect04";
int TST_TOTAL = ARRAY_SIZE(testfunc);
-static volatile int sigsegv_caught;
+static volatile int sig_caught;
static sigjmp_buf env;
int main(int ac, char **av)
@@ -82,13 +82,8 @@ int main(int ac, char **av)
static void sighandler(int sig)
{
- if (sig == SIGSEGV) {
- sigsegv_caught = 1;
- siglongjmp(env, 1);
- } else {
- tst_brkm(TBROK, cleanup, "received an unexpected signal: %d",
- sig);
- }
+ sig_caught = sig;
+ siglongjmp(env, 1);
}
static void setup(void)
@@ -103,7 +98,7 @@ static void testfunc_protnone(void)
char *addr;
int page_sz;
- sigsegv_caught = 0;
+ sig_caught = 0;
page_sz = getpagesize();
@@ -119,10 +114,18 @@ static void testfunc_protnone(void)
if (sigsetjmp(env, 1) == 0)
addr[0] = 1;
- if (sigsegv_caught)
+ switch (sig_caught) {
+ case SIGSEGV:
tst_resm(TPASS, "test PROT_NONE for mprotect success");
- else
+ break;
+ case 0:
tst_resm(TFAIL, "test PROT_NONE for mprotect failed");
+ break;
+ default:
+ tst_brkm(TBROK, cleanup,
+ "received an unexpected signal: %d",
+ sig_caught);
+ }
}
SAFE_MUNMAP(cleanup, addr, page_sz);
@@ -138,7 +141,7 @@ static void testfunc_protexec(void)
int page_sz;
int (*func)(void);
- sigsegv_caught = 0;
+ sig_caught = 0;
page_sz = getpagesize();
@@ -156,10 +159,18 @@ static void testfunc_protexec(void)
if (sigsetjmp(env, 1) == 0)
(*func)();
- if (sigsegv_caught)
+ switch (sig_caught) {
+ case SIGSEGV:
tst_resm(TFAIL, "test PROT_EXEC for mprotect failed");
- else
+ break;
+ case 0:
tst_resm(TPASS, "test PROT_EXEC for mprotect success");
+ break;
+ default:
+ tst_brkm(TBROK, cleanup,
+ "received an unexpected signal: %d",
+ sig_caught);
+ }
}
SAFE_MUNMAP(cleanup, func, page_sz);
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
prev parent reply other threads:[~2014-03-25 16:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-06 1:54 [LTP] [PATCH v3] mprotect/mprotect04.c: add PROT_NONE, PROT_EXEC flag test Xing Gu
2014-03-07 11:08 ` Jan Stancek
2014-03-11 15:16 ` chrubis
2014-03-25 16:36 ` chrubis [this message]
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=20140325163627.GC10754@rei \
--to=chrubis@suse.cz \
--cc=gux.fnst@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox