Refactored tests

This commit is contained in:
pithikos 2015-01-16 18:21:34 +00:00
parent f269de73f8
commit 42e7937bca
4 changed files with 12 additions and 14 deletions

View File

@ -6,7 +6,7 @@
#include <time.h>
/* This showcasts this issue: https://sourceware.org/ml/glibc-bugs/2007-04/msg00036.html */
/* Alsoe here: http://stackoverflow.com/questions/27803819/pthreads-leak-memory-even-if-used-correctly/27804629 */
/* Also here: http://stackoverflow.com/questions/27803819/pthreads-leak-memory-even-if-used-correctly/27804629 */
volatile int threads_keepalive = 1;
@ -14,7 +14,6 @@ void* thread_do(void *arg){
while(threads_keepalive)
sleep(1);
pthread_exit(NULL);
return;
}
int main(void){

View File

@ -60,5 +60,6 @@ test_thread_free 1
test_thread_free 20
test_thread_free_multi 4 20
test_thread_free_multi 3 1000
test_thread_free_multi 100 100
echo "No memory leaks"

View File

@ -22,18 +22,17 @@ int main(int argc, char *argv[]){
puts("This testfile needs excactly two arguments");
exit(1);
}
int jobs = strtol(argv[1], &p, 10);
int threads = strtol(argv[2], &p, 10);
int num_jobs = strtol(argv[1], &p, 10);
int num_threads = strtol(argv[2], &p, 10);
thpool_t* thpool;
thpool = thpool_init(threads);
thpool threadpool = thpool_init(num_threads);
int n;
for (n=0; n<jobs; n++){
thpool_add_work(thpool, (void*)increment, NULL);
for (n=0; n<num_jobs; n++){
thpool_add_work(threadpool, (void*)increment, NULL);
}
thpool_wait(thpool);
thpool_wait(threadpool);
printf("%d\n", sum);

View File

@ -6,7 +6,7 @@
int main(int argc, char *argv[]){
char* p;
if (argc != 2){
puts("This testfile needs excactly one arguments");
@ -14,10 +14,9 @@ int main(int argc, char *argv[]){
}
int threads = strtol(argv[1], &p, 10);
thpool_t* thpool;
thpool = thpool_init(threads);
thpool_destroy(thpool);
thpool threadpool = thpool_init(threads);
thpool_destroy(threadpool);
sleep(1); // Sometimes main exits before thpool_destroy finished 100%
return 0;