]>
git.proxmox.com Git - libgit2.git/blob - tests/libgit2/threads/basic.c
1 #include "clar_libgit2.h"
3 #include "thread_helpers.h"
7 static git_repository
*g_repo
;
9 void test_threads_basic__initialize(void)
11 g_repo
= cl_git_sandbox_init("testrepo");
14 void test_threads_basic__cleanup(void)
16 cl_git_sandbox_cleanup();
20 void test_threads_basic__cache(void)
22 /* run several threads polling the cache at the same time */
26 void test_threads_basic__multiple_init(void)
28 git_repository
*nested_repo
;
31 cl_git_pass(git_repository_open(&nested_repo
, cl_fixture("testrepo.git")));
32 git_repository_free(nested_repo
);
34 git_libgit2_shutdown();
35 cl_git_pass(git_repository_open(&nested_repo
, cl_fixture("testrepo.git")));
36 git_repository_free(nested_repo
);
39 static void *set_error(void *dummy
)
41 git_error_set(GIT_ERROR_INVALID
, "oh no, something happened!\n");
46 /* Set errors so we can check that we free it */
47 void test_threads_basic__set_error(void)
49 run_in_parallel(1, 4, set_error
, NULL
, NULL
);
53 static void *return_normally(void *param
)
58 static void *exit_abruptly(void *param
)
60 git_thread_exit(param
);
65 void test_threads_basic__exit(void)
73 /* Ensure that the return value of the threadproc is returned. */
74 cl_git_pass(git_thread_create(&thread
, return_normally
, (void *)424242));
75 cl_git_pass(git_thread_join(&thread
, &result
));
76 cl_assert_equal_sz(424242, (size_t)result
);
78 /* Ensure that the return value of `git_thread_exit` is returned. */
79 cl_git_pass(git_thread_create(&thread
, exit_abruptly
, (void *)232323));
80 cl_git_pass(git_thread_join(&thread
, &result
));
81 cl_assert_equal_sz(232323, (size_t)result
);