Skip to contentSkip to conversation

pidns17 testcase bugfix/cleanup

PATCH In review Sukadev Bhattiprolu 2 participants 2 messages Jun 17, 2009 – Jun 18, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pidns17 testcase bugfix/cleanup

Fix minor bugs in the test case that cause the test to fail intermittently. Also, print more debug info when test fails.

This fixes a bug reported by Sachin P. Sant.

---
 testcases/kernel/containers/pidns/pidns17.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
testcases/kernel/containers/pidns/pidns17.c +11 -6
Index: ltp-full-20090331/testcases/kernel/containers/pidns/pidns17.c
===================================================================
@@ -74,8 +74,10 @@ int child_fn(void *arg)
 
 	/* Spawn many children */
 	for (i = 0; i < 10; i++)
-		if ((children[i] = fork()) == 0)
-			sleep(10);
+		if ((children[i] = fork()) == 0) {
+			pause();
+			exit(2);
+		}
 
 	/* wait for last child to get scheduled */
 	sleep(1);
@@ -86,13 +88,16 @@ int child_fn(void *arg)
 	}
 
 	for (i = 0; i < 10; i++) {
-		if (waitpid(children[i], &status, WNOHANG) == -1) {
+		if (waitpid(children[i], &status, 0) == -1) {
 			tst_resm(TBROK, "cinit: waitpid() failed(%s)",\
 					strerror(errno));
 			cleanup();
 		}
-		if (!(WIFSIGNALED(&status) && WTERMSIG(status) == SIGUSR1)) {
-			tst_resm(TFAIL, "cinit: found a child alive still.");
+		if (!(WIFSIGNALED(status) && WTERMSIG(status) == SIGUSR1)) {
+			tst_resm(TFAIL, "cinit: found a child alive still "
+					"%d exit: %d, %d, signal %d, %d", i,
+					WIFEXITED(status), WEXITSTATUS(status),
+					WIFSIGNALED(status), WTERMSIG(status));
 			cleanup();
 		}
 	}
@@ -125,7 +130,7 @@ int main(int argc, char *argv[])
 	}
 
 	sleep(1);
-	if (wait(&status) < 0)
+	if (waitpid(-1, &status, __WALL) < 0)
 		tst_resm(TWARN, "parent: waitpid() failed.");
 
 	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw
Quoted 6 lines · Sukadev Bhattiprolu

Fix minor bugs in the test case that cause the test to fail intermittently. Also, print more debug info when test fails.

This fixes a bug reported by Sachin P. Sant.

Thanks. Merged.

Regards--
Subrata

Quoted 42 lines
---
 testcases/kernel/containers/pidns/pidns17.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Index: ltp-full-20090331/testcases/kernel/containers/pidns/pidns17.c
===================================================================

testcases/kernel/containers/pidns/pidns17.c +10 -5
@@ -74,8 +74,10 @@ int child_fn(void *arg)
 
 	/* Spawn many children */
 	for (i = 0; i < 10; i++)
-		if ((children[i] = fork()) == 0)
-			sleep(10);
+		if ((children[i] = fork()) == 0) {
+			pause();
+			exit(2);
+		}
 
 	/* wait for last child to get scheduled */
 	sleep(1);
@@ -86,13 +88,16 @@ int child_fn(void *arg)
 	}
 
 	for (i = 0; i < 10; i++) {
-		if (waitpid(children[i], &status, WNOHANG) == -1) {
+		if (waitpid(children[i], &status, 0) == -1) {
 			tst_resm(TBROK, "cinit: waitpid() failed(%s)",\
 					strerror(errno));
 			cleanup();
 		}
-		if (!(WIFSIGNALED(&status) && WTERMSIG(status) == SIGUSR1)) {
-			tst_resm(TFAIL, "cinit: found a child alive still.");
+		if (!(WIFSIGNALED(status) && WTERMSIG(status) == SIGUSR1)) {
+			tst_resm(TFAIL, "cinit: found a child alive still "
+					"%d exit: %d, %d, signal %d, %d", i,
+					WIFEXITED(status), WEXITSTATUS(status),
+					WIFSIGNALED(status), WTERMSIG(status));
 			cleanup();
 		}
 	}

testcases/kernel/containers/pidns/pidns17.c int main(int argc, char *argv[]) · line 136

Quoted 8 lines
testcases/kernel/containers/pidns/pidns17.c +1 -1
@@ -125,7 +130,7 @@ int main(int argc, char *argv[])
 	}
 
 	sleep(1);
-	if (wait(&status) < 0)
+	if (waitpid(-1, &status, __WALL) < 0)
 		tst_resm(TWARN, "parent: waitpid() failed.");
 
 	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list