@@ -362,6 +362,14 @@ void tst_set_max_runtime(int max_runtime);
*/
char *tst_get_tmpdir(void);
+/*
+ * Validates exit status of child processes
+ */
+int tst_validate_children_(const char *file, const int lineno,
+ unsigned int count);
+#define tst_validate_children(child_count) \
+ tst_validate_children_(__FILE__, __LINE__, (child_count))
+
#ifndef TST_NO_DEFAULT_MAIN
static struct tst_test test;
@@ -49,3 +49,23 @@ const char *tst_strstatus(int status)
return invalid(status);
}
+
+int tst_validate_children_(const char *file, const int lineno,
+ unsigned int count)
+{
+ unsigned int i;
+ int status;
+ pid_t pid;
+
+ for (i = 0; i < count; i++) {
+ pid = SAFE_WAITPID(-1, &status, 0);
+
+ if (!WIFEXITED(status) || WEXITSTATUS(status)) {
+ tst_res_(file, lineno, TFAIL, "Child %d: %s", pid,
+ tst_strstatus(status));
+ return 1;
+ }
+ }
+
+ return 0;
+}
The function waits for given number of child processes and validates that they have all exited without error. Signed-off-by: Martin Doucha <mdoucha@suse.cz> --- Changes since v1: - Moved tst_validate_children_() to lib/tst_status.c - Simplified the code using tst_strstatus() include/tst_test.h | 8 ++++++++ lib/tst_status.c | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+)