]> git.proxmox.com Git - libgit2.git/blob - tests/main.c
New upstream version 1.3.0+dfsg.1
[libgit2.git] / tests / main.c
1 #include "clar_libgit2.h"
2 #include "clar_libgit2_trace.h"
3
4 #ifdef GIT_WIN32_LEAKCHECK
5 # include "win32/w32_leakcheck.h"
6 #endif
7
8 #ifdef _WIN32
9 int __cdecl main(int argc, char *argv[])
10 #else
11 int main(int argc, char *argv[])
12 #endif
13 {
14 int res;
15 char *at_exit_cmd;
16
17 clar_test_init(argc, argv);
18
19 res = git_libgit2_init();
20 if (res < 0) {
21 const git_error *err = git_error_last();
22 const char *msg = err ? err->message : "unknown failure";
23 fprintf(stderr, "failed to init libgit2: %s\n", msg);
24 return res;
25 }
26
27 cl_global_trace_register();
28 cl_sandbox_set_search_path_defaults();
29
30 /* Run the test suite */
31 res = clar_test_run();
32
33 clar_test_shutdown();
34
35 cl_global_trace_disable();
36 git_libgit2_shutdown();
37
38 #ifdef GIT_WIN32_LEAKCHECK
39 if (git_win32_leakcheck_has_leaks())
40 res = res || 1;
41 #endif
42
43 at_exit_cmd = getenv("CLAR_AT_EXIT");
44 if (at_exit_cmd != NULL) {
45 int at_exit = system(at_exit_cmd);
46 return res || at_exit;
47 }
48
49 return res;
50 }