Unverified Commit 319ff349 by Edward Thomson Committed by GitHub

Merge pull request #5892 from libgit2/ethomson/memleak

tests: clean up memory leak, fail on leak for win32
parents b5dcdad3 1b1e541d
...@@ -558,6 +558,11 @@ static void git_win32_leakcheck_global_shutdown(void) ...@@ -558,6 +558,11 @@ static void git_win32_leakcheck_global_shutdown(void)
git_win32_leakcheck_stack_cleanup(); 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) int git_win32_leakcheck_global_init(void)
{ {
git_win32_leakcheck_stacktrace_init(); git_win32_leakcheck_stacktrace_init();
......
...@@ -21,6 +21,8 @@ int git_win32_leakcheck_global_init(void); ...@@ -21,6 +21,8 @@ int git_win32_leakcheck_global_init(void);
#include "git2/errors.h" #include "git2/errors.h"
#include "strnlen.h" #include "strnlen.h"
bool git_win32_leakcheck_has_leaks(void);
/* Stack frames (for stack tracing, below) */ /* Stack frames (for stack tracing, below) */
/** /**
......
#include "clar_libgit2.h" #include "clar_libgit2.h"
#include "clar_libgit2_trace.h" #include "clar_libgit2_trace.h"
#ifdef GIT_WIN32_LEAKCHECK
# include "win32/w32_leakcheck.h"
#endif
#ifdef _WIN32 #ifdef _WIN32
int __cdecl main(int argc, char *argv[]) int __cdecl main(int argc, char *argv[])
#else #else
...@@ -29,6 +33,11 @@ int main(int argc, char *argv[]) ...@@ -29,6 +33,11 @@ int main(int argc, char *argv[])
cl_global_trace_disable(); cl_global_trace_disable();
git_libgit2_shutdown(); git_libgit2_shutdown();
#ifdef GIT_WIN32_LEAKCHECK
if (git_win32_leakcheck_has_leaks())
res = res || 1;
#endif
at_exit_cmd = getenv("CLAR_AT_EXIT"); at_exit_cmd = getenv("CLAR_AT_EXIT");
if (at_exit_cmd != NULL) { if (at_exit_cmd != NULL) {
int at_exit = system(at_exit_cmd); int at_exit = system(at_exit_cmd);
......
...@@ -31,10 +31,12 @@ void test_refs_races__create_matching_zero_old(void) ...@@ -31,10 +31,12 @@ void test_refs_races__create_matching_zero_old(void)
git_oid_fromstr(&zero_id, "0000000000000000000000000000000000000000"); git_oid_fromstr(&zero_id, "0000000000000000000000000000000000000000");
cl_git_fail(git_reference_create_matching(&ref, g_repo, refname, &id, 1, &zero_id, NULL)); cl_git_fail(git_reference_create_matching(&ref, g_repo, refname, &id, 1, &zero_id, NULL));
git_reference_free(ref);
cl_git_pass(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL)); cl_git_pass(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL));
cl_git_fail(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL)); git_reference_free(ref);
cl_git_fail(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL));
git_reference_free(ref); git_reference_free(ref);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment