mprotect02 triggered an expected SIGSEGV in test, but it puts this
information in dmesg, which might cause confusion when checking results:

mprotect02[11416]: segfault at 7f9ca0060000 ip 0000003a8e3382ff sp 
00007fff7aeecb68 error 6 in libc-2.12.so[3a8e200000+197000]

This patch hides the sigfault information from dmesg.

Signed-off-by: Caspar Zhang <[email protected]>
---
 testcases/kernel/syscalls/mprotect/mprotect02.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/mprotect/mprotect02.c b/testcases/kernel/syscalls/mprotect/mprotect02.c
index 97250c5..1d1fad0 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect02.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect02.c
@@ -60,6 +60,7 @@
 
 #include "safe_macros.h"
 
+static void sighandler(int sig);
 static void cleanup(void);
 static void setup(void);
 
@@ -121,13 +122,6 @@ int main(int ac, char **av)
 		if (waitpid(pid, &status, 0) == -1)
 			tst_brkm(TBROK|TERRNO, cleanup, "waitpid failed");
 
-		if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)
-			tst_resm(TPASS, "got SIGSEGV as expected");
-		else
-			tst_brkm(TBROK, cleanup,
-			    "child exited abnormally; wait status = %d",
-			    status);
-
 		/* Change the protection to WRITE. */
 		TEST(mprotect(addr, sizeof(buf), PROT_WRITE));
 
@@ -185,9 +179,21 @@ int main()
 
 #endif /* UCLINUX */
 
+static void sighandler(int sig)
+{
+	if (sig == SIGSEGV) {
+		tst_resm(TPASS, "got SIGSEGV as expected");
+		tst_exit();
+	} else
+		tst_brkm(TBROK, cleanup, "child exited abnormally: %d",
+			sig);
+}
+
 static void setup()
 {
 
+	tst_sig(FORK, sighandler, cleanup);
+
 	TEST_PAUSE;
 
 	tst_tmpdir();
------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to