diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c index 27d2b6e99..0eedbf4ad 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 0b91065be..12f170ee7 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))