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 |   31 +++++++++++++++++------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/testcases/kernel/syscalls/mprotect/mprotect02.c b/testcases/kernel/syscalls/mprotect/mprotect02.c
index 97250c5..301391a 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);
 
@@ -114,19 +115,26 @@ int main(int ac, char **av)
 
 		if (pid == 0) {
 			(void)memcpy(addr, buf, strlen(buf));
-			printf("memcpy did not generate SIGSEGV\n");
-			exit(1);
+			exit(255);
 		}
 
 		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
+		if (!WIFEXITED(status))
+			tst_brkm(TBROK, cleanup, "child exited abnormally "
+					"with status: %d", status);
+		switch (status) {
+		case 255:
 			tst_brkm(TBROK, cleanup,
-			    "child exited abnormally; wait status = %d",
-			    status);
+					"memcpy did not generate SIGSEGV");
+		case 0:
+			tst_resm(TPASS, "got SIGSEGV as expected");
+			break;
+		default:
+			tst_brkm(TBROK, cleanup, "got unexpected signal: %d",
+					status);
+			break;
+		}
 
 		/* Change the protection to WRITE. */
 		TEST(mprotect(addr, sizeof(buf), PROT_WRITE));
@@ -185,8 +193,14 @@ int main()
 
 #endif /* UCLINUX */
 
+static void sighandler(int sig)
+{
+	_exit((sig == SIGSEGV) ? 0 : sig);
+}
+
 static void setup()
 {
+	tst_sig(FORK, sighandler, cleanup);
 
 	TEST_PAUSE;
 
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to