when overcommit_memory=0, mmap() will be destroyed in two below scenario:
 1) MAP_FAILED with ENOMEM,
 2) oom_killer kill it.
without the patch, it just catched oom_killer scenario,
the patch fixed it.

Signed-off-by: Zhouping Liu <z...@redhat.com>
---
 testcases/kernel/mem/tunable/min_free_kbytes.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/mem/tunable/min_free_kbytes.c b/testcases/kernel/mem/tunable/min_free_kbytes.c
index a69e129..00ead04 100644
--- a/testcases/kernel/mem/tunable/min_free_kbytes.c
+++ b/testcases/kernel/mem/tunable/min_free_kbytes.c
@@ -92,7 +92,6 @@ int main(int argc, char *argv[])
 		exit(0);
 	}
 
-
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		Tst_count = 0;
 
@@ -101,7 +100,6 @@ int main(int argc, char *argv[])
 		test_tune(1);
 	}
 
-
 	if (kill(pid, SIGUSR1) == -1)
 		tst_brkm(TBROK|TERRNO, cleanup, "kill %d", pid);
 	if (waitpid(pid, &status, WUNTRACED|WCONTINUED)  == -1)
@@ -150,10 +148,21 @@ static void test_tune(unsigned long overcommit_policy)
 			if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
 				tst_resm(TFAIL,
 				    "child unexpectedly failed: %d", status);
-		} else {
+		} else if (overcommit_policy == 1) {
 			if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGKILL)
 				tst_resm(TFAIL,
 				    "child unexpectedly failed: %d", status);
+		} else {
+			if (WIFEXITED(status)) {
+				if (WEXITSTATUS(status) != 0) {
+					tst_resm(TFAIL, "child unexpectedly "
+					    "failed: %d", status);
+				}
+			} else if (!WIFSIGNALED(status) ||
+				    WTERMSIG(status) != SIGKILL) {
+				tst_resm(TFAIL,
+				    "child unexpectedly failed: %d", status);
+			}
 		}
 	}
 }
@@ -178,7 +187,7 @@ static int eatup_mem(unsigned long overcommit_policy)
 		addrs[i] = mmap(NULL, MAP_SIZE, PROT_READ|PROT_WRITE,
 		    MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
 		if (addrs[i] == MAP_FAILED) {
-			if (overcommit_policy != 2 || errno != ENOMEM) {
+			if (overcommit_policy != 1 && errno != ENOMEM) {
 				perror("mmap");
 				ret = -1;
 			}
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to