[CRIU] [PATCH] zdtm: return non-zero code in a error case

Andrey Vagin avagin at openvz.org
Wed Oct 21 07:15:43 PDT 2015


From: Andrew Vagin <avagin at openvz.org>

Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 test/zdtm/lib/test.c    | 26 ++++++++++++++++----------
 test/zdtm/lib/zdtmtst.h |  2 ++
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c
index 27d2b6e..0eedbf4 100644
--- a/test/zdtm/lib/test.c
+++ b/test/zdtm/lib/test.c
@@ -189,15 +189,18 @@ void test_init(int argc, char **argv)
 
 		if (futex_get(&sig_received) == SIGCHLD) {
 			int ret;
-			waitpid(pid, &ret, 0);
+			if (waitpid(pid, &ret, 0) != pid) {
+				pr_perror("Unable to wait %d, pid");
+				exit(1);
+			}
 
 			if (WIFEXITED(ret)) {
-				pr_perror("Test exited unexpectedly with code %d", WEXITSTATUS(ret));
-				exit(0);
+				pr_err("Test exited unexpectedly with code %d\n", WEXITSTATUS(ret));
+				exit(1);
 			}
 			if (WIFSIGNALED(ret)) {
-				pr_perror("Test exited on unexpected signal %d", WTERMSIG(ret));
-				exit(0);
+				pr_err("Test exited on unexpected signal %d\n", WTERMSIG(ret));
+				exit(1);
 			}
 		}
 
@@ -321,15 +324,18 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags,
 
 	if (futex_get(&sig_received) == SIGCHLD) {
 		int ret;
-		waitpid(pid, &ret, 0);
+		if (waitpid(pid, &ret, 0) != pid) {
+			pr_perror("Unable to wait %d", pid);
+			exit(1);
+		}
 
 		if (WIFEXITED(ret)) {
-			pr_perror("Test exited unexpectedly with code %d", WEXITSTATUS(ret));
-			exit(0);
+			pr_err("Test exited unexpectedly with code %d\n", WEXITSTATUS(ret));
+			exit(1);
 		}
 		if (WIFSIGNALED(ret)) {
-			pr_perror("Test exited on unexpected signal %d", WTERMSIG(ret));
-			exit(0);
+			pr_err("Test exited on unexpected signal %d\n", WTERMSIG(ret));
+			exit(1);
 		}
 	}
 
diff --git a/test/zdtm/lib/zdtmtst.h b/test/zdtm/lib/zdtmtst.h
index 0b91065..12f170e 100644
--- a/test/zdtm/lib/zdtmtst.h
+++ b/test/zdtm/lib/zdtmtst.h
@@ -102,6 +102,8 @@ extern int parse_opt_string(char *param, void *arg);
 extern void setup_outfile(void);
 extern int test_log_init(const char *outfile, const char *suffix);
 extern int zdtm_seccomp;
+#define pr_err(format, arg...) \
+	test_msg("ERR: %s:%d: " format, __FILE__, __LINE__, ## arg)
 #define pr_perror(format, arg...)	\
 	test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", \
 		__FILE__, __LINE__, ## arg, errno, strerror(errno))
-- 
2.4.3



More information about the CRIU mailing list