summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-09-26 22:51:55 -0400
committerRich Felker <dalias@aerifal.cx>2011-09-26 22:51:55 -0400
commit6cbbd147434b343705dedffc201fe3667f3004f1 (patch)
tree7abcda87fab28c90652c8f94472bad495f4aba99
parent013c2f7aa49f5b683ff28f5e039287cba960e3d6 (diff)
downloadlibc-testsuite-6cbbd147434b343705dedffc201fe3667f3004f1.tar.gz
add pthread_cond_broadcast test
-rw-r--r--pthread.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/pthread.c b/pthread.c
index b7fb22f..0ff6821 100644
--- a/pthread.c
+++ b/pthread.c
@@ -236,7 +236,7 @@ int test_pthread(void)
TEST(r, pthread_mutex_destroy(&mtx), 0, "%d != %d");
TEST(r, pthread_cond_destroy(&cond), 0, "%d != %d");
-
+ /* Condition variables with multiple waiters */
TEST(r, pthread_mutex_init(&mtx, 0), 0, "%d != %d");
TEST(r, pthread_cond_init(&cond, 0), 0, "%d != %d");
TEST(r, pthread_mutex_lock(&mtx), 0, "%d != %d");
@@ -262,6 +262,25 @@ int test_pthread(void)
TEST(r, pthread_mutex_destroy(&mtx), 0, "%d != %d");
TEST(r, pthread_cond_destroy(&cond), 0, "%d != %d");
+ /* Condition variables with broadcast signals */
+ TEST(r, pthread_mutex_init(&mtx, 0), 0, "%d != %d");
+ TEST(r, pthread_cond_init(&cond, 0), 0, "%d != %d");
+ TEST(r, pthread_mutex_lock(&mtx), 0, "%d != %d");
+ foo[0] = 1;
+ TEST(r, pthread_create(&td1, 0, start8, (void *[]){ &cond, &mtx, foo }), 0, "%d != %d");
+ TEST(r, pthread_create(&td2, 0, start8, (void *[]){ &cond, &mtx, foo }), 0, "%d != %d");
+ TEST(r, pthread_create(&td3, 0, start8, (void *[]){ &cond, &mtx, foo }), 0, "%d != %d");
+ TEST(r, pthread_mutex_unlock(&mtx), 0, "%d != %d");
+ nanosleep(&(struct timespec){.tv_nsec=1000000}, 0);
+ TEST(r, pthread_mutex_lock(&mtx), 0, "%d != %d");
+ foo[0] = 0;
+ TEST(r, pthread_mutex_unlock(&mtx), 0, "%d != %d");
+ TEST(r, pthread_cond_broadcast(&cond), 0, "%d != %d");
+ TEST(r, pthread_join(td1, 0), 0, "%d != %d");
+ TEST(r, pthread_join(td2, 0), 0, "%d != %d");
+ TEST(r, pthread_join(td3, 0), 0, "%d != %d");
+ TEST(r, pthread_mutex_destroy(&mtx), 0, "%d != %d");
+ TEST(r, pthread_cond_destroy(&cond), 0, "%d != %d");
return err;
}