1
#ifndef TEST_ASSERT_IMPL__H
2
#define TEST_ASSERT_IMPL__H
4
/* $Id: test_assert_impl.h,v 1.1 2006/03/07 18:22:09 lavr Exp $
5
* ===========================================================================
8
* National Center for Biotechnology Information
10
* This software/database is a "United States Government Work" under the
11
* terms of the United States Copyright Act. It was written as part of
12
* the author's official duties as a United States Government employee and
13
* thus cannot be copyrighted. This software/database is freely available
14
* to the public for use. The National Library of Medicine and the U.S.
15
* Government have not placed any restriction on its use or reproduction.
17
* Although all reasonable efforts have been taken to ensure the accuracy
18
* and reliability of the software and data, the NLM and the U.S.
19
* Government do not and cannot warrant the performance or results that
20
* may be obtained by using this software or data. The NLM and the U.S.
21
* Government disclaim all warranties, express or implied, including
22
* warranties of performance, merchantability or fitness for any particular
25
* Please cite the author in any work or product based on this material.
27
* ===========================================================================
29
* Author: Denis Vakatov
32
* Setup #NDEBUG and #_DEBUG preprocessor macro in a way that ASSERTs
33
* will be active even in the "Release" mode (it's useful for test apps).
37
#ifndef TEST_ASSERT__H
38
# error "Must not use this header alone, but from a proper wrapper."
39
#endif /*TEST_ASSERT__H*/
41
#if defined(NCBI_OS_MAC) || \
42
(defined(NCBI_OS_DARWIN) && defined(NCBI_COMPILER_METROWERKS))
46
#elif defined(NCBI_OS_MSWIN)
56
/* Suppress popup messages on execution errors.
57
* NOTE: Windows-specific, suppresses all error message boxes in both runtime
58
* and in debug libraries, as well as all General Protection Fault messages.
59
* Environment variable DIAG_SILENT_ABORT must be set to "Y" or "y".
62
/* Handler for "Unhandled" exceptions */
63
static LONG CALLBACK _SEH_Handler(EXCEPTION_POINTERS* ep)
65
/* Always terminate a program */
66
return EXCEPTION_EXECUTE_HANDLER;
69
static int _SuppressDiagPopupMessages(void)
71
/* Check environment variable for silent abort app at error */
72
const char* value = getenv("DIAG_SILENT_ABORT");
73
if (value && (*value == 'Y' || *value == 'y')) {
74
/* Windows GPF errors */
75
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
76
SEM_NOOPENFILEERRORBOX);
79
_set_error_mode(_OUT_TO_STDERR);
82
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
83
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
84
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
85
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
86
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
87
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
90
SetUnhandledExceptionFilter(_SEH_Handler);
95
/* Put this function at startup init level 'V', far enough not to mess up with
96
* base RTL init, which happens at preceding levels in alphabetical order.
99
# pragma section( ".CRT$XIV", read)
101
# pragma data_seg(".CRT$XIV")
102
static int (*_SDPM)(void) = _SuppressDiagPopupMessages;
105
#endif /*defined(NCBI_OS_...)*/
115
/* IRIX stdlib fix (MIPSpro compiler tested): assert.h already included above*/
122
/* Likewise on OSF/1 (at least with GCC 3, but this never hurts) */
129
/* ...and on Darwin (at least with GCC 3, but this never hurts) */
130
#ifdef NCBI_OS_DARWIN
131
# ifdef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
132
# undef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
141
#define _ASSERT assert
145
* --------------------------------------------------------------------------
146
* $Log: test_assert_impl.h,v $
147
* Revision 1.1 2006/03/07 18:22:09 lavr
150
* ===========================================================================
153
#endif /* TEST_ASSERT_IMPL__H */