pgbackrest.git / summary / log / commit / refs
commit 58e9f1e50cfbc2df22af17293fe8a298cac5513a
Author: David Steele <david@pgmasters.net>
Date: Fri Jul 20 22:51:42 2018 +0000
Refactor the common/log tests to not depend on common/harnessLog.
common/harnessLog was not ideally suited for general testing and made all the tests quite awkward. Instead, move all code used to test the common/log module into the logTest module and repurpose common/harnessLog to do log expect testing for all other tests in a cleaner way.
Add a few exceptions for config testing since the log levels are reset by default in config/parse.
doc/xml/release.xml | 6 ++
libc/xs/config/configTest.xs | 2 +-
src/common/log.c | 2 +-
src/common/log.h | 15 ---
src/config/load.c | 2 +-
src/config/parse.c | 4 +-
src/config/parse.h | 2 +-
src/perl/libc.auto.c | 2 +-
test/code-count/file-type.yaml | 2 +-
test/define.yaml | 14 +--
test/src/common/harnessConfig.c | 8 +-
harnessLog.c} | 88 ++++++-----------
harnessLog.h} | 18 ++--
test/src/common/harnessTest.c | 22 +++--
test/src/module/archive/commonTest.c | 4 +-
test/src/module/archive/getTest.c | 6 +-
test/src/module/archive/pushTest.c | 6 +-
test/src/module/command/commandTest.c | 20 ++--
test/src/module/common/debugOnTest.c | 12 +--
test/src/module/common/exitTest.c | 18 ++--
test/src/module/common/logTest.c | 119 ++++++++++++++++++++---
test/src/module/config/loadTest.c | 39 +++++---
test/src/module/config/parseTest.c | 145 ++++++++++++++++------------
test/src/module/help/helpTest.c | 27 +++---
test/src/module/perl/execTest.c | 1 +
test/src/module/storage/storageTest.c | 2 +-
test/src/test.c | 2 +-
27 files changed, 343 insertions(+), 245 deletions(-)
diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index 1fc68a497..15219db3a 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -87,6 +87,12 @@
<p>Error if LibC build is performed outside the test environment. LibC is no longer required for production builds.</p>
</release-item>
</release-improvement-list>
+
+ <release-development-list>
+ <release-item>
+ <p>Refactor the <code>common/log</code> tests to not depend on <code>common/harnessLog</code>. <code>common/harnessLog</code> was not ideally suited for general testing and made all the tests quite awkward. Instead, move all code used to test the <code>common/log</code> module into the <code>logTest</code> module and repurpose <code>common/harnessLog</code> to do log expect testing for all other tests in a cleaner way. Add a few exceptions for config testing since the log levels are reset by default in <code>config/parse</code>.</p>
+ </release-item>
+ </release-development-list>
</release-test-list>
</release>
diff --git a/libc/xs/config/configTest.xs b/libc/xs/config/configTest.xs
index 6919dc2ea..f47c958f2 100644
--- a/libc/xs/config/configTest.xs
+++ b/libc/xs/config/configTest.xs
@@ -21,7 +21,7 @@ CODE:
StringList *paramList = strLstNewSplitZ(strCat(strNew("pgbackrest|"), parseParam), "|");
// Don't use cfgLoad() because it has a lot of side effects that we don't want
- configParse(strLstSize(paramList), strLstPtr(paramList));
+ configParse(strLstSize(paramList), strLstPtr(paramList), false);
cfgExeSet(strNew(backrestBin));
cfgLoadUpdateOption();
diff --git a/src/common/log.c b/src/common/log.c
index cfddc2ac7..e34f57784 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -30,7 +30,7 @@ DEBUG_UNIT_EXTERN int logHandleStdErr = STDERR_FILENO;
DEBUG_UNIT_EXTERN int logHandleFile = -1;
// Has the log file banner been written yet?
-static bool logFileBanner = false;
+DEBUG_UNIT_EXTERN bool logFileBanner = false;
// Is the timestamp printed in the log?
DEBUG_UNIT_EXTERN bool logTimestamp = false;
diff --git a/src/common/log.h b/src/common/log.h
index a746d46d2..2c088d1b4 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -15,21 +15,6 @@ Max size allowed for a single log message including header
#define LOG_BUFFER_SIZE ((size_t)(32 * 1024))
#endif
-/***********************************************************************************************************************************
-Expose internal data for unit testing/debugging
-***********************************************************************************************************************************/
-#ifdef DEBUG_UNIT
- extern LogLevel logLevelStdOut;
- extern LogLevel logLevelStdErr;
- extern LogLevel logLevelFile;
-
- extern int logHandleStdOut;
- extern int logHandleStdErr;
- extern int logHandleFile;
-
- extern bool logTimestamp;
-#endif
-
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
diff --git a/src/config/load.c b/src/config/load.c
index c23e3bd09..88798f06b 100644
--- a/src/config/load.c
+++ b/src/config/load.c
@@ -212,7 +212,7 @@ cfgLoad(unsigned int argListSize, const char *argList[])
MEM_CONTEXT_TEMP_BEGIN()
{
// Parse config from command line and config file
- configParse(argListSize, argList);
+ configParse(argListSize, argList, true);
// Load the log settings
cfgLoadLogSetting();
diff --git a/src/config/parse.c b/src/config/parse.c
index c303934f9..40675942c 100644
--- a/src/config/parse.c
+++ b/src/config/parse.c
@@ -356,7 +356,7 @@ Parse the command-line arguments and config file to produce final config data
logic to this critical path code.
***********************************************************************************************************************************/
void
-configParse(unsigned int argListSize, const char *argList[])
+configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
{
FUNCTION_DEBUG_BEGIN(logLevelTrace);
FUNCTION_DEBUG_PARAM(UINT, argListSize);
@@ -513,7 +513,7 @@ configParse(unsigned int argListSize, const char *argList[])
cfgCommandParamSet(commandParamList);
// Enable logging (except for local and remote commands) so config file warnings will be output
- if (cfgCommand() != cfgCmdLocal && cfgCommand() != cfgCmdRemote)
+ if (cfgCommand() != cfgCmdLocal && cfgCommand() != cfgCmdRemote && resetLogLevel)
logInit(logLevelWarn, logLevelWarn, logLevelOff, false);
// Phase 2: parse config file unless --no-config passed
diff --git a/src/config/parse.h b/src/config/parse.h
index ad6aba885..b61744516 100644
--- a/src/config/parse.h
+++ b/src/config/parse.h
@@ -9,6 +9,6 @@ Parse Configuration
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
-void configParse(unsigned int argListSize, const char *argList[]);
+void configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel);
#endif
diff --git a/src/perl/libc.auto.c b/src/perl/libc.auto.c
index 0bb711632..e97e08d46 100644
--- a/src/perl/libc.auto.c
+++ b/src/perl/libc.auto.c
@@ -955,7 +955,7 @@ XS_EUPXS(XS_pgBackRest__LibC_cfgParseTest)
StringList *paramList = strLstNewSplitZ(strCat(strNew("pgbackrest|"), parseParam), "|");
// Don't use cfgLoad() because it has a lot of side effects that we don't want
- configParse(strLstSize(paramList), strLstPtr(paramList));
+ configParse(strLstSize(paramList), strLstPtr(paramList), false);
cfgExeSet(strNew(backrestBin));
cfgLoadUpdateOption();
diff --git a/test/code-count/file-type.yaml b/test/code-count/file-type.yaml
index 237f4bee0..596b53f5f 100644
--- a/test/code-count/file-type.yaml
+++ b/test/code-count/file-type.yaml
@@ -1219,7 +1219,7 @@ test/src/common/logTest.c:
class: test/harness
type: c
-test/src/common/logTest.h:
+test/src/common/harnessLog.h:
class: test/harness
type: c/h
diff --git a/test/define.yaml b/test/define.yaml
index a680d852f..64ff9bd7b 100644
--- a/test/define.yaml
+++ b/test/define.yaml
@@ -94,23 +94,23 @@ unit:
# ----------------------------------------------------------------------------------------------------------------------------
- name: log
total: 5
- define: -DIN_LOG
+ define: -DNO_LOG
coverage:
common/log: full
# ----------------------------------------------------------------------------------------------------------------------------
- - name: debug-on
- total: 4
+ - name: debug-off
+ total: 2
+ define: -DNDEBUG -DNO_LOG
+ debugUnitSuppress: true
coverage:
common/debug: full
# ----------------------------------------------------------------------------------------------------------------------------
- - name: debug-off
- total: 2
- define: -DNDEBUG -DNO_LOG
- debugUnitSuppress: true
+ - name: debug-on
+ total: 4
coverage:
common/debug: full
diff --git a/test/src/common/harnessConfig.c b/test/src/common/harnessConfig.c
index dd651569e..8cb6cd056 100644
--- a/test/src/common/harnessConfig.c
+++ b/test/src/common/harnessConfig.c
@@ -2,7 +2,7 @@
Harness for Loading Test Configurations
***********************************************************************************************************************************/
#include "common/harnessDebug.h"
-#include "common/logTest.h"
+#include "common/harnessLog.h"
#include "config/load.h"
#include "config/parse.h"
@@ -10,8 +10,7 @@ Harness for Loading Test Configurations
/***********************************************************************************************************************************
Load a test configuration without any side effects
-Log testing requires that log levels be set in a certain way but calls to cfgLoad() will reset that. Also there's no need to open
-log files, acquire locks, etc.
+There's no need to open log files, acquire locks, reset log levels, etc.
***********************************************************************************************************************************/
void
harnessCfgLoad(unsigned int argListSize, const char *argList[])
@@ -21,8 +20,7 @@ harnessCfgLoad(unsigned int argListSize, const char *argList[])
FUNCTION_HARNESS_PARAM(CHARPY, argList);
FUNCTION_HARNESS_END();
- configParse(argListSize, argList);
- logInit(logLevelInfo, logLevelOff, logLevelDebug, false);
+ configParse(argListSize, argList, false);
cfgLoadUpdateOption();
FUNCTION_HARNESS_RESULT_VOID();
diff --git a/test/src/common/logTest.c b/test/src/common/harnessLog.c
similarity index 77%
rename from test/src/common/logTest.c
rename to test/src/common/harnessLog.c
index 3706ad011..4b2fdcc20 100644
--- a/test/src/common/logTest.c
+++ b/test/src/common/harnessLog.c
@@ -15,15 +15,17 @@ Log Test Harness
#ifndef NO_LOG
/***********************************************************************************************************************************
-Has the log harness been init'd?
+Expose log internal data for unit testing/debugging
***********************************************************************************************************************************/
-static bool harnessLogInit = false;
+extern LogLevel logLevelStdOut;
+extern LogLevel logLevelFile;
+extern int logHandleFile;
+extern bool logFileBanner;
/***********************************************************************************************************************************
Name of file where logs are stored for testing
***********************************************************************************************************************************/
-static char stdoutFile[1024];
-static char stderrFile[1024];
+static char logFile[1024];
/***********************************************************************************************************************************
Buffer where log results are loaded for comparison purposes
@@ -56,30 +58,34 @@ harnessLogOpen(const char *logFile, int flags, int mode)
Initialize log for testing
***********************************************************************************************************************************/
void
-testLogInit()
+harnessLogInit()
{
FUNCTION_HARNESS_VOID();
- if (!harnessLogInit)
- {
- logInit(logLevelInfo, logLevelOff, logLevelOff, false);
+ logInit(logLevelOff, logLevelOff, logLevelInfo, false);
+ logFileBanner = true;
- snprintf(stdoutFile, sizeof(stdoutFile), "%s/stdout.log", testPath());
- logHandleStdOut = harnessLogOpen(stdoutFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+ snprintf(logFile, sizeof(logFile), "%s/expect.log", testPath());
+ logHandleFile = harnessLogOpen(logFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
- snprintf(stderrFile, sizeof(stderrFile), "%s/stderr.log", testPath());
- logHandleStdErr = harnessLogOpen(stderrFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+ FUNCTION_HARNESS_RESULT_VOID();
+}
- harnessLogInit = true;
- }
+/***********************************************************************************************************************************
+Change test log level
- FUNCTION_HARNESS_RESULT_VOID();
+This is info by default but it can sometimes be useful to set the log level to something else.
+***********************************************************************************************************************************/
+void
+harnessLogLevelSet(LogLevel logLevel)
+{
+ logInit(logLevelStdOut, logLevelOff, logLevel, false);
}
/***********************************************************************************************************************************
Load log result from file into the log buffer
***********************************************************************************************************************************/
-void
+static void
harnessLogLoad(const char *logFile)
{
FUNCTION_HARNESS_BEGIN();
@@ -121,7 +127,7 @@ Compare log to a static string
After the comparison the log is cleared so the next result can be compared.
***********************************************************************************************************************************/
void
-testLogResult(const char *expected)
+harnessLogResult(const char *expected)
{
FUNCTION_HARNESS_BEGIN();
FUNCTION_HARNESS_PARAM(STRINGZ, expected);
@@ -129,13 +135,13 @@ testLogResult(const char *expected)
FUNCTION_HARNESS_ASSERT(expected != NULL);
FUNCTION_HARNESS_END();
- harnessLogLoad(stdoutFile);
+ harnessLogLoad(logFile);
if (strcmp(harnessLogBuffer, expected) != 0)
THROW_FMT(AssertError, "\n\nexpected log:\n\n%s\n\nbut actual log was:\n\n%s\n\n", expected, harnessLogBuffer);
- close(logHandleStdOut);
- logHandleStdOut = harnessLogOpen(stdoutFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+ close(logHandleFile);
+ logHandleFile = harnessLogOpen(logFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
FUNCTION_HARNESS_RESULT_VOID();
}
@@ -146,7 +152,7 @@ Compare log to a regexp
After the comparison the log is cleared so the next result can be compared.
***********************************************************************************************************************************/
void
-testLogResultRegExp(const char *expression)
+harnessLogResultRegExp(const char *expression)
{
FUNCTION_HARNESS_BEGIN();
FUNCTION_HARNESS_PARAM(STRINGZ, expression);
@@ -158,7 +164,7 @@ testLogResultRegExp(const char *expression)
TRY_BEGIN()
{
- harnessLogLoad(stdoutFile);
+ harnessLogLoad(logFile);
// Compile the regexp and process errors
int result = 0;
@@ -174,8 +180,8 @@ testLogResultRegExp(const char *expression)
if (regexec(®Exp, harnessLogBuffer, 0, NULL, 0) != 0)
THROW_FMT(AssertError, "\n\nexpected log regexp:\n\n%s\n\nbut actual log was:\n\n%s\n\n", expression, harnessLogBuffer);
- close(logHandleStdOut);
- logHandleStdOut = harnessLogOpen(stdoutFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+ close(logHandleFile);
+ logHandleFile = harnessLogOpen(logFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
}
FINALLY()
{
@@ -186,49 +192,19 @@ testLogResultRegExp(const char *expression)
FUNCTION_HARNESS_RESULT_VOID();
}
-/***********************************************************************************************************************************
-Compare error log to a static string
-
-After the comparison the log is cleared so the next result can be compared.
-***********************************************************************************************************************************/
-void
-testLogErrResult(const char *expected)
-{
- FUNCTION_HARNESS_BEGIN();
- FUNCTION_HARNESS_PARAM(STRINGZ, expected);
-
- FUNCTION_HARNESS_ASSERT(expected != NULL);
- FUNCTION_HARNESS_END();
-
- harnessLogLoad(stderrFile);
-
- if (strcmp(harnessLogBuffer, expected) != 0)
- THROW_FMT(AssertError, "\n\nexpected error log:\n\n%s\n\nbut actual error log was:\n\n%s\n\n", expected, harnessLogBuffer);
-
- close(logHandleStdErr);
- logHandleStdErr = harnessLogOpen(stderrFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
-
- FUNCTION_HARNESS_RESULT_VOID();
-}
-
/***********************************************************************************************************************************
Make sure nothing is left in the log after all tests have completed
***********************************************************************************************************************************/
void
-testLogFinal()
+harnessLogFinal()
{
FUNCTION_HARNESS_VOID();
- harnessLogLoad(stdoutFile);
+ harnessLogLoad(logFile);
if (strcmp(harnessLogBuffer, "") != 0)
THROW_FMT(AssertError, "\n\nexpected log to be empty but actual log was:\n\n%s\n\n", harnessLogBuffer);
- harnessLogLoad(stderrFile);
-
- if (strcmp(harnessLogBuffer, "") != 0)
- THROW_FMT(AssertError, "\n\nexpected error log to be empty but actual error log was:\n\n%s\n\n", harnessLogBuffer);
-
FUNCTION_HARNESS_RESULT_VOID();
}
diff --git a/test/src/common/logTest.h b/test/src/common/harnessLog.h
similarity index 52%
rename from test/src/common/logTest.h
rename to test/src/common/harnessLog.h
index 568d57d44..57254d32f 100644
--- a/test/src/common/logTest.h
+++ b/test/src/common/harnessLog.h
@@ -1,16 +1,20 @@
/***********************************************************************************************************************************
Log Test Harness
***********************************************************************************************************************************/
-#ifndef TEST_COMMON_LOG_H
-#define TEST_COMMON_LOG_H
+#ifndef TEST_COMMON_HARNESSLOG_H
+#define TEST_COMMON_HARNESSLOG_H
+
+#include "common/logLevel.h"
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
-void testLogInit();
-void testLogResult(const char *expected);
-void testLogResultRegExp(const char *expression);
-void testLogErrResult(const char *expected);
-void testLogFinal();
+void harnessLogResult(const char *expected);
+void harnessLogResultRegExp(const char *expression);
+
+/***********************************************************************************************************************************
+Setters
+***********************************************************************************************************************************/
+void harnessLogLevelSet(LogLevel logLevel);
#endif
diff --git a/test/src/common/harnessTest.c b/test/src/common/harnessTest.c
index 84ba44669..03d743665 100644
--- a/test/src/common/harnessTest.c
+++ b/test/src/common/harnessTest.c
@@ -7,7 +7,7 @@ C Test Harness
#include "common/harnessDebug.h"
#include "common/harnessTest.h"
-#include "common/logTest.h"
+#include "common/harnessLog.h"
#define TEST_LIST_SIZE 64
@@ -25,6 +25,14 @@ static bool testFirst = true;
static const char *testExeData = NULL;
static const char *testPathData = NULL;
+/***********************************************************************************************************************************
+Extern functions
+***********************************************************************************************************************************/
+#ifndef NO_LOG
+ void harnessLogInit();
+ void harnessLogFinal();
+#endif
+
/***********************************************************************************************************************************
Get and set the test exe
***********************************************************************************************************************************/
@@ -115,11 +123,9 @@ testBegin(const char *name)
if (testList[testRun - 1].selected)
{
#ifndef NO_LOG
-#ifndef IN_LOG
// Make sure there is nothing untested left in the log
if (!testFirst)
- testLogFinal();
-#endif
+ harnessLogFinal();
#endif
// No longer the first test
testFirst = false;
@@ -131,10 +137,8 @@ testBegin(const char *name)
fflush(stdout);
#ifndef NO_LOG
-#ifndef IN_LOG
// Initialize logging
- testLogInit();
-#endif
+ harnessLogInit();
#endif
result = true;
@@ -152,10 +156,8 @@ testComplete()
FUNCTION_HARNESS_VOID();
#ifndef NO_LOG
-#ifndef IN_LOG
// Make sure there is nothing untested left in the log
- testLogFinal();
-#endif
+ harnessLogFinal();
#endif
// Check that all tests ran
diff --git a/test/src/module/archive/commonTest.c b/test/src/module/archive/commonTest.c
index 207b7b66b..a66e05b0c 100644
--- a/test/src/module/archive/commonTest.c
+++ b/test/src/module/archive/commonTest.c
@@ -64,13 +64,13 @@ testRun()
storageNewWriteNP(storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))),
bufNewStr(strNew("0\nwarning")));
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "ok file with warning");
- testLogResult("P00 WARN: warning");
+ harnessLogResult("P00 WARN: warning");
storagePutNP(
storageNewWriteNP(storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))),
bufNewStr(strNew("25\nerror")));
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "error status renamed to ok");
- testLogResult(
+ harnessLogResult(
"P00 WARN: WAL segment '000000010000000100000001' was not pushed due to error [25] and was manually skipped: error");
// -------------------------------------------------------------------------------------------------------------------------
diff --git a/test/src/module/archive/getTest.c b/test/src/module/archive/getTest.c
index 003e010de..6bf8fec35 100644
--- a/test/src/module/archive/getTest.c
+++ b/test/src/module/archive/getTest.c
@@ -187,7 +187,7 @@ testRun()
storageNewWriteNP(storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s.ok", strPtr(walSegment))), NULL);
TEST_RESULT_VOID(cmdArchiveGet(), "successful get of missing WAL");
- testLogResult("P00 INFO: unable to find WAL segment 000000010000000100000001");
+ harnessLogResult("P00 INFO: unable to find WAL segment 000000010000000100000001");
TEST_RESULT_BOOL(
storageExistsNP(storageSpool(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s.ok", strPtr(walSegment))), false,
@@ -204,7 +204,7 @@ testRun()
bufNewStr(strNew("SHOULD-BE-A-REAL-WAL-FILE")));
TEST_RESULT_VOID(cmdArchiveGet(), "successful get");
- testLogResult("P00 INFO: got WAL segment 000000010000000100000001 asynchronously");
+ harnessLogResult("P00 INFO: got WAL segment 000000010000000100000001 asynchronously");
TEST_RESULT_BOOL(storageExistsNP(storageTest, walFile), true, "check WAL segment was moved");
storageRemoveP(storageTest, walFile, .errorOnMissing = true);
@@ -228,7 +228,7 @@ testRun()
bufNewStr(strNew("SHOULD-BE-A-REAL-WAL-FILE")));
TEST_RESULT_VOID(cmdArchiveGet(), "successful get");
- testLogResult("P00 INFO: got WAL segment 000000010000000100000001 asynchronously");
+ harnessLogResult("P00 INFO: got WAL segment 000000010000000100000001 asynchronously");
TEST_RESULT_BOOL(storageExistsNP(storageTest, walFile), true, "check WAL segment was moved");
diff --git a/test/src/module/archive/pushTest.c b/test/src/module/archive/pushTest.c
index b35d875ff..2cce78ff8 100644
--- a/test/src/module/archive/pushTest.c
+++ b/test/src/module/archive/pushTest.c
@@ -22,13 +22,13 @@ testRun()
strLstAddZ(argList, "--archive-timeout=1");
strLstAddZ(argList, "--stanza=db");
strLstAddZ(argList, "archive-push");
- cfgLoad(strLstSize(argList), strLstPtr(argList));
+ harnessCfgLoad(strLstSize(argList), strLstPtr(argList));
TEST_ERROR(cmdArchivePush(), ParamRequiredError, "WAL segment to push required");
// -------------------------------------------------------------------------------------------------------------------------
strLstAddZ(argList, "000000010000000100000001");
- cfgLoad(strLstSize(argList), strLstPtr(argList));
+ harnessCfgLoad(strLstSize(argList), strLstPtr(argList));
TEST_ERROR(cmdArchivePush(), AssertError, "archive-push in C does not support synchronous mode");
@@ -70,7 +70,7 @@ testRun()
bufNewStr(strNew("")));
TEST_RESULT_VOID(cmdArchivePush(), "successful push");
- testLogResult("P00 INFO: pushed WAL segment 000000010000000100000001 asynchronously");
+ harnessLogResult("P00 INFO: pushed WAL segment 000000010000000100000001 asynchronously");
storageRemoveP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/000000010000000100000001.ok"), .errorOnMissing = true);
diff --git a/test/src/module/command/commandTest.c b/test/src/module/command/commandTest.c
index 170c1b115..c11b6853c 100644
--- a/test/src/module/command/commandTest.c
+++ b/test/src/module/command/commandTest.c
@@ -32,14 +32,14 @@ testRun()
cfgCommandParamSet(commandParamList);
TEST_RESULT_VOID(cmdBegin(true), "command begin with command parameter");
- testLogResult(
+ harnessLogResult(
"P00 INFO: archive-get command begin " PGBACKREST_VERSION ": [param1] --compress");
strLstAddZ(commandParamList, "param 2");
cfgCommandParamSet(commandParamList);
TEST_RESULT_VOID(cmdBegin(true), "command begin with command parameters");
- testLogResult(
+ harnessLogResult(
"P00 INFO: archive-get command begin " PGBACKREST_VERSION ": [param1, \"param 2\"] --compress");
cfgInit();
@@ -78,32 +78,32 @@ testRun()
cfgOptionSet(cfgOptRecoveryOption, cfgSourceParam, recoveryVar);
TEST_RESULT_VOID(cmdBegin(true), "command begin with option logging");
- testLogResult(
+ harnessLogResult(
"P00 INFO: archive-get command begin " PGBACKREST_VERSION ": --no-config --db-include=db1 --db-include=db2"
" --recovery-option=standby_mode=on --recovery-option=primary_conn_info=blah --reset-repo1-host"
" --repo1-path=\"/path/to the/repo\" --repo1-s3-key=<redacted>");
TEST_RESULT_VOID(cmdBegin(false), "command begin no option logging");
- testLogResult(
+ harnessLogResult(
"P00 INFO: archive-get command begin");
// Nothing should be logged for command begin when the log level is too low
// -------------------------------------------------------------------------------------------------------------------------
- logInit(logLevelWarn, logLevelOff, logLevelOff, false);
+ harnessLogLevelSet(logLevelWarn);
TEST_RESULT_VOID(cmdBegin(true), "command begin no logging");
// Nothing should be logged for command end when the log level is too low
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(cmdEnd(0, NULL), "command end no logging");
- logInit(logLevelInfo, logLevelOff, logLevelOff, false);
+ harnessLogLevelSet(logLevelInfo);
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(cmdEnd(25, strNew("aborted with exception [025]")), "command end with error");
- testLogResult("P00 INFO: archive-get command end: aborted with exception [025]");
+ harnessLogResult("P00 INFO: archive-get command end: aborted with exception [025]");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(cmdEnd(0, NULL), "command end with success");
- testLogResult("P00 INFO: archive-get command end: completed successfully");
+ harnessLogResult("P00 INFO: archive-get command end: completed successfully");
// Make sure time output is covered but don't do expect testing since the output is variable
// -------------------------------------------------------------------------------------------------------------------------
@@ -111,12 +111,12 @@ testRun()
cfgOptionSet(cfgOptLogTimestamp, cfgSourceParam, varNewBool(false));
TEST_RESULT_VOID(cmdEnd(0, NULL), "command end with success");
- testLogResult("P00 INFO: archive-get command end: completed successfully");
+ harnessLogResult("P00 INFO: archive-get command end: completed successfully");
cfgOptionSet(cfgOptLogTimestamp, cfgSourceParam, varNewBool(true));
TEST_RESULT_VOID(cmdEnd(0, NULL), "command end with success");
- testLogResultRegExp("P00 INFO\\: archive-get command end: completed successfully \\([0-9]+ms\\)");
+ harnessLogResultRegExp("P00 INFO\\: archive-get command end: completed successfully \\([0-9]+ms\\)");
}
FUNCTION_HARNESS_RESULT_VOID();
diff --git a/test/src/module/common/debugOnTest.c b/test/src/module/common/debugOnTest.c
index 018f1a7c0..1b9f5c7e4 100644
--- a/test/src/module/common/debugOnTest.c
+++ b/test/src/module/common/debugOnTest.c
@@ -3,7 +3,7 @@ Test Debug Macros and Routines
***********************************************************************************************************************************/
#include "common/log.h"
-#include "common/logTest.h"
+#include "common/harnessLog.h"
static void
testFunction3()
@@ -111,22 +111,22 @@ testRun()
// *****************************************************************************************************************************
if (testBegin("FUNCTION_DEBUG() and FUNCTION_DEBUG_RESULT()"))
{
- logInit(logLevelTrace, logLevelOff, logLevelOff, false);
+ harnessLogLevelSet(logLevelTrace);
testFunction1(99, false, 1.17, 0755);
- testLogResult(
+ harnessLogResult(
"P00 DEBUG: module/common/debugOnTest::testFunction1: (paramInt: 99, paramBool: false, paramDouble: 1.17"
", paramMode: 0755)\n"
"P00 TRACE: module/common/debugOnTest::testFunction2: (void)\n"
"P00 TRACE: module/common/debugOnTest::testFunction2: => void\n"
"P00 DEBUG: module/common/debugOnTest::testFunction1: => 1");
- logInit(logLevelTrace, logLevelOff, logLevelOff, false);
+ harnessLogLevelSet(logLevelTrace);
// -------------------------------------------------------------------------------------------------------------------------
- logInit(logLevelInfo, logLevelOff, logLevelOff, false);
+ harnessLogLevelSet(logLevelInfo);
testFunction1(55, true, 0.99, 0755);
- testLogResult("");
+ harnessLogResult("");
}
FUNCTION_HARNESS_RESULT_VOID();
diff --git a/test/src/module/common/exitTest.c b/test/src/module/common/exitTest.c
index 5bf34dc9a..36c591082 100644
--- a/test/src/module/common/exitTest.c
+++ b/test/src/module/common/exitTest.c
@@ -53,7 +53,7 @@ testRun()
cfgCommandSet(cfgCmdArchivePush);
TEST_RESULT_INT(exitSafe(0, false, signalTypeNone), 0, "exit with no error")
- testLogResult("P00 INFO: archive-push command end: completed successfully");
+ harnessLogResult("P00 INFO: archive-push command end: completed successfully");
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
@@ -63,14 +63,14 @@ testRun()
CATCH_ANY()
{
exitSafe(0, true, signalTypeNone);
- testLogResult(
+ harnessLogResult(
"P00 ERROR: [122]: test error message\n"
"P00 INFO: archive-push command end: aborted with exception [122]");
}
TRY_END();
// -------------------------------------------------------------------------------------------------------------------------
- logInit(logLevelDebug, logLevelOff, logLevelOff, false);
+ harnessLogLevelSet(logLevelDebug);
TRY_BEGIN()
{
@@ -79,7 +79,7 @@ testRun()
CATCH_ANY()
{
exitSafe(0, true, signalTypeNone);
- testLogResultRegExp(
+ harnessLogResultRegExp(
"P00 ERROR\\: \\[122\\]\\: test debug error message\n"
" STACK TRACE\\:\n"
" module\\/common\\/exitTest\\:testRun\\:.*\n"
@@ -87,7 +87,7 @@ testRun()
}
TRY_END();
- logInit(logLevelInfo, logLevelOff, logLevelOff, false);
+ harnessLogLevelSet(logLevelInfo);
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
@@ -97,7 +97,7 @@ testRun()
CATCH_ANY()
{
exitSafe(0, true, signalTypeNone);
- testLogResultRegExp(
+ harnessLogResultRegExp(
"P00 ASSERT\\: \\[025\\]\\: test assert message\n"
" STACK TRACE\\:\n"
" module/common/exitTest\\:testRun\\:.*\n"
@@ -113,7 +113,7 @@ testRun()
CATCH_ANY()
{
exitSafe(0, true, signalTypeNone);
- testLogResult(
+ harnessLogResult(
"P00 INFO: archive-push command end: aborted with exception [122]");
}
TRY_END();
@@ -121,12 +121,12 @@ testRun()
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(
exitSafe(errorTypeCode(&TermError), false, signalTypeNone), errorTypeCode(&TermError), "exit on term with no signal");
- testLogResult("P00 INFO: archive-push command end: terminated on signal from child process");
+ harnessLogResult("P00 INFO: archive-push command end: terminated on signal from child process");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(
exitSafe(errorTypeCode(&TermError), false, signalTypeTerm), errorTypeCode(&TermError), "exit on term with SIGTERM");
- testLogResult("P00 INFO: archive-push command end: terminated on signal [SIGTERM]");
+ harnessLogResult("P00 INFO: archive-push command end: terminated on signal [SIGTERM]");
}
FUNCTION_HARNESS_RESULT_VOID();
diff --git a/test/src/module/common/logTest.c b/test/src/module/common/logTest.c
index f7da25a9a..b76d5c94c 100644
--- a/test/src/module/common/logTest.c
+++ b/test/src/module/common/logTest.c
@@ -5,10 +5,94 @@ Test Log Handler
#include <unistd.h>
#include <common/regExp.h>
-#include <storage/storage.h>
-void harnessLogLoad(const char *logFile);
-extern char harnessLogBuffer[];
+/***********************************************************************************************************************************
+Open a log file
+***********************************************************************************************************************************/
+static int
+testLogOpen(const char *logFile, int flags, int mode)
+{
+ FUNCTION_HARNESS_BEGIN();
+ FUNCTION_HARNESS_PARAM(STRINGZ, logFile);
+ FUNCTION_HARNESS_PARAM(INT, flags);
+ FUNCTION_HARNESS_PARAM(INT, mode);
+
+ FUNCTION_HARNESS_ASSERT(logFile != NULL);
+ FUNCTION_HARNESS_END();
+
+ int result = open(logFile, flags, mode);
+
+ if (result == -1) // {uncovered - no errors in test}
+ THROW_SYS_ERROR_FMT(FileOpenError, "unable to open log file '%s'", logFile); // {+uncovered}
+
+ FUNCTION_HARNESS_RESULT(INT, result);
+}
+
+/***********************************************************************************************************************************
+Load log result from file into a buffer
+***********************************************************************************************************************************/
+static void
+testLogLoad(const char *logFile, char *buffer, size_t bufferSize)
+{
+ FUNCTION_HARNESS_BEGIN();
+ FUNCTION_HARNESS_PARAM(STRINGZ, logFile);
+ FUNCTION_HARNESS_PARAM(STRINGZ, buffer);
+ FUNCTION_HARNESS_PARAM(SIZE, bufferSize);
+
+ FUNCTION_HARNESS_ASSERT(logFile != NULL);
+ FUNCTION_HARNESS_ASSERT(buffer != NULL);
+ FUNCTION_HARNESS_END();
+
+ buffer[0] = 0;
+
+ int handle = testLogOpen(logFile, O_RDONLY, 0);
+
+ size_t totalBytes = 0;
+ ssize_t actualBytes = 0;
+
+ do
+ {
+ actualBytes = read(handle, buffer, bufferSize - totalBytes);
+
+ if (actualBytes == -1) // {uncovered - no errors in test}
+ THROW_SYS_ERROR_FMT(FileOpenError, "unable to read log file '%s'", logFile); // {+uncovered}
+
+ totalBytes += (size_t)actualBytes;
+ }
+ while (actualBytes != 0);
+
+ if (close(handle) == -1) // {uncovered - no errors in test}
+ THROW_SYS_ERROR_FMT(FileOpenError, "unable to close log file '%s'", logFile); // {+uncovered}
+
+ // Remove final linefeed
+ buffer[totalBytes - 1] = 0;
+
+ FUNCTION_HARNESS_RESULT_VOID();
+}
+
+/***********************************************************************************************************************************
+Compare log to a static string
+***********************************************************************************************************************************/
+void
+testLogResult(const char *logFile, const char *expected)
+{
+ FUNCTION_HARNESS_BEGIN();
+ FUNCTION_HARNESS_PARAM(STRINGZ, logFile);
+ FUNCTION_HARNESS_PARAM(STRINGZ, expected);
+
+ FUNCTION_HARNESS_ASSERT(logFile != NULL);
+ FUNCTION_HARNESS_ASSERT(expected != NULL);
+ FUNCTION_HARNESS_END();
+
+ char actual[32768];
+ testLogLoad(logFile, actual, sizeof(actual));
+
+ if (strcmp(actual, expected) != 0) // {uncovered - no errors in test}
+ THROW_FMT( // {+uncovered}
+ AssertError, "\n\nexpected log:\n\n%s\n\nbut actual log was:\n\n%s\n\n", expected, actual);
+
+ FUNCTION_HARNESS_RESULT_VOID();
+}
/***********************************************************************************************************************************
Test Run
@@ -104,7 +188,14 @@ testRun()
true, "check timestamp format: %s", strPtr(logTime));
// Redirect output to files
- testLogInit();
+ char stdoutFile[1024];
+ snprintf(stdoutFile, sizeof(stdoutFile), "%s/stdout.log", testPath());
+ logHandleStdOut = testLogOpen(stdoutFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+
+ char stderrFile[1024];
+ snprintf(stderrFile, sizeof(stderrFile), "%s/stderr.log", testPath());
+ logHandleStdErr = testLogOpen(stderrFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+
TEST_RESULT_VOID(logInit(logLevelWarn, logLevelOff, logLevelOff, false), "init logging to warn (timestamp off)");
logBuffer[0] = 0;
@@ -129,8 +220,9 @@ testRun()
TEST_RESULT_VOID(logInit(logLevelDebug, logLevelDebug, logLevelDebug, false), "init logging to debug");
// Log to file
- String *fileFile = strNewFmt("%s/file.log", testPath());
- logFileSet(strPtr(fileFile));
+ char fileFile[1024];
+ snprintf(fileFile, sizeof(stdoutFile), "%s/file.log", testPath());
+ logFileSet(fileFile);
logBuffer[0] = 0;
TEST_RESULT_VOID(
@@ -147,7 +239,7 @@ testRun()
TEST_RESULT_STR(logBuffer, "P00 TRACE: test::test_func: message\n", " check log");
// Reopen the log file
- logFileSet(strPtr(fileFile));
+ logFileSet(fileFile);
logBuffer[0] = 0;
TEST_RESULT_VOID(
@@ -162,13 +254,15 @@ testRun()
// Check stdout
testLogResult(
+ stdoutFile,
"P00 WARN: format 99\n"
"P00 ERROR: [026]: message\n"
"P00 ERROR: [026]: message1\n"
" message2");
// Check stderr
- testLogErrResult(
+ testLogResult(
+ stderrFile,
"DEBUG: test::test_func: message\n"
" message2\n"
"INFO: info message\n"
@@ -177,18 +271,15 @@ testRun()
" NOTE: process will continue without log file.");
// Check file
- harnessLogLoad(strPtr(fileFile));
-
- TEST_RESULT_STR(
- harnessLogBuffer,
+ testLogResult(
+ fileFile,
"-------------------PROCESS START-------------------\n"
"P00 DEBUG: test::test_func: message\n"
" message2\n"
"\n"
"-------------------PROCESS START-------------------\n"
"P00 INFO: info message\n"
- "P00 INFO: info message 2",
- "checkout file output");
+ "P00 INFO: info message 2");
}
FUNCTION_HARNESS_RESULT_VOID();
diff --git a/test/src/module/config/loadTest.c b/test/src/module/config/loadTest.c
index 4d7792a2d..44976d254 100644
--- a/test/src/module/config/loadTest.c
+++ b/test/src/module/config/loadTest.c
@@ -7,6 +7,14 @@ Test Configuration Load
#include "common/harnessConfig.h"
+/***********************************************************************************************************************************
+Expose log internal data for unit testing/debugging
+***********************************************************************************************************************************/
+extern LogLevel logLevelStdOut;
+extern LogLevel logLevelStdErr;
+extern LogLevel logLevelFile;
+extern bool logTimestamp;
+
/***********************************************************************************************************************************
Test run
***********************************************************************************************************************************/
@@ -144,13 +152,12 @@ testRun()
StringList *argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("--stanza=db"));
- strLstAdd(argList, strNew("--log-level-console=info"));
- strLstAdd(argList, strNew("--log-level-stderr=off"));
strLstAdd(argList, strNew("--no-log-timestamp"));
strLstAdd(argList, strNew("expire"));
+ harnessLogLevelSet(logLevelWarn);
TEST_RESULT_VOID(harnessCfgLoad(strLstSize(argList), strLstPtr(argList)), "load config for retention warning");
- testLogResult(
+ harnessLogResult(
"P00 WARN: option repo1-retention-full is not set, the repository may run out of space\n"
" HINT: to retain full backups indefinitely (without warning), set option"
" 'repo1-retention-full' to the maximum.");
@@ -168,14 +175,12 @@ testRun()
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("--stanza=db"));
- strLstAdd(argList, strNew("--log-level-console=info"));
- strLstAdd(argList, strNew("--log-level-stderr=off"));
strLstAdd(argList, strNew("--no-log-timestamp"));
strLstAdd(argList, strNew("--repo1-retention-archive-type=incr"));
strLstAdd(argList, strNew("expire"));
TEST_RESULT_VOID(harnessCfgLoad(strLstSize(argList), strLstPtr(argList)), "load config for retention warning");
- testLogResult(
+ harnessLogResult(
"P00 WARN: option repo1-retention-full is not set, the repository may run out of space\n"
" HINT: to retain full backups indefinitely (without warning), set option 'repo1-retention-full'"
" to the maximum.\n"
@@ -186,14 +191,12 @@ testRun()
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("--stanza=db"));
- strLstAdd(argList, strNew("--log-level-console=info"));
- strLstAdd(argList, strNew("--log-level-stderr=off"));
strLstAdd(argList, strNew("--no-log-timestamp"));
strLstAdd(argList, strNew("--repo1-retention-archive-type=diff"));
strLstAdd(argList, strNew("expire"));
TEST_RESULT_VOID(harnessCfgLoad(strLstSize(argList), strLstPtr(argList)), "load config for retention warning");
- testLogResult(
+ harnessLogResult(
"P00 WARN: option repo1-retention-full is not set, the repository may run out of space\n"
" HINT: to retain full backups indefinitely (without warning), set option"
" 'repo1-retention-full' to the maximum.\n"
@@ -204,7 +207,7 @@ testRun()
strLstAdd(argList, strNew("--repo1-retention-diff=2"));
TEST_RESULT_VOID(harnessCfgLoad(strLstSize(argList), strLstPtr(argList)), "load config for retention warning");
- testLogResult(
+ harnessLogResult(
"P00 WARN: option repo1-retention-full is not set, the repository may run out of space\n"
" HINT: to retain full backups indefinitely (without warning), set option"
" 'repo1-retention-full' to the maximum.");
@@ -213,8 +216,6 @@ testRun()
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("--stanza=db"));
- strLstAdd(argList, strNew("--log-level-console=info"));
- strLstAdd(argList, strNew("--log-level-stderr=off"));
strLstAdd(argList, strNew("--no-log-timestamp"));
strLstAdd(argList, strNew("--repo1-retention-archive-type=diff"));
strLstAdd(argList, strNew("--repo1-retention-archive=3"));
@@ -222,7 +223,7 @@ testRun()
strLstAdd(argList, strNew("expire"));
TEST_RESULT_VOID(harnessCfgLoad(strLstSize(argList), strLstPtr(argList)), "load config for retention warning");
- testLogResult(
+ harnessLogResult(
"P00 WARN: option 'repo1-retention-diff' is not set for 'repo1-retention-archive-type=diff'\n"
" HINT: to retain differential backups indefinitely (without warning), set option 'repo1-retention-diff'"
" to the maximum.");
@@ -244,6 +245,9 @@ testRun()
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("--stanza=db"));
+ strLstAdd(argList, strNew("--log-level-console=off"));
+ strLstAdd(argList, strNew("--log-level-stderr=off"));
+ strLstAdd(argList, strNew("--log-level-file=off"));
strLstAdd(argList, strNew("archive-get"));
umask(0111);
@@ -256,6 +260,9 @@ testRun()
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("--stanza=db"));
strLstAdd(argList, strNew("--no-neutral-umask"));
+ strLstAdd(argList, strNew("--log-level-console=off"));
+ strLstAdd(argList, strNew("--log-level-stderr=off"));
+ strLstAdd(argList, strNew("--log-level-file=off"));
strLstAdd(argList, strNew("archive-get"));
umask(0111);
@@ -285,6 +292,9 @@ testRun()
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("help"));
strLstAdd(argList, strNew("backup"));
+ strLstAdd(argList, strNew("--log-level-console=off"));
+ strLstAdd(argList, strNew("--log-level-stderr=off"));
+ strLstAdd(argList, strNew("--log-level-file=off"));
strLstAdd(argList, strNew("--repo1-retention-full=2"));
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "help command for backup");
@@ -298,6 +308,9 @@ testRun()
strLstAdd(argList, strNew("--pg1-path=/path"));
strLstAdd(argList, strNew("--repo1-retention-full=1"));
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
+ strLstAdd(argList, strNew("--log-level-console=off"));
+ strLstAdd(argList, strNew("--log-level-stderr=off"));
+ strLstAdd(argList, strNew("--log-level-file=off"));
strLstAdd(argList, strNew("backup"));
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "lock and open log file");
diff --git a/test/src/module/config/parseTest.c b/test/src/module/config/parseTest.c
index f1d6f1d0b..9718d59b1 100644
--- a/test/src/module/config/parseTest.c
+++ b/test/src/module/config/parseTest.c
@@ -9,6 +9,13 @@ Test Configuration Parse
#define TEST_COMMAND_RESTORE "restore"
#define TEST_COMMAND_VERSION "version"
+/***********************************************************************************************************************************
+Expose log internal data for unit testing/debugging
+***********************************************************************************************************************************/
+extern LogLevel logLevelStdOut;
+extern LogLevel logLevelStdErr;
+extern LogLevel logLevelFile;
+
/***********************************************************************************************************************************
Option find test -- this is done a lot in the deprecated tests
***********************************************************************************************************************************/
@@ -93,16 +100,17 @@ testRun()
"pg1-path=/path/to/db\n"
"recovery-option=c=d\n")));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_BACKUP " command with config-include");
- testLogErrResult(
+ TEST_RESULT_VOID(
+ configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command with config-include");
+ harnessLogResult(
strPtr(
strNew(
- "WARN: configuration file contains option 'recovery-option' invalid for section 'db:backup'\n"
- "WARN: configuration file contains invalid option 'bogus'\n"
- "WARN: configuration file contains negate option 'no-compress'\n"
- "WARN: configuration file contains reset option 'reset-compress'\n"
- "WARN: configuration file contains command-line only option 'online'\n"
- "WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'")));
+ "P00 WARN: configuration file contains option 'recovery-option' invalid for section 'db:backup'\n"
+ "P00 WARN: configuration file contains invalid option 'bogus'\n"
+ "P00 WARN: configuration file contains negate option 'no-compress'\n"
+ "P00 WARN: configuration file contains reset option 'reset-compress'\n"
+ "P00 WARN: configuration file contains command-line only option 'online'\n"
+ "P00 WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'")));
TEST_RESULT_BOOL(cfgOptionTest(cfgOptPgHost), false, " pg1-host is not set (command line reset override)");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgPath)), "/path/to/db", " pg1-path is set");
@@ -547,20 +555,21 @@ testRun()
argList = strLstNew();
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
strLstAdd(argList, strNew(BOGUS_STR));
- TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)), CommandInvalidError, "invalid command 'BOGUS'");
+ TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), CommandInvalidError, "invalid command 'BOGUS'");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
strLstAdd(argList, strNew("--" BOGUS_STR));
- TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "invalid option '--BOGUS'");
+ TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError, "invalid option '--BOGUS'");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
strLstAdd(argList, strNew("--pg1-host"));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option '--pg1-host' requires argument");
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
+ "option '--pg1-host' requires argument");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@@ -568,7 +577,8 @@ testRun()
strLstAdd(argList, strNew("--no-online"));
strLstAdd(argList, strNew("--no-online"));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option 'online' is negated multiple times");
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
+ "option 'online' is negated multiple times");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@@ -576,7 +586,8 @@ testRun()
strLstAdd(argList, strNew("--reset-pg1-host"));
strLstAdd(argList, strNew("--reset-pg1-host"));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option 'pg1-host' is reset multiple times");
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
+ "option 'pg1-host' is reset multiple times");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@@ -584,7 +595,8 @@ testRun()
strLstAdd(argList, strNew("--no-config"));
strLstAdd(argList, strNew("--config=/etc/config"));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option 'config' cannot be set and negated");
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
+ "option 'config' cannot be set and negated");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@@ -592,7 +604,8 @@ testRun()
strLstAdd(argList, strNew("--reset-log-path"));
strLstAdd(argList, strNew("--log-path=/var/log"));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option 'log-path' cannot be set and reset");
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
+ "option 'log-path' cannot be set and reset");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@@ -600,7 +613,7 @@ testRun()
strLstAdd(argList, strNew("--no-compress"));
strLstAdd(argList, strNew("--reset-compress"));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'compress' cannot be negated and reset");
// -------------------------------------------------------------------------------------------------------------------------
@@ -609,7 +622,7 @@ testRun()
strLstAdd(argList, strNew("--reset-compress"));
strLstAdd(argList, strNew("--no-compress"));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'compress' cannot be negated and reset");
// -------------------------------------------------------------------------------------------------------------------------
@@ -619,21 +632,21 @@ testRun()
strLstAdd(argList, strNew("--compress-level=3"));
strLstAdd(argList, strNew("--compress-level=3"));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'compress-level' cannot have multiple arguments");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
strLstAdd(argList, strNew("--online"));
- TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)), CommandRequiredError, "no command found");
+ TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), CommandRequiredError, "no command found");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
strLstAdd(argList, strNew("--manifest-save-threshold=123Q"));
- TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
+ TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
"'123Q' is not valid for 'manifest-save-threshold' option");
// -------------------------------------------------------------------------------------------------------------------------
@@ -641,7 +654,7 @@ testRun()
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
strLstAdd(argList, strNew("--manifest-save-threshold=199999999999999999999p"));
- TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
+ TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
"'225179981368524800000000000000000000' is out of range for 'manifest-save-threshold' option");
// Local and remove commands should not modify log levels during parsing
@@ -658,7 +671,7 @@ testRun()
logLevelStdOut = logLevelError;
logLevelStdErr = logLevelError;
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "load local config");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "load local config");
TEST_RESULT_INT(logLevelStdOut, logLevelError, "console logging is error");
TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error");
@@ -673,7 +686,7 @@ testRun()
logLevelStdOut = logLevelError;
logLevelStdErr = logLevelError;
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "load remote config");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "load remote config");
TEST_RESULT_INT(logLevelStdOut, logLevelError, "console logging is error");
TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error");
@@ -682,7 +695,7 @@ testRun()
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionRequiredError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
"backup command requires option: pg1-path\nHINT: does this stanza exist?");
// -------------------------------------------------------------------------------------------------------------------------
@@ -691,7 +704,7 @@ testRun()
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionRequiredError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
"backup command requires option: stanza");
// -------------------------------------------------------------------------------------------------------------------------
@@ -703,7 +716,7 @@ testRun()
strLstAdd(argList, strNew("--repo1-s3-key=xxx"));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'repo1-s3-key' is not allowed on the command-line\n"
"HINT: this option could expose secrets in the process list.\n"
"HINT: specify the option in '/etc/pgbackrest/pgbackrest.conf' instead.");
@@ -717,7 +730,7 @@ testRun()
strLstAdd(argList, strNew("--repo1-s3-host=xxx"));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'repo1-s3-host' not valid without option 'repo1-type' = 's3'");
// -------------------------------------------------------------------------------------------------------------------------
@@ -728,7 +741,7 @@ testRun()
strLstAdd(argList, strNew("--stanza=db"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'repo1-host-user' not valid without option 'repo1-host'");
// -------------------------------------------------------------------------------------------------------------------------
@@ -739,7 +752,7 @@ testRun()
strLstAdd(argList, strNew("--force"));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'force' not valid without option 'no-online'");
// -------------------------------------------------------------------------------------------------------------------------
@@ -750,7 +763,7 @@ testRun()
strLstAdd(argList, strNew("--test-delay=1"));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'test-delay' not valid without option 'test'");
// -------------------------------------------------------------------------------------------------------------------------
@@ -761,7 +774,7 @@ testRun()
strLstAdd(argList, strNew("--recovery-option=a=b"));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'recovery-option' not valid for command 'backup'");
// -------------------------------------------------------------------------------------------------------------------------
@@ -772,7 +785,7 @@ testRun()
strLstAdd(argList, strNew("--target-exclusive"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"option 'target-exclusive' not valid without option 'type' in ('time', 'xid')");
// -------------------------------------------------------------------------------------------------------------------------
@@ -783,7 +796,7 @@ testRun()
strLstAdd(argList, strNew("--type=bogus"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
"'bogus' is not allowed for 'type' option");
// Lower and upper bounds for integer ranges
@@ -795,7 +808,7 @@ testRun()
strLstAdd(argList, strNew("--process-max=0"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
"'0' is out of range for 'process-max' option");
argList = strLstNew();
@@ -805,7 +818,7 @@ testRun()
strLstAdd(argList, strNew("--process-max=65536"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
"'65536' is out of range for 'process-max' option");
// -------------------------------------------------------------------------------------------------------------------------
@@ -816,7 +829,7 @@ testRun()
strLstAdd(argList, strNew("--process-max=bogus"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
"'bogus' is not valid for 'process-max' option");
// -------------------------------------------------------------------------------------------------------------------------
@@ -827,7 +840,7 @@ testRun()
strLstAdd(argList, strNew("--protocol-timeout=.01"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
"'.01' is out of range for 'protocol-timeout' option");
// -------------------------------------------------------------------------------------------------------------------------
@@ -838,7 +851,7 @@ testRun()
strLstAdd(argList, strNew("--protocol-timeout=bogus"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
"'bogus' is not valid for 'protocol-timeout' option");
// -------------------------------------------------------------------------------------------------------------------------
@@ -854,7 +867,7 @@ testRun()
)));
TEST_ERROR(configParse(
- strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "boolean option 'compress' must be 'y' or 'n'");
+ strLstSize(argList), strLstPtr(argList), false), OptionInvalidError, "boolean option 'compress' must be 'y' or 'n'");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@@ -869,7 +882,7 @@ testRun()
)));
TEST_ERROR(configParse(
- strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
+ strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
"section 'global', key 'compress' must have a value");
// -------------------------------------------------------------------------------------------------------------------------
@@ -886,7 +899,7 @@ testRun()
)));
TEST_ERROR(configParse(
- strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
strPtr(strNew("configuration file contains duplicate options ('db-path', 'pg1-path') in section '[db]'")));
// -------------------------------------------------------------------------------------------------------------------------
@@ -902,26 +915,32 @@ testRun()
"pg1-path=/also/path/to/db\n"
)));
- TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)),
+ TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false),
OptionInvalidError,
"option 'pg1-path' cannot have multiple arguments");
+ // Test that log levels are set correctly when reset is enabled, then set them back to harness defaults
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "no command");
+ logLevelStdOut = logLevelOff;
+ logLevelStdErr = logLevelOff;
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), true), "no command");
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdNone, " command is none");
TEST_RESULT_INT(logLevelStdOut, logLevelWarn, "console logging is warn");
TEST_RESULT_INT(logLevelStdErr, logLevelWarn, "stderr logging is warn");
+ logLevelStdOut = logLevelOff;
+ logLevelStdErr = logLevelOff;
+ logLevelFile = logLevelInfo;
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
strLstAdd(argList, strNew("help"));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help command");
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdHelp, " command is help");
@@ -931,7 +950,7 @@ testRun()
strLstAdd(argList, strNew("help"));
strLstAdd(argList, strNew("version"));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help for version command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for version command");
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdVersion, " command is version");
@@ -942,7 +961,7 @@ testRun()
strLstAdd(argList, strNew("help"));
strLstAdd(argList, strNew("backup"));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help for backup command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for backup command");
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, " command is backup");
TEST_RESULT_BOOL(cfgOptionValid(cfgOptPgPath), true, " pg1-path is valid");
@@ -955,7 +974,7 @@ testRun()
strLstAdd(argList, strNew(TEST_COMMAND_ARCHIVE_GET));
strLstAdd(argList, strNew("000000010000000200000003"));
strLstAdd(argList, strNew("/path/to/wal/RECOVERYWAL"));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "command arguments");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "command arguments");
TEST_RESULT_STR(
strPtr(strLstJoin(cfgCommandParam(), "|")), "000000010000000200000003|/path/to/wal/RECOVERYWAL",
" check command arguments");
@@ -968,7 +987,7 @@ testRun()
strLstAdd(argList, strNew("--no-online"));
strLstAdd(argList, strNew("--no-config"));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_BACKUP " command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, " command is " TEST_COMMAND_BACKUP);
TEST_RESULT_STR(strPtr(cfgExe()), TEST_BACKREST_EXE, " exe is set");
@@ -1024,16 +1043,16 @@ testRun()
"recovery-option=c=d\n"
)));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_BACKUP " command");
- testLogErrResult(
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
+ harnessLogResult(
strPtr(
strNew(
- "WARN: configuration file contains option 'recovery-option' invalid for section 'db:backup'\n"
- "WARN: configuration file contains invalid option 'bogus'\n"
- "WARN: configuration file contains negate option 'no-compress'\n"
- "WARN: configuration file contains reset option 'reset-compress'\n"
- "WARN: configuration file contains command-line only option 'online'\n"
- "WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'")));
+ "P00 WARN: configuration file contains option 'recovery-option' invalid for section 'db:backup'\n"
+ "P00 WARN: configuration file contains invalid option 'bogus'\n"
+ "P00 WARN: configuration file contains negate option 'no-compress'\n"
+ "P00 WARN: configuration file contains reset option 'reset-compress'\n"
+ "P00 WARN: configuration file contains command-line only option 'online'\n"
+ "P00 WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'")));
TEST_RESULT_BOOL(cfgOptionTest(cfgOptPgHost), false, " pg1-host is not set (command line reset override)");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgPath)), "/path/to/db", " pg1-path is set");
@@ -1065,7 +1084,7 @@ testRun()
"spool-path=/path/to/spool\n"
)));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "archive-push command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "archive-push command");
TEST_RESULT_INT(cfgOptionInt64(cfgOptArchivePushQueueMax), 4503599627370496, "archive-push-queue-max is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptArchivePushQueueMax), cfgSourceParam, " archive-push-queue-max is source config");
@@ -1082,7 +1101,7 @@ testRun()
strLstAdd(argList, strNew("--stanza=db"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"key/value 'a' not valid for 'recovery-option' option");
// -------------------------------------------------------------------------------------------------------------------------
@@ -1093,7 +1112,7 @@ testRun()
strLstAdd(argList, strNew("--stanza=db"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
TEST_ERROR(
- configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
+ configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
"key/value 'a' not valid for 'recovery-option' option");
// -------------------------------------------------------------------------------------------------------------------------
@@ -1104,7 +1123,7 @@ testRun()
strLstAdd(argList, strNew("--db-include=def"));
strLstAdd(argList, strNew("--stanza=db"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_RESTORE " command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
const VariantList *includeList = NULL;
TEST_ASSIGN(includeList, cfgOptionLst(cfgOptDbInclude), "get db include options");
@@ -1119,7 +1138,7 @@ testRun()
strLstAdd(argList, strNew("--recovery-option=c=de=fg hi"));
strLstAdd(argList, strNew("--stanza=db"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_RESTORE " command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
const KeyValue *recoveryKv = NULL;
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
@@ -1142,7 +1161,7 @@ testRun()
"pg1-path=/path/to/db\n"
)));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_RESTORE " command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("f"))))), "g", "check recovery option");
@@ -1163,7 +1182,7 @@ testRun()
"repo1-path=/not/the/path\n"
)));
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "info command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "info command");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoPath)), "/path/to/repo", "check repo1-path option");
}
diff --git a/test/src/module/help/helpTest.c b/test/src/module/help/helpTest.c
index 53e1e6414..23ecd1c00 100644
--- a/test/src/module/help/helpTest.c
+++ b/test/src/module/help/helpTest.c
@@ -84,13 +84,13 @@ testRun()
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAddZ(argList, "/path/to/pgbackrest");
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help from empty command line");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help from empty command line");
TEST_RESULT_STR(strPtr(helpRender()), generalHelp, " check text");
argList = strLstNew();
strLstAddZ(argList, "/path/to/pgbackrest");
strLstAddZ(argList, "help");
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help from help command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help from help command");
TEST_RESULT_STR(strPtr(helpRender()), generalHelp, " check text");
// -------------------------------------------------------------------------------------------------------------------------
@@ -107,7 +107,7 @@ testRun()
strLstAddZ(argList, "/path/to/pgbackrest");
strLstAddZ(argList, "help");
strLstAddZ(argList, "version");
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help for version command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for version command");
TEST_RESULT_STR(strPtr(helpRender()), commandHelp, " check text");
// This test is broken up into multiple strings because C99 does not require compilers to support const strings > 4095 bytes
@@ -227,7 +227,7 @@ testRun()
strLstAddZ(argList, "--link-map=/link2=/dest2");
strLstAddZ(argList, "--db-include=db1");
strLstAddZ(argList, "--db-include=db2");
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help for restore command");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for restore command");
TEST_RESULT_STR(strPtr(helpRender()), commandHelp, " check text");
// -------------------------------------------------------------------------------------------------------------------------
@@ -237,7 +237,7 @@ testRun()
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, "buffer-size");
strLstAddZ(argList, "buffer-size");
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "parse too many options");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "parse too many options");
TEST_ERROR(helpRender(), ParamInvalidError, "only one option allowed for option help");
argList = strLstNew();
@@ -245,7 +245,7 @@ testRun()
strLstAddZ(argList, "help");
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, BOGUS_STR);
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "parse bogus option");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "parse bogus option");
TEST_ERROR(helpRender(), OptionInvalidError, "option 'BOGUS' is not valid for command 'archive-push'");
// -------------------------------------------------------------------------------------------------------------------------
@@ -267,11 +267,13 @@ testRun()
strLstAddZ(argList, "help");
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, "buffer-size");
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, buffer-size option");
+ TEST_RESULT_VOID(
+ configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, buffer-size option");
TEST_RESULT_STR(strPtr(helpRender()), strPtr(strNewFmt("%s\ndefault: 4194304\n", optionHelp)), " check text");
strLstAddZ(argList, "--buffer-size=32768");
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, buffer-size option");
+ TEST_RESULT_VOID(
+ configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, buffer-size option");
TEST_RESULT_STR(
strPtr(helpRender()), strPtr(strNewFmt("%s\ncurrent: 32768\ndefault: 4194304\n", optionHelp)), " check text");
@@ -290,13 +292,13 @@ testRun()
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, "repo1-s3-host");
TEST_RESULT_VOID(
- configParse(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, repo1-s3-host option");
+ configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, repo1-s3-host option");
TEST_RESULT_STR(strPtr(helpRender()), optionHelp, " check text");
strLstAddZ(argList, "--repo1-type=s3");
strLstAddZ(argList, "--repo1-s3-host=s3-host");
TEST_RESULT_VOID(
- configParse(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, repo1-s3-host option");
+ configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, repo1-s3-host option");
TEST_RESULT_STR(
strPtr(helpRender()), strPtr(strNewFmt("%s\ncurrent: s3-host\n", optionHelp)), " check text");
@@ -321,7 +323,8 @@ testRun()
strLstAddZ(argList, "help");
strLstAddZ(argList, "backup");
strLstAddZ(argList, "repo-hardlink");
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help for backup command, repo-hardlink option");
+ TEST_RESULT_VOID(
+ configParse(strLstSize(argList), strLstPtr(argList), false), "help for backup command, repo-hardlink option");
TEST_RESULT_STR(strPtr(helpRender()), optionHelp, " check text");
}
@@ -330,7 +333,7 @@ testRun()
{
StringList *argList = strLstNew();
strLstAddZ(argList, "/path/to/pgbackrest");
- TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "parse help from empty command line");
+ TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "parse help from empty command line");
// Redirect stdout to a file
int stdoutSave = dup(STDOUT_FILENO);
diff --git a/test/src/module/perl/execTest.c b/test/src/module/perl/execTest.c
index c017c3037..8468951ff 100644
--- a/test/src/module/perl/execTest.c
+++ b/test/src/module/perl/execTest.c
@@ -45,6 +45,7 @@ testRun()
strLstAdd(argList, strNew("--stanza=db"));
strLstAdd(argList, strNew("--log-level-console=off"));
strLstAdd(argList, strNew("--log-level-stderr=off"));
+ strLstAdd(argList, strNew("--log-level-file=off"));
strLstAdd(argList, strNew("archive-push"));
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "load archive-push config");
diff --git a/test/src/module/storage/storageTest.c b/test/src/module/storage/storageTest.c
index c5ee74e59..e5a964daf 100644
--- a/test/src/module/storage/storageTest.c
+++ b/test/src/module/storage/storageTest.c
@@ -198,7 +198,7 @@ testRun()
TEST_RESULT_VOID(
storagePutNP(storageNewWriteNP(storageTest, strNew("aaa.txt")), bufNewStr(strNew("aaa"))), "write aaa.text");
TEST_RESULT_STR(
- strPtr(strLstJoin(storageListNP(storageTest, NULL), ", ")), "aaa.txt, stderr.log, stdout.log, noperm",
+ strPtr(strLstJoin(storageListNP(storageTest, NULL), ", ")), "aaa.txt, expect.log, noperm",
"dir list");
TEST_RESULT_VOID(
diff --git a/test/src/test.c b/test/src/test.c
index 8aef9e744..4fb587888 100644
--- a/test/src/test.c
+++ b/test/src/test.c
@@ -17,7 +17,7 @@ This wrapper runs the the C unit tests.
#include "common/harnessTest.h"
#ifndef NO_LOG
- #include "common/logTest.h"
+ #include "common/harnessLog.h"
#endif
#ifndef NO_MEM_CONTEXT
[parent: 1359e2908c77]