]> git.proxmox.com Git - libgit2.git/blob - tests/threads/iterator.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / threads / iterator.c
1 #include "clar_libgit2.h"
2 #include "thread_helpers.h"
3 #include "iterator.h"
4
5 static git_repository *_repo;
6
7 void test_threads_iterator__cleanup(void)
8 {
9 cl_git_sandbox_cleanup();
10 }
11
12 static void *run_workdir_iterator(void *arg)
13 {
14 int error = 0;
15 git_repository *repo;
16 git_iterator *iter;
17 git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
18 const git_index_entry *entry = NULL;
19
20 iter_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
21
22 cl_git_pass(git_repository_open(&repo, git_repository_path(_repo)));
23 cl_git_pass(git_iterator_for_workdir(
24 &iter, repo, NULL, NULL, &iter_opts));
25
26 while (!error) {
27 if (entry && entry->mode == GIT_FILEMODE_TREE) {
28 error = git_iterator_advance_into(&entry, iter);
29
30 if (error == GIT_ENOTFOUND)
31 error = git_iterator_advance(&entry, iter);
32 } else {
33 error = git_iterator_advance(&entry, iter);
34 }
35
36 if (!error)
37 (void)git_iterator_current_is_ignored(iter);
38 }
39
40 cl_assert_equal_i(GIT_ITEROVER, error);
41
42 git_iterator_free(iter);
43 git_repository_free(repo);
44 git_error_clear();
45 return arg;
46 }
47
48
49 void test_threads_iterator__workdir(void)
50 {
51 _repo = cl_git_sandbox_init("status");
52
53 run_in_parallel(
54 1, 20, run_workdir_iterator, NULL, NULL);
55 }