summaryrefslogtreecommitdiff
path: root/tests/main.c
diff options
context:
space:
mode:
authorJeff Hostetler <jeffhost@microsoft.com>2015-04-10 06:15:06 -0400
committerJeff Hostetler <jeffhost@microsoft.com>2015-04-15 10:25:09 -0400
commitd06c589f486ebe9c96a9133bc8492844ad0cc6e8 (patch)
tree4e070b4ca2c03fa5f796e98af776bd1662426921 /tests/main.c
parent47f37400253210f483d84fb9c2ecf44fb5986849 (diff)
downloadlibgit2-d06c589f486ebe9c96a9133bc8492844ad0cc6e8.tar.gz
Add MSVC CRTDBG memory leak reporting.
Diffstat (limited to 'tests/main.c')
-rw-r--r--tests/main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/main.c b/tests/main.c
index f67c8ffbc..56326da1c 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -1,3 +1,10 @@
+
+#if defined(GIT_MSVC_CRTDBG)
+/* Enable MSVC CRTDBG memory leak reporting. See src/util.h for details. */
+#include <stdlib.h>
+#include <crtdbg.h>
+#endif
+
#include "clar_libgit2.h"
#include "clar_libgit2_trace.h"
@@ -9,6 +16,18 @@ int main(int argc, char *argv[])
{
int res;
+#if defined(GIT_MSVC_CRTDBG)
+ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+
+ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
+
+ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+#endif
+
clar_test_init(argc, argv);
git_libgit2_init();