From 188b1956353ab5f07546705dc512361a66afd9e2 Mon Sep 17 00:00:00 2001 From: ad Date: Sat, 23 Dec 2006 17:44:12 +0000 Subject: [PATCH] Fix this test (it seems to have depended on the specific behaviour of our libpthread). --- regress/lib/libpthread/barrier1/barrier1.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/regress/lib/libpthread/barrier1/barrier1.c b/regress/lib/libpthread/barrier1/barrier1.c index 8071f01f1261..75d592fd79a9 100644 --- a/regress/lib/libpthread/barrier1/barrier1.c +++ b/regress/lib/libpthread/barrier1/barrier1.c @@ -1,4 +1,4 @@ -/* $NetBSD: barrier1.c,v 1.1 2003/01/30 18:23:09 thorpej Exp $ */ +/* $NetBSD: barrier1.c,v 1.2 2006/12/23 17:44:12 ad Exp $ */ #include #include @@ -30,6 +30,9 @@ main(int argc, char *argv[]) err(1, "pthread_barrier_init"); for (i = 0; i < COUNT; i++) { + pthread_mutex_lock(&mutex); + assert(after_barrier_count == 0); + pthread_mutex_unlock(&mutex); ret = pthread_create(&new[i], NULL, threadfunc, (void *)(long)i); if (ret != 0) @@ -38,15 +41,18 @@ main(int argc, char *argv[]) } for (i = 0; i < COUNT; i++) { - pthread_mutex_lock(&mutex); - assert(after_barrier_count >= (COUNT - i)); - pthread_mutex_unlock(&mutex); ret = pthread_join(new[i], &joinval); if (ret != 0) err(1, "pthread_join"); + pthread_mutex_lock(&mutex); + assert(after_barrier_count > i); + pthread_mutex_unlock(&mutex); printf("main joined with thread %d\n", i); } + pthread_mutex_lock(&mutex); + assert(after_barrier_count == COUNT); + pthread_mutex_unlock(&mutex); assert(serial_count == 1); return 0;