1
0
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:
David Steele
2018-04-13 16:05:52 -04:00
parent 49fc737cd0
commit 2a4ff2f904
11 changed files with 221 additions and 176 deletions

View File

@ -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;
}
}
/***********************************************************************************************************************************