[CRIU] [PATCH] zdtm/stopped: fix stopped test

Konstantin Neumoin kneumoin at parallels.com
Tue Oct 7 04:28:30 PDT 2014


The main problem with the
test that it's never 'fail'.
Test can only 'pass' or hangs.

Signed-off-by: Konstantin Neumoin <kneumoin at parallels.com>
---
 test/zdtm/live/static/stopped.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/test/zdtm/live/static/stopped.c b/test/zdtm/live/static/stopped.c
index 6194d6b..b74b7ff 100644
--- a/test/zdtm/live/static/stopped.c
+++ b/test/zdtm/live/static/stopped.c
@@ -33,35 +33,42 @@ int main(int argc, char **argv)
 			return 1;
 		}
 
-		ret = read(p[0], &c, 1);
-		if (ret != 0) {
-			err("Unable to read: %d", ret);
-			return 1;
-		}
-
 		return 0;
 	}
 	close(p[0]);
 
 	kill(pid, SIGSTOP);
+
 	write(p[1], "0", 1);
+	close(p[1]);
 
 	test_daemon();
 	test_waitsig();
 
+	// Return immediately if child run or stopped(by SIGSTOP)
+	if (waitpid(pid, &status, WUNTRACED | WCONTINUED) == -1) {
+		err("Unable to wait child");
+		goto out;
+	}
+
+	if (WIFSTOPPED(status))
+		test_msg("The procces stopped\n");
+	else{
+		fail("The process doesn't stopped");
+		goto out;
+	}
+
 	kill(pid, SIGCONT);
-	if (waitpid(pid, &status, WCONTINUED) == -1) {
+
+	if (waitpid(pid, &status, 0) == -1) {
 		err("Unable to wait child");
 		goto out;
 	}
 
-	if (WIFCONTINUED(status))
+	if (WIFEXITED(status))
 		pass();
 	else
 		fail("The process doesn't continue");
 out:
-	close(p[1]);
-	waitpid(pid, &status, 0);
-
 	return 0;
 }
-- 
1.7.11.7



More information about the CRIU mailing list