summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Marie <semarie@online.fr>2024-01-19 16:08:21 +0000
committerDaniel Stone <daniels@collabora.com>2024-02-21 15:46:41 +0000
commit791912c67867b84e15f7a70d5f716c9dd8c2c01b (patch)
tree24f3d33161601d756f1d154639d4c01894ac7f31
parenta74aa93394a6d572eb48b1898658dad3e0c5f720 (diff)
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>
-rw-r--r--tests/test-compositor.c23
-rw-r--r--tests/test-runner.c21
2 files changed, 18 insertions, 26 deletions
diff --git a/tests/test-compositor.c b/tests/test-compositor.c
index 49d76d6..8648fb6 100644
--- a/tests/test-compositor.c
+++ b/tests/test-compositor.c
@@ -103,26 +103,23 @@ handle_client_destroy(void *data)
{
struct client_info *ci = data;
struct display *d;
- siginfo_t status;
+ int status;
d = ci->display;
- assert(waitid(P_PID, ci->pid, &status, WEXITED) != -1);
+ assert(waitpid(ci->pid, &status, 0) != -1);
- switch (status.si_code) {
- case CLD_KILLED:
- case CLD_DUMPED:
+ if (WIFSIGNALED(status)) {
fprintf(stderr, "Client '%s' was killed by signal %d\n",
- ci->name, status.si_status);
- ci->kill_code = status.si_status;
- break;
- case CLD_EXITED:
- if (status.si_status != EXIT_SUCCESS)
+ ci->name, WTERMSIG(status));
+ ci->kill_code = WTERMSIG(status);
+
+ } else if (WIFEXITED(status)) {
+ if (WEXITSTATUS(status) != EXIT_SUCCESS)
fprintf(stderr, "Client '%s' exited with code %d\n",
- ci->name, status.si_status);
+ ci->name, WEXITSTATUS(status));
- ci->exit_code = status.si_status;
- break;
+ ci->exit_code = WEXITSTATUS(status);
}
++d->clients_terminated_no;
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) {