diff options
| author | Sébastien Marie <semarie@online.fr> | 2024-01-19 16:08:21 +0000 |
|---|---|---|
| committer | Daniel Stone <daniels@collabora.com> | 2024-02-21 15:46:41 +0000 |
| commit | 791912c67867b84e15f7a70d5f716c9dd8c2c01b (patch) | |
| tree | 24f3d33161601d756f1d154639d4c01894ac7f31 /tests/test-runner.c | |
| parent | protocol: mention wl_surface events from wl_output.{scale,transform} (diff) | |
| download | wayland-791912c67867b84e15f7a70d5f716c9dd8c2c01b.tar wayland-791912c67867b84e15f7a70d5f716c9dd8c2c01b.tar.gz wayland-791912c67867b84e15f7a70d5f716c9dd8c2c01b.tar.bz2 wayland-791912c67867b84e15f7a70d5f716c9dd8c2c01b.tar.lz wayland-791912c67867b84e15f7a70d5f716c9dd8c2c01b.tar.xz wayland-791912c67867b84e15f7a70d5f716c9dd8c2c01b.tar.zst wayland-791912c67867b84e15f7a70d5f716c9dd8c2c01b.zip | |
compat: prefer waitpid() over waitid()
while both are defined by POSIX, waitpid() is more common than waitid().
Signed-off-by: Sebastien Marie <semarie@online.fr>
Diffstat (limited to 'tests/test-runner.c')
| -rw-r--r-- | tests/test-runner.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/tests/test-runner.c b/tests/test-runner.c index d07dab1..ea2715e 100644 --- a/tests/test-runner.c +++ b/tests/test-runner.c @@ -315,7 +315,7 @@ int main(int argc, char *argv[]) const struct test *t; pid_t pid; int total, pass; - siginfo_t info; + int info; if (isatty(fileno(stderr))) is_atty = 1; @@ -358,37 +358,32 @@ int main(int argc, char *argv[]) if (pid == 0) run_test(t); /* never returns */ - if (waitid(P_PID, pid, &info, WEXITED)) { + if (waitpid(pid, &info, 0) == -1) { stderr_set_color(RED); - fprintf(stderr, "waitid failed: %s\n", + fprintf(stderr, "waitpid failed: %s\n", strerror(errno)); stderr_reset_color(); abort(); } - switch (info.si_code) { - case CLD_EXITED: - if (info.si_status == EXIT_SUCCESS) + if (WIFEXITED(info)) { + if (WEXITSTATUS(info) == EXIT_SUCCESS) success = !t->must_fail; else success = t->must_fail; stderr_set_color(success ? GREEN : RED); fprintf(stderr, "test \"%s\":\texit status %d", - t->name, info.si_status); + t->name, WEXITSTATUS(info)); - break; - case CLD_KILLED: - case CLD_DUMPED: + } else if (WIFSIGNALED(info)) { if (t->must_fail) success = 1; stderr_set_color(success ? GREEN : RED); fprintf(stderr, "test \"%s\":\tsignal %d", - t->name, info.si_status); - - break; + t->name, WTERMSIG(info)); } if (success) { |
