Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Src/Generic/Test/TestErrorHandling.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ namespace TestGenericLib
#endif
}

#ifdef DEBUG
void testNativeAssertThrowsExceptionWithoutContinuing()
{
#if defined(WIN32) || defined(_M_X64)
Expand All @@ -182,6 +183,7 @@ namespace TestGenericLib
// TODO-Linux: port
#endif
}
#endif

public:
TestErrorHandling();
Expand Down
14 changes: 12 additions & 2 deletions Src/Generic/Test/testGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ Last reviewed:
-------------------------------------------------------------------------------*//*:End Ignore*/
#include "testGenericLib.h"
#include "RedirectHKCU.h"
#ifdef DEBUG
#include "DebugProcs.h"
#endif
#include <cstdlib>
#include <cstring>
#include <csignal>
#include <stdexcept>

namespace
{
#ifdef DEBUG
Pfn_Assert g_previousAssertProc = NULL;

void RestorePreviousAssertProc()
Expand All @@ -29,6 +32,7 @@ namespace
g_previousAssertProc = NULL;
}
}
#endif

void TerminateOnSigAbrt(int)
{
Expand All @@ -47,6 +51,7 @@ namespace
return fEnabled;
}

#ifdef DEBUG
void WINAPI ThrowingAssertProc(const char * pszExp, const char * pszFile, int nLine, HMODULE)
{
char szMessage[1024];
Expand All @@ -61,12 +66,14 @@ namespace
fflush(stderr);
throw std::runtime_error(szMessage);
}
#endif
}

namespace unitpp
{
void GlobalSetup(bool verbose)
{
#ifdef DEBUG
if (IsEnvironmentSwitchEnabled("FW_TEST_ALLOW_ASSERT_DIALOGS"))
{
ShowAssertMessageBox(1);
Expand All @@ -76,6 +83,7 @@ namespace unitpp
g_previousAssertProc = SetAssertProc(ThrowingAssertProc);
ShowAssertMessageBox(0); // Disable assertion dialogs
}
#endif
#if defined(WIN32) || defined(WIN64)
ModuleEntry::DllMain(0, DLL_PROCESS_ATTACH);
#endif
Expand All @@ -87,29 +95,31 @@ namespace unitpp
{
signal(SIGABRT, TerminateOnSigAbrt);

#ifdef DEBUG
const bool fInjectTeardownAssert = IsEnvironmentSwitchEnabled("FW_TEST_INDUCE_TEARDOWN_ASSERT");
const bool fInjectTeardownAbort = IsEnvironmentSwitchEnabled("FW_TEST_INDUCE_TEARDOWN_ABORT");
if (fInjectTeardownAssert || fInjectTeardownAbort)
RestorePreviousAssertProc();

#ifdef DEBUG
if (fInjectTeardownAssert)
AssertMsg(false, "Injected teardown assert for native test infrastructure validation");
#endif

if (fInjectTeardownAbort)
{
_set_error_mode(_OUT_TO_STDERR);
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
abort();
}
#endif

#if defined(WIN32) || defined(WIN64)
ModuleEntry::DllMain(0, DLL_PROCESS_DETACH);
#endif
::OleUninitialize();

#ifdef DEBUG
RestorePreviousAssertProc();
#endif
}
}

Expand Down
Loading