diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-09-26 22:51:55 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-09-26 22:51:55 -0400 |
commit | 6cbbd147434b343705dedffc201fe3667f3004f1 (patch) | |
tree | 7abcda87fab28c90652c8f94472bad495f4aba99 | |
parent | 013c2f7aa49f5b683ff28f5e039287cba960e3d6 (diff) | |
download | libc-testsuite-6cbbd147434b343705dedffc201fe3667f3004f1.tar.gz |
add pthread_cond_broadcast test
-rw-r--r-- | pthread.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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; } |