diff options
author | unknown <guilhem@gbichot3.local> | 2006-09-14 01:37:41 +0200 |
---|---|---|
committer | unknown <guilhem@gbichot3.local> | 2006-09-14 01:37:41 +0200 |
commit | 336bbb52b1de43fa1ea34d6727e7a0ac2fc9fe73 (patch) | |
tree | 58b37846dac178dd502a99ebb35de09966462fbb /unittest | |
parent | 63387829420571ab82debaa32267d195f31e0db6 (diff) | |
download | mariadb-git-336bbb52b1de43fa1ea34d6727e7a0ac2fc9fe73.tar.gz |
fixes for the my_atomic-t unit test:
- compiler warning
- detection of pthread_create failure (you will see this message
only if you run with "make test-verbose" in unittest; otherwise
unit.pl masks all messages from the test but "ok" ones.
- the test fails randomly on some machines (I filed it as BUG#22320),
on one host it looks like a crash at exit() which a sleep(2) makes
disappear. So I add the sleep(2), which can be removed
when BUG#22320 is fixed.
unittest/mysys/my_atomic-t.c:
- fix for compiler warning on 64-bit "cast from pointer to integer of
different size". Casting to long and then to int. We'll use intptr
instead later.
- detect if pthread_create fails.
- sleep(2) until BUG#22320 is fixed
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/mysys/my_atomic-t.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c index 4e2e496c3b1..fe93b0942ce 100644 --- a/unittest/mysys/my_atomic-t.c +++ b/unittest/mysys/my_atomic-t.c @@ -32,7 +32,7 @@ pthread_handler_t test_atomic_add_handler(void *arg) { int m=*(int *)arg; int32 x; - for (x=((int)(&m)); m ; m--) + for (x=((int)((long)(&m))); m ; m--) { x=x*m+0x87654321; my_atomic_rwlock_wrlock(&rwl); @@ -104,7 +104,7 @@ pthread_handler_t test_atomic_cas_handler(void *arg) { int m=*(int *)arg, ok; int32 x,y; - for (x=((int)(&m)); m ; m--) + for (x=((int)((long)(&m))); m ; m--) { my_atomic_rwlock_wrlock(&rwl); y=my_atomic_load32(&a32); @@ -140,13 +140,21 @@ void test_atomic(const char *test, pthread_handler handler, int n, int m) diag("Testing %s with %d threads, %d iterations... ", test, n, m); for (N=n ; n ; n--) - pthread_create(&t, &thr_attr, handler, &m); + { + if (pthread_create(&t, &thr_attr, handler, &m) != 0) + { + diag("Could not create thread"); + a32= 1; + goto err; + } + } pthread_mutex_lock(&mutex); while (N) pthread_cond_wait(&cond, &mutex); pthread_mutex_unlock(&mutex); now=my_getsystime()-now; +err: ok(a32 == 0, "tested %s in %g secs", test, ((double)now)/1e7); } @@ -170,6 +178,12 @@ int main() test_atomic("my_atomic_swap32", test_atomic_swap_handler, 100,10000); test_atomic("my_atomic_cas32", test_atomic_cas_handler, 100,10000); + /* + workaround until we know why it crashes randomly on some machine + (BUG#22320). + */ + sleep(2); + pthread_mutex_destroy(&mutex); pthread_cond_destroy(&cond); pthread_attr_destroy(&thr_attr); |