You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Add stack trace macros to all functions.
Low-level functions only include stack trace in test builds while higher-level functions ship with stack trace built-in. Stack traces include all parameters passed to the function but production builds only create the parameter list when the log level is set high enough, i.e. debug or trace depending on the function.
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
Test Exit Routines
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/error.h"
|
||||
#include "common/log.h"
|
||||
#include "config/config.h"
|
||||
|
||||
#include "common/harnessFork.h"
|
||||
@ -12,6 +13,8 @@ Test Run
|
||||
void
|
||||
testRun()
|
||||
{
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("exitSignalName()"))
|
||||
{
|
||||
@ -66,6 +69,42 @@ testRun()
|
||||
}
|
||||
TRY_END();
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
logInit(logLevelDebug, logLevelOff, logLevelOff, false);
|
||||
|
||||
TRY_BEGIN()
|
||||
{
|
||||
THROW(RuntimeError, "test debug error message");
|
||||
}
|
||||
CATCH_ANY()
|
||||
{
|
||||
exitSafe(0, true, signalTypeNone);
|
||||
testLogResultRegExp(
|
||||
"P00 ERROR\\: \\[122\\]\\: test debug error message\n"
|
||||
" STACK TRACE\\:\n"
|
||||
" module\\/common\\/exitTest\\:testRun\\:.*\n"
|
||||
" test\\:main\\:.*\n");
|
||||
}
|
||||
TRY_END();
|
||||
|
||||
logInit(logLevelInfo, logLevelOff, logLevelOff, false);
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TRY_BEGIN()
|
||||
{
|
||||
THROW(AssertError, "test assert message");
|
||||
}
|
||||
CATCH_ANY()
|
||||
{
|
||||
exitSafe(0, true, signalTypeNone);
|
||||
testLogResultRegExp(
|
||||
"P00 ASSERT\\: \\[025\\]\\: test assert message\n"
|
||||
" STACK TRACE\\:\n"
|
||||
" module/common/exitTest\\:testRun\\:.*\n"
|
||||
" test\\:main\\:.*\n");
|
||||
}
|
||||
TRY_END();
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TRY_BEGIN()
|
||||
{
|
||||
@ -89,4 +128,6 @@ testRun()
|
||||
exitSafe(errorTypeCode(&TermError), false, signalTypeTerm), errorTypeCode(&TermError), "exit on term with SIGTERM");
|
||||
testLogResult("P00 INFO: archive-push command end: terminated on signal [SIGTERM]");
|
||||
}
|
||||
|
||||
FUNCTION_HARNESS_RESULT_VOID();
|
||||
}
|
||||
|
Reference in New Issue
Block a user