From ed8b7ea7a7bf189fa6ea94bdbaaf1657a68b7a7e Mon Sep 17 00:00:00 2001 From: Jon Simons Date: Sat, 12 Nov 2022 15:36:41 -0500 Subject: [PATCH] tests/pkd: relax pthread_kill assert in `pkd_stop` Relax the `pthread_kill` result assertion in `pkd_stop` to tolerate `ESRCH`, and guard against only `EINVAL` and `ENOTSUP`. On macOS what can happen is that the `pthread_kill` returns `ESRCH` due to the accept thread being already terminated. For that case, the teardown path should proceed to `pthread_join`. Testing notes: - On my macOS setup I consistently encountered `ESRCH` in this codepath, causing pkd tests to fail unnecessarily. With the change, I observe the tests passing. Signed-off-by: Jon Simons Reviewed-by: Jakub Jelen (cherry picked from commit aa206cbfe5c8775667f74a6244728d7d5b9a37c9) --- tests/pkd/pkd_daemon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/pkd/pkd_daemon.c b/tests/pkd/pkd_daemon.c index 5325a5de..70f441b2 100644 --- a/tests/pkd/pkd_daemon.c +++ b/tests/pkd/pkd_daemon.c @@ -589,7 +589,8 @@ void pkd_stop(struct pkd_result *out) { close(pkd_state.server_fd); rc = pthread_kill(ctx.tid, SIGUSR1); - assert_int_equal(rc, 0); + assert_int_not_equal(rc, EINVAL); + assert_int_not_equal(rc, ENOTSUP); rc = pthread_join(ctx.tid, NULL); assert_int_equal(rc, 0);