summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-14 12:29:27 -0700
committerRussell Belfer <rb@github.com>2014-04-17 14:56:41 -0700
commitea642d61f9b3dd3d9e1670621198483541cf4f0d (patch)
tree82821f124566c93a73ba02768e168ccf60cdb4ad /tests
parent2e9d813bd69ab014b970a75b5a4f7d24f241cc05 (diff)
downloadlibgit2-ea642d61f9b3dd3d9e1670621198483541cf4f0d.tar.gz
Fix race checking for existing index items
In the threading tests, I was still seeing a race condition where the same item could end up being inserted multiple times into the index. Preserving the sorted-ness of the index outside of the `index_insert` call fixes the issue.
Diffstat (limited to 'tests')
-rw-r--r--tests/threads/diff.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/threads/diff.c b/tests/threads/diff.c
index 562eec71c..d33e75f2c 100644
--- a/tests/threads/diff.c
+++ b/tests/threads/diff.c
@@ -15,8 +15,14 @@ void test_threads_diff__cleanup(void)
static void setup_trees(void)
{
+ git_index *idx;
+
_repo = cl_git_sandbox_reopen(); /* reopen sandbox to flush caches */
+ /* avoid competing to load initial index */
+ cl_git_pass(git_repository_index(&idx, _repo));
+ git_index_free(idx);
+
cl_git_pass(git_revparse_single(
(git_object **)&_a, _repo, "0017bd4ab1^{tree}"));
cl_git_pass(git_revparse_single(
@@ -107,7 +113,7 @@ void test_threads_diff__concurrent_diffs(void)
_check_counts = 1;
run_in_parallel(
- 20, 32, run_index_diffs, setup_trees, free_trees);
+ 5, 32, run_index_diffs, setup_trees, free_trees);
}
static void *run_index_diffs_with_modifier(void *arg)
@@ -169,5 +175,5 @@ void test_threads_diff__with_concurrent_index_modified(void)
_check_counts = 0;
run_in_parallel(
- 20, 32, run_index_diffs_with_modifier, setup_trees, free_trees);
+ 5, 16, run_index_diffs_with_modifier, setup_trees, free_trees);
}