diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Bmakefile | 10 | ||||
-rw-r--r-- | tests/GNUmakefile | 10 | ||||
-rw-r--r-- | tests/Makefile | 10 | ||||
-rw-r--r-- | tests/cancel4.c | 4 | ||||
-rw-r--r-- | tests/condvar2.c | 2 | ||||
-rw-r--r-- | tests/semaphore1.c | 4 | ||||
-rw-r--r-- | tests/tsd1.c | 38 |
7 files changed, 43 insertions, 35 deletions
diff --git a/tests/Bmakefile b/tests/Bmakefile index ff8c95b..7e18d56 100644 --- a/tests/Bmakefile +++ b/tests/Bmakefile @@ -91,11 +91,12 @@ PASSES= loadfree.pass \ mutex6s.pass mutex6es.pass mutex6rs.pass \ mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \ mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \ - count1.pass once1.pass once2.pass once3.pass once4.pass tsd1.pass \ + count1.pass once1.pass once2.pass once3.pass once4.pass \ self2.pass \ cancel1.pass cancel2.pass \ semaphore4.pass semaphore4t.pass \ - delay1.pass delay2.pass eyal1.pass \ + barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass \ + tsd1.pass delay1.pass delay2.pass eyal1.pass \ condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass \ condvar4.pass condvar5.pass condvar6.pass \ condvar7.pass condvar8.pass condvar9.pass \ @@ -108,7 +109,6 @@ PASSES= loadfree.pass \ cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \ priority1.pass priority2.pass inherit1.pass \ spin1.pass spin2.pass spin3.pass spin4.pass \ - barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass \ exception1.pass exception2.pass exception3.pass \ cancel9.pass create3.pass stress1.pass @@ -220,7 +220,7 @@ benchtest2.bench: benchtest3.bench: benchtest4.bench: benchtest5.bench: -barrier1.pass: +barrier1.pass: semaphore4.pass barrier2.pass: barrier1.pass barrier3.pass: barrier2.pass barrier4.pass: barrier3.pass @@ -341,6 +341,6 @@ spin2.pass: spin1.pass spin3.pass: spin2.pass spin4.pass: spin3.pass stress1.pass: barrier5.pass -tsd1.pass: join1.pass +tsd1.pass: barrier5.pass join1.pass valid1.pass: join1.pass valid2.pass: valid1.pass diff --git a/tests/GNUmakefile b/tests/GNUmakefile index fc36c32..15d8dcc 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -86,10 +86,11 @@ TESTS = sizes loadfree \ mutex4 mutex6 mutex6n mutex6e mutex6r \ mutex6s mutex6es mutex6rs \ mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \ - count1 once1 once2 once3 once4 tsd1 self2 \ + count1 once1 once2 once3 once4 self2 \ cancel1 cancel2 \ semaphore4 semaphore4t \ - delay1 delay2 eyal1 \ + barrier1 barrier2 barrier3 barrier4 barrier5 \ + tsd1 delay1 delay2 eyal1 \ condvar3 condvar3_1 condvar3_2 condvar3_3 \ condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ errno1 \ @@ -100,7 +101,6 @@ TESTS = sizes loadfree \ cleanup0 cleanup1 cleanup2 cleanup3 \ priority1 priority2 inherit1 \ spin1 spin2 spin3 spin4 \ - barrier1 barrier2 barrier3 barrier4 barrier5 \ exception1 exception2 exception3 \ cancel9 create3 @@ -183,7 +183,7 @@ benchtest5.bench: stress1.pass: -barrier1.pass: +barrier1.pass: semaphore4.pass barrier2.pass: barrier1.pass barrier3.pass: barrier2.pass barrier4.pass: barrier3.pass @@ -304,7 +304,7 @@ spin1.pass: spin2.pass: spin1.pass spin3.pass: spin2.pass spin4.pass: spin3.pass -tsd1.pass: join1.pass +tsd1.pass: barrier5.pass join1.pass valid1.pass: join1.pass valid2.pass: valid1.pass diff --git a/tests/Makefile b/tests/Makefile index f227914..0a7738a 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -95,11 +95,12 @@ PASSES= sizes.pass loadfree.pass \ mutex6s.pass mutex6es.pass mutex6rs.pass \ mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \ mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \ - count1.pass once1.pass once2.pass once3.pass once4.pass tsd1.pass \ + count1.pass once1.pass once2.pass once3.pass once4.pass \ self2.pass \ cancel1.pass cancel2.pass \ semaphore4.pass semaphore4t.pass \ - delay1.pass delay2.pass eyal1.pass \ + barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass \ + tsd1.pass delay1.pass delay2.pass eyal1.pass \ condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass \ condvar4.pass condvar5.pass condvar6.pass \ condvar7.pass condvar8.pass condvar9.pass \ @@ -113,7 +114,6 @@ PASSES= sizes.pass loadfree.pass \ cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \ priority1.pass priority2.pass inherit1.pass \ spin1.pass spin2.pass spin3.pass spin4.pass \ - barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass \ exception1.pass exception2.pass exception3.pass \ cancel9.pass create3.pass @@ -276,7 +276,7 @@ benchtest5.bench: stress1.pass: -barrier1.pass: +barrier1.pass: semaphore4.pass barrier2.pass: barrier1.pass barrier3.pass: barrier2.pass barrier4.pass: barrier3.pass @@ -396,6 +396,6 @@ spin1.pass: spin2.pass: spin1.pass spin3.pass: spin2.pass spin4.pass: spin3.pass -tsd1.pass: join1.pass +tsd1.pass: barrier5.pass join1.pass valid1.pass: join1.pass valid2.pass: valid1.pass diff --git a/tests/cancel4.c b/tests/cancel4.c index 1561ea6..6d6d3dc 100644 --- a/tests/cancel4.c +++ b/tests/cancel4.c @@ -112,10 +112,10 @@ mythread(void * arg) assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0); /* - * We wait up to 10 seconds, waking every 0.1 seconds, + * We wait up to 2 seconds, waking every 0.1 seconds, * for a cancelation to be applied to us. */ - for (bag->count = 0; bag->count < 100; bag->count++) + for (bag->count = 0; bag->count < 20; bag->count++) Sleep(100); return (void *) result; diff --git a/tests/condvar2.c b/tests/condvar2.c index cfc68af..33f1d3f 100644 --- a/tests/condvar2.c +++ b/tests/condvar2.c @@ -102,7 +102,7 @@ main() abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - abstime.tv_sec += 5; + abstime.tv_sec += 1; assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == ETIMEDOUT); diff --git a/tests/semaphore1.c b/tests/semaphore1.c index b5b2050..4327e73 100644 --- a/tests/semaphore1.c +++ b/tests/semaphore1.c @@ -86,7 +86,7 @@ thr(void * arg) if ( result == -1 ) { int err = errno; - perror("thread: sem_trywait 1: expected error"); // No error + perror("thread: sem_trywait 1: expect an EAGAIN error"); // No error assert(err == EAGAIN); } else @@ -131,7 +131,7 @@ main() if ( result == -1 ) { int err = errno; - perror("main: sem_trywait 1: expected error"); // No error + perror("main: sem_trywait 1: expect an EAGAIN error"); // No error assert(err == EAGAIN); } else diff --git a/tests/tsd1.c b/tests/tsd1.c index 6e21d2a..4d89165 100644 --- a/tests/tsd1.c +++ b/tests/tsd1.c @@ -34,6 +34,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * + * -------------------------------------------------------------------------- + * * Description: * - * @@ -77,10 +79,15 @@ #include <sched.h> #include "test.h" +enum { + NUM_THREADS = 100 +}; + static pthread_key_t key = NULL; -static int accesscount[10]; -static int thread_set[10]; -static int thread_destroyed[10]; +static int accesscount[NUM_THREADS]; +static int thread_set[NUM_THREADS]; +static int thread_destroyed[NUM_THREADS]; +static pthread_barrier_t startBarrier; static void destroy_key(void * arg) @@ -117,10 +124,7 @@ setkey(void * arg) static void * mythread(void * arg) { - while (key == NULL) - { - sched_yield(); - } + (void) pthread_barrier_wait(&startBarrier); setkey(arg); @@ -134,22 +138,24 @@ main() { int i; int fail = 0; - pthread_t thread[10]; + pthread_t thread[NUM_THREADS]; - for (i = 1; i < 5; i++) + assert(pthread_barrier_init(&startBarrier, NULL, NUM_THREADS/2) == 0); + + for (i = 1; i < NUM_THREADS/2; i++) { accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); } - Sleep(2000); - /* * Here we test that existing threads will get a key created * for them. */ assert(pthread_key_create(&key, destroy_key) == 0); + (void) pthread_barrier_wait(&startBarrier); + /* * Test main thread key. */ @@ -160,16 +166,16 @@ main() * Here we test that new threads will get a key created * for them. */ - for (i = 5; i < 10; i++) + for (i = NUM_THREADS/2; i < NUM_THREADS; i++) { - accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; + accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); } /* * Wait for all threads to complete. */ - for (i = 1; i < 10; i++) + for (i = 1; i < NUM_THREADS; i++) { int result = 0; @@ -178,7 +184,9 @@ main() assert(pthread_key_delete(key) == 0); - for (i = 1; i < 10; i++) + assert(pthread_barrier_destroy(&startBarrier) == 0); + + for (i = 1; i < NUM_THREADS; i++) { /* * The counter is incremented once when the key is set to |