[CRIU] [PATCH 2/6] test: Helper for checking libcriu test child exit status

Pavel Emelyanov xemul at parallels.com
Wed Jun 25 04:23:35 PDT 2014


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 test/libcriu/test_sub.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/test/libcriu/test_sub.c b/test/libcriu/test_sub.c
index 31361f5..162c331 100644
--- a/test/libcriu/test_sub.c
+++ b/test/libcriu/test_sub.c
@@ -32,6 +32,21 @@ static void what_err_ret_mean(ret)
 	}
 }
 
+static inline int chk_exit(int status, int want)
+{
+	if (WIFEXITED(status)) {
+		if (WEXITSTATUS(status) == want)
+			return 0;
+
+		printf("   `- FAIL (exit %d)\n", WEXITSTATUS(status));
+	} else if (WIFSIGNALED(status))
+		printf("   `- FAIL (die %d)\n", WTERMSIG(status));
+	else
+		printf("   `- FAIL (%#x)\n", status);
+
+	return 1;
+}
+
 static int stop = 0;
 static void sh(int sig)
 {
@@ -126,15 +141,5 @@ err:
 		return -1;
 	}
 
-	if (WIFEXITED(ret)) {
-		if (WEXITSTATUS(ret) == SUCC_ECODE)
-			printf("   `- Success\n");
-		else
-			printf("   `- FAIL ec is %d\n", WEXITSTATUS(ret));
-	} else if (WIFSIGNALED(ret))
-		printf("   `- FAIL killed %d\n", WTERMSIG(ret));
-	else
-		printf("   `- FAIL bs %#x\n", ret);
-
-	return 0;
+	return chk_exit(ret, SUCC_ECODE);
 }
-- 
1.8.4.2




More information about the CRIU mailing list