diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-05-18 11:51:25 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-05-18 11:52:42 +0100 |
commit | a6fb72a8ba3bf3f8bc8d78ef4104c6b083416a4b (patch) | |
tree | 80afff156fa87e8c8a8ceeac605196a67ac1a7d4 | |
parent | b5dcdad34de01283e72e66ffca4b7be6fdbddf9f (diff) | |
download | libgit2-a6fb72a8ba3bf3f8bc8d78ef4104c6b083416a4b.tar.gz |
tests: exit with error on win32 leakcheck
-rw-r--r-- | src/win32/w32_leakcheck.c | 5 | ||||
-rw-r--r-- | src/win32/w32_leakcheck.h | 2 | ||||
-rw-r--r-- | tests/main.c | 9 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/win32/w32_leakcheck.c b/src/win32/w32_leakcheck.c index ef1700443..5c8425be3 100644 --- a/src/win32/w32_leakcheck.c +++ b/src/win32/w32_leakcheck.c @@ -558,6 +558,11 @@ static void git_win32_leakcheck_global_shutdown(void) git_win32_leakcheck_stack_cleanup(); } +bool git_win32_leakcheck_has_leaks(void) +{ + return (g_transient_count_total_leaks > 0); +} + int git_win32_leakcheck_global_init(void) { git_win32_leakcheck_stacktrace_init(); diff --git a/src/win32/w32_leakcheck.h b/src/win32/w32_leakcheck.h index 7da03ab0e..cb45e3675 100644 --- a/src/win32/w32_leakcheck.h +++ b/src/win32/w32_leakcheck.h @@ -21,6 +21,8 @@ int git_win32_leakcheck_global_init(void); #include "git2/errors.h" #include "strnlen.h" +bool git_win32_leakcheck_has_leaks(void); + /* Stack frames (for stack tracing, below) */ /** diff --git a/tests/main.c b/tests/main.c index 00b2bae02..207a6a8be 100644 --- a/tests/main.c +++ b/tests/main.c @@ -1,6 +1,10 @@ #include "clar_libgit2.h" #include "clar_libgit2_trace.h" +#ifdef GIT_WIN32_LEAKCHECK +# include "win32/w32_leakcheck.h" +#endif + #ifdef _WIN32 int __cdecl main(int argc, char *argv[]) #else @@ -29,6 +33,11 @@ int main(int argc, char *argv[]) cl_global_trace_disable(); git_libgit2_shutdown(); +#ifdef GIT_WIN32_LEAKCHECK + if (git_win32_leakcheck_has_leaks()) + res = res || 1; +#endif + at_exit_cmd = getenv("CLAR_AT_EXIT"); if (at_exit_cmd != NULL) { int at_exit = system(at_exit_cmd); |