You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Split cfgLoad() into multiple functions to make testing easier.
Mainly this helps with unit tests that need to do log expect testing. Add harnessCfgLoad() test function, which allows a new config to be loaded for unit testing without resetting log functions, opening a log file, or taking locks.
This commit is contained in:
@ -11,6 +11,11 @@ Log Test Harness
|
||||
|
||||
#ifndef NO_LOG
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Has the log harness been init'd?
|
||||
***********************************************************************************************************************************/
|
||||
static bool harnessLogInit = false;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Name of file where logs are stored for testing
|
||||
***********************************************************************************************************************************/
|
||||
@ -23,13 +28,18 @@ Initialize log for testing
|
||||
void
|
||||
testLogInit()
|
||||
{
|
||||
logInit(logLevelInfo, logLevelOff, logLevelOff, false);
|
||||
if (!harnessLogInit)
|
||||
{
|
||||
logInit(logLevelInfo, logLevelOff, logLevelOff, false);
|
||||
|
||||
stdoutFile = strNewFmt("%s/stdout.log", testPath());
|
||||
logHandleStdOut = open(strPtr(stdoutFile), O_WRONLY | O_CREAT | O_TRUNC, 0640);
|
||||
stdoutFile = strNewFmt("%s/stdout.log", testPath());
|
||||
logHandleStdOut = open(strPtr(stdoutFile), O_WRONLY | O_CREAT | O_TRUNC, 0640);
|
||||
|
||||
stderrFile = strNewFmt("%s/stderr.log", testPath());
|
||||
logHandleStdErr = open(strPtr(stderrFile), O_WRONLY | O_CREAT | O_TRUNC, 0640);
|
||||
stderrFile = strNewFmt("%s/stderr.log", testPath());
|
||||
logHandleStdErr = open(strPtr(stderrFile), O_WRONLY | O_CREAT | O_TRUNC, 0640);
|
||||
|
||||
harnessLogInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
Reference in New Issue
Block a user