summaryrefslogtreecommitdiff
path: root/tests/threads/diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/threads/diff.c')
-rw-r--r--tests/threads/diff.c49
1 files changed, 5 insertions, 44 deletions
diff --git a/tests/threads/diff.c b/tests/threads/diff.c
index 5565c4bf1..562eec71c 100644
--- a/tests/threads/diff.c
+++ b/tests/threads/diff.c
@@ -1,59 +1,22 @@
#include "clar_libgit2.h"
-#include "thread-utils.h"
+#include "thread_helpers.h"
static git_repository *_repo;
static git_tree *_a, *_b;
static git_atomic _counts[4];
static int _check_counts;
+#define THREADS 20
+
void test_threads_diff__cleanup(void)
{
cl_git_sandbox_cleanup();
}
-static void run_in_parallel(
- int repeats, int threads, void *(*func)(void *),
- void (*before_test)(void), void (*after_test)(void))
-{
- int r, t, *id = git__calloc(threads, sizeof(int));
-#ifdef GIT_THREADS
- git_thread *th = git__calloc(threads, sizeof(git_thread));
- cl_assert(th != NULL);
-#else
- void *th = NULL;
-#endif
-
- cl_assert(id != NULL);
-
- for (r = 0; r < repeats; ++r) {
- _repo = cl_git_sandbox_reopen(); /* reopen sandbox to flush caches */
-
- if (before_test) before_test();
-
- for (t = 0; t < threads; ++t) {
- id[t] = t;
-#ifdef GIT_THREADS
- cl_git_pass(git_thread_create(&th[t], NULL, func, &id[t]));
-#else
- cl_assert(func(&id[t]) == &id[t]);
-#endif
- }
-
-#ifdef GIT_THREADS
- for (t = 0; t < threads; ++t)
- cl_git_pass(git_thread_join(th[t], NULL));
- memset(th, 0, threads * sizeof(git_thread));
-#endif
-
- if (after_test) after_test();
- }
-
- git__free(id);
- git__free(th);
-}
-
static void setup_trees(void)
{
+ _repo = cl_git_sandbox_reopen(); /* reopen sandbox to flush caches */
+
cl_git_pass(git_revparse_single(
(git_object **)&_a, _repo, "0017bd4ab1^{tree}"));
cl_git_pass(git_revparse_single(
@@ -62,8 +25,6 @@ static void setup_trees(void)
memset(_counts, 0, sizeof(_counts));
}
-#define THREADS 20
-
static void free_trees(void)
{
git_tree_free(_a); _a = NULL;