Add an abstraction layer for threading in tests

This commit is contained in:
Mike Hommey 2012-04-18 18:29:42 +02:00 committed by Jason Evans
parent 188da7c3f5
commit e38e45743f
4 changed files with 45 additions and 55 deletions

View file

@ -2,7 +2,6 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
@ -11,7 +10,7 @@
#include "jemalloc_test.h"
void *
thread_start(void *arg)
je_thread_start(void *arg)
{
int err;
void *p;
@ -106,33 +105,22 @@ int
main(void)
{
int ret = 0;
pthread_t thread;
je_thread_t thread;
malloc_printf("Test begin\n");
thread_start(NULL);
je_thread_start(NULL);
if (pthread_create(&thread, NULL, thread_start, NULL)
!= 0) {
malloc_printf("%s(): Error in pthread_create()\n", __func__);
ret = 1;
goto label_return;
}
pthread_join(thread, (void *)&ret);
je_thread_create(&thread, je_thread_start, NULL);
je_thread_join(thread, (void *)&ret);
thread_start(NULL);
je_thread_start(NULL);
if (pthread_create(&thread, NULL, thread_start, NULL)
!= 0) {
malloc_printf("%s(): Error in pthread_create()\n", __func__);
ret = 1;
goto label_return;
}
pthread_join(thread, (void *)&ret);
je_thread_create(&thread, je_thread_start, NULL);
je_thread_join(thread, (void *)&ret);
thread_start(NULL);
je_thread_start(NULL);
label_return:
malloc_printf("Test end\n");
return (ret);
}