summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan@13f79535-47bb-0310-9956-ffa450edef68>2022-06-27 17:24:54 +0000
committerivan <ivan@13f79535-47bb-0310-9956-ffa450edef68>2022-06-27 17:24:54 +0000
commit970bd43033d7f1d8c177d0d0cfaebe84c268a8fa (patch)
treef59a07549906aa9aa7cb27999976337fa91aec57
parente8e96292d13b649da5dede5cf0a0a460982e3d67 (diff)
downloadlibapr-970bd43033d7f1d8c177d0d0cfaebe84c268a8fa.tar.gz
tests: Configure VC runtime to write errors to stderr instead of displaying
popup message box on Windows. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902283 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--test/testutil.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/testutil.c b/test/testutil.c
index d3c1ff8ac..3a9e25cb4 100644
--- a/test/testutil.c
+++ b/test/testutil.c
@@ -16,6 +16,9 @@
#include <stdio.h>
#include <stdlib.h>
+#if defined(_MSC_VER)
+#include <crtdbg.h>
+#endif
#include "abts.h"
#include "testutil.h"
@@ -53,4 +56,18 @@ void initialize(void) {
atexit(apr_terminate);
apr_pool_create(&p, NULL);
+
+#if _MSC_VER >= 1400
+ /* In release mode: Redirect abort() errors to stderr */
+ _set_error_mode(_OUT_TO_STDERR);
+
+ /* In _DEBUG mode: Redirect all debug output (E.g. assert() to stderr.
+ (Ignored in release builds) */
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+#endif /* _MSC_VER >= 1400 */
}