Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jun 2025 17:17:37 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 7b26124ae106 - main - libtpool/tests: Fix a flaky test
Message-ID:  <202506251717.55PHHbV1061111@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=7b26124ae106283952e1e61d07f0eecda5c361a0

commit 7b26124ae106283952e1e61d07f0eecda5c361a0
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-06-25 14:19:27 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-06-25 17:17:08 +0000

    libtpool/tests: Fix a flaky test
    
    I occasionally see failures due to pthread_barrier_wait() not returning
    0.  There is another possible non-error return value, so allow that too.
    While here, check the result in tp_delay() as well.
    
    Fixes:          5c1ba994a8bc ("Add a regression test for a libtpool bug")
    Differential Revision:  https://reviews.freebsd.org/D50967
---
 cddl/lib/libtpool/tests/libtpool_test.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/cddl/lib/libtpool/tests/libtpool_test.c b/cddl/lib/libtpool/tests/libtpool_test.c
index 42726a13420c..42bce269cb23 100644
--- a/cddl/lib/libtpool/tests/libtpool_test.c
+++ b/cddl/lib/libtpool/tests/libtpool_test.c
@@ -11,9 +11,12 @@ static void
 tp_delay(void *arg)
 {
 	pthread_barrier_t *barrier = arg;
+	int r;
 
 	/* Block this task until all thread pool workers have been created. */
-	pthread_barrier_wait(barrier);
+	r = pthread_barrier_wait(barrier);
+	ATF_REQUIRE_MSG(r == 0 || r == PTHREAD_BARRIER_SERIAL_THREAD,
+	    "pthread_barrier_wait failed: %s", strerror(r));
 }
 
 /*
@@ -38,7 +41,6 @@ ATF_TC_BODY(complete_exhaustion, tc)
 	int nworkers;
 	int r, i;
 
-
 	len = sizeof(max_threads_per_proc);
 	r = sysctlbyname("kern.threads.max_threads_per_proc",
 	    &max_threads_per_proc, &len, NULL, 0);
@@ -65,7 +67,9 @@ ATF_TC_BODY(complete_exhaustion, tc)
 	ATF_REQUIRE_EQ(tpool_dispatch(tp1, tp_delay, NULL), -1);
 
 	/* Cleanup */
-	ATF_REQUIRE_EQ(pthread_barrier_wait(&barrier), 0);
+	r = pthread_barrier_wait(&barrier);
+	ATF_REQUIRE_MSG(r == 0 || r == PTHREAD_BARRIER_SERIAL_THREAD,
+	    "pthread_barrier_wait failed: %s", strerror(r));
 	tpool_wait(tp1);
 	tpool_wait(tp0);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202506251717.55PHHbV1061111>