]>
Commit | Line | Data |
---|---|---|
6d91dc53 ET |
1 | #include "clar_libgit2.h" |
2 | ||
3 | void test_core_init__returns_count(void) | |
4 | { | |
e579e0f7 | 5 | /* libgit2_tests initializes us first, so we have an existing |
6d91dc53 ET |
6 | * initialization. |
7 | */ | |
8 | cl_assert_equal_i(2, git_libgit2_init()); | |
9 | cl_assert_equal_i(3, git_libgit2_init()); | |
10 | ||
11 | cl_assert_equal_i(2, git_libgit2_shutdown()); | |
12 | cl_assert_equal_i(1, git_libgit2_shutdown()); | |
13 | } | |
14 | ||
1c33ecc4 PS |
15 | void test_core_init__reinit_succeeds(void) |
16 | { | |
17 | cl_assert_equal_i(0, git_libgit2_shutdown()); | |
18 | cl_assert_equal_i(1, git_libgit2_init()); | |
19 | cl_sandbox_set_search_path_defaults(); | |
20 | } | |
21 | ||
22 | #ifdef GIT_THREADS | |
23 | static void *reinit(void *unused) | |
24 | { | |
25 | unsigned i; | |
26 | ||
27 | for (i = 0; i < 20; i++) { | |
28 | cl_assert(git_libgit2_init() > 0); | |
29 | cl_assert(git_libgit2_shutdown() >= 0); | |
30 | } | |
31 | ||
32 | return unused; | |
33 | } | |
34 | #endif | |
35 | ||
36 | void test_core_init__concurrent_init_succeeds(void) | |
37 | { | |
38 | #ifdef GIT_THREADS | |
39 | git_thread threads[10]; | |
40 | unsigned i; | |
41 | ||
99479062 | 42 | cl_assert_equal_i(2, git_libgit2_init()); |
1c33ecc4 PS |
43 | |
44 | for (i = 0; i < ARRAY_SIZE(threads); i++) | |
45 | git_thread_create(&threads[i], reinit, NULL); | |
46 | for (i = 0; i < ARRAY_SIZE(threads); i++) | |
47 | git_thread_join(&threads[i], NULL); | |
48 | ||
99479062 | 49 | cl_assert_equal_i(1, git_libgit2_shutdown()); |
1c33ecc4 PS |
50 | cl_sandbox_set_search_path_defaults(); |
51 | #else | |
52 | cl_skip(); | |
53 | #endif | |
54 | } |