]>
git.proxmox.com Git - libgit2.git/blob - tests/threads/thread_helpers.c
1 #include "clar_libgit2.h"
2 #include "thread_helpers.h"
8 void (*before_test
)(void),
9 void (*after_test
)(void))
11 int r
, t
, *id
= git__calloc(threads
, sizeof(int));
13 git_thread
*th
= git__calloc(threads
, sizeof(git_thread
));
14 cl_assert(th
!= NULL
);
19 cl_assert(id
!= NULL
);
21 for (r
= 0; r
< repeats
; ++r
) {
22 if (before_test
) before_test();
24 for (t
= 0; t
< threads
; ++t
) {
27 cl_git_pass(git_thread_create(&th
[t
], func
, &id
[t
]));
29 cl_assert(func(&id
[t
]) == &id
[t
]);
34 for (t
= 0; t
< threads
; ++t
)
35 cl_git_pass(git_thread_join(&th
[t
], NULL
));
36 memset(th
, 0, threads
* sizeof(git_thread
));
39 if (after_test
) after_test();