Merge branch 'tizen' into security-manager
[platform/core/test/security-tests.git] / src / common / tests_common.cpp
index e34f401..d08893c 100644 (file)
@@ -26,6 +26,7 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <unistd.h>
 #include <grp.h>
 #include <errno.h>
@@ -231,10 +232,17 @@ void removeDir(const std::string &path)
     RUNNER_ASSERT_ERRNO_MSG(0 == rmdir(path.c_str()), "rmdir for <" << path << "> failed");
 }
 
+void waitPid(pid_t pid)
+{
+    int status;
+    pid_t ret = waitpid(pid, &status, 0);
+    RUNNER_ASSERT_MSG((ret != -1) && WIFEXITED(status) && WEXITSTATUS(status) == 0,
+        "Child process exited abnormally" <<
+        ": ret=" << ret << ", errno=" << errno << ", status=" << status);
+}
 // changes process label
 void change_label(const char* label)
 {
     int ret = smack_set_label_for_self(label);
     RUNNER_ASSERT_MSG(0 == ret, "Error in smack_set_label_for_self("<<label<<"). Error: " << ret);
 }
-