1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Parameterize configLoad() as cfgLoadP().

There is one existing optional parameter and there are more to come.
This commit is contained in:
David Steele 2023-04-11 16:28:29 +04:00
parent d6cb3de17a
commit 75254c9285
8 changed files with 129 additions and 101 deletions

View File

@ -13,7 +13,7 @@ The general-purpose functions for querying the current configuration are found i
#include "config/parse.h"
/***********************************************************************************************************************************
Configuration data. These structures are not directly user-created or accessible. configParse() creates the structures and uses
Configuration data. These structures are not directly user-created or accessible. cfgParseP() creates the structures and uses
cfgInit() to load it as the current configuration. Various cfg*() functions provide access.
***********************************************************************************************************************************/
// Group options that are related to allow valid and test checks across all options in the group

View File

@ -449,7 +449,7 @@ cfgLoad(unsigned int argListSize, const char *argList[])
MEM_CONTEXT_TEMP_BEGIN()
{
// Parse config from command line and config file
configParse(storageLocal(), argListSize, argList, true);
cfgParseP(storageLocal(), argListSize, argList);
// Initialize dry-run mode for storage when valid for the current command
storageHelperDryRunInit(cfgOptionValid(cfgOptDryRun) && cfgOptionBool(cfgOptDryRun));

View File

@ -1421,13 +1421,13 @@ cfgFileLoad(
logic to this critical path code.
***********************************************************************************************************************************/
FN_EXTERN void
configParse(const Storage *storage, unsigned int argListSize, const char *argList[], bool resetLogLevel)
cfgParse(const Storage *const storage, const unsigned int argListSize, const char *argList[], const CfgParseParam param)
{
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(STORAGE, storage);
FUNCTION_LOG_PARAM(UINT, argListSize);
FUNCTION_LOG_PARAM(CHARPY, argList);
FUNCTION_LOG_PARAM(BOOL, resetLogLevel);
FUNCTION_LOG_PARAM(BOOL, param.noResetLogLevel);
FUNCTION_LOG_END();
MEM_CONTEXT_TEMP_BEGIN()
@ -1689,7 +1689,7 @@ configParse(const Storage *storage, unsigned int argListSize, const char *argLis
THROW(ParamInvalidError, "command does not allow parameters");
// Enable logging for main role so config file warnings will be output
if (resetLogLevel && config->commandRole == cfgCmdRoleMain)
if (!param.noResetLogLevel && config->commandRole == cfgCmdRoleMain)
logInit(logLevelWarn, logLevelWarn, logLevelOff, false, 0, 1, false);
// Only continue if command options need to be validated, i.e. a real command is running or we are getting help for a

View File

@ -40,7 +40,16 @@ typedef enum
Functions
***********************************************************************************************************************************/
// Parse the command-line arguments and config file to produce final config data
FN_EXTERN void configParse(const Storage *storage, unsigned int argListSize, const char *argList[], bool resetLogLevel);
typedef struct CfgParseParam
{
VAR_PARAM_HEADER;
bool noResetLogLevel; // Do not reset log level
} CfgParseParam;
#define cfgParseP(storage, argListSize, argList, ...) \
cfgParse(storage, argListSize, argList, (CfgParseParam){VAR_PARAM_INIT, __VA_ARGS__})
FN_EXTERN void cfgParse(const Storage *storage, unsigned int argListSize, const char *argList[], CfgParseParam param);
// Get command name by id
FN_EXTERN const char *cfgParseCommandName(ConfigCommand commandId);

View File

@ -82,7 +82,7 @@ hrnCfgLoad(ConfigCommand commandId, const StringList *argListParam, const HrnCfg
hrnStorageHelperFree();
// Parse config
configParse(storageLocal(), strLstSize(argList), strLstPtr(argList), false);
cfgParseP(storageLocal(), strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true);
// Set dry-run mode for storage and logging
harnessLogDryRunSet(cfgOptionValid(cfgOptDryRun) && cfgOptionBool(cfgOptDryRun));

View File

@ -88,12 +88,12 @@ cfgLoad(unsigned int argListSize, const char *argList[])
// Parse config from command line
TRY_BEGIN()
{
configParse(storagePosixNewP(FSLASH_STR), strLstSize(argListNew), strLstPtr(argListNew), true);
cfgParseP(storagePosixNewP(FSLASH_STR), strLstSize(argListNew), strLstPtr(argListNew));
}
CATCH(CommandRequiredError)
{
strLstAddZ(argListNew, CFGCMD_TEST);
configParse(storagePosixNewP(FSLASH_STR), strLstSize(argListNew), strLstPtr(argListNew), true);
cfgParseP(storagePosixNewP(FSLASH_STR), strLstSize(argListNew), strLstPtr(argListNew));
}
TRY_END();

View File

@ -21,7 +21,7 @@ testCfgLoad(const StringList *const argList)
FUNCTION_HARNESS_END();
// Parse config
configParse(storageLocal(), strLstSize(argList), strLstPtr(argList), false);
cfgParseP(storageLocal(), strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true);
// Apply special option rules
cfgLoadUpdateOption();

View File

@ -156,7 +156,7 @@ testRun(void)
"recovery-option=c=d\n"));
TEST_RESULT_VOID(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false),
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true),
TEST_COMMAND_BACKUP " command with config-include");
TEST_RESULT_LOG(
"P00 WARN: configuration file contains option 'recovery-option' invalid for section 'db:backup'\n"
@ -602,7 +602,7 @@ testRun(void)
}
// *****************************************************************************************************************************
if (testBegin("configParse()"))
if (testBegin("cfgParseP()"))
{
StringList *argList = NULL;
const String *configFile = STRDEF(TEST_PATH "/test.config");
@ -621,7 +621,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "-bogus");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option '-bogus' must begin with --");
// -------------------------------------------------------------------------------------------------------------------------
@ -631,7 +631,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
hrnCfgArgRawZ(argList, cfgOptOnline, "bogus");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"boolean option '--online' argument must be 'y' or 'n'");
// -------------------------------------------------------------------------------------------------------------------------
@ -642,7 +642,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptNeutralUmask, "n");
strLstAddZ(argList, CFGCMD_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionRequiredError,
"backup command requires option: stanza");
// -------------------------------------------------------------------------------------------------------------------------
@ -653,7 +653,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptNeutralUmask, "y");
strLstAddZ(argList, CFGCMD_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionRequiredError,
"backup command requires option: stanza");
// -------------------------------------------------------------------------------------------------------------------------
@ -664,7 +664,7 @@ testRun(void)
strLstAddZ(argList, "--no-neutral-umask=n");
strLstAddZ(argList, CFGCMD_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'no-neutral-umask' does not allow an argument");
// -------------------------------------------------------------------------------------------------------------------------
@ -675,7 +675,7 @@ testRun(void)
strLstAddZ(argList, "--no-online=y");
strLstAddZ(argList, CFGCMD_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'no-online' does not allow an argument");
// -------------------------------------------------------------------------------------------------------------------------
@ -686,7 +686,7 @@ testRun(void)
strLstAddZ(argList, "--reset-pg1-host=xxx");
strLstAddZ(argList, CFGCMD_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'reset-pg1-host' does not allow an argument");
// -------------------------------------------------------------------------------------------------------------------------
@ -696,7 +696,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, BOGUS_STR);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), CommandInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), CommandInvalidError,
"invalid command 'BOGUS'");
// -------------------------------------------------------------------------------------------------------------------------
@ -707,7 +707,7 @@ testRun(void)
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_ASYNC);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), CommandInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), CommandInvalidError,
"invalid command/role combination 'backup:async'");
// -------------------------------------------------------------------------------------------------------------------------
@ -717,7 +717,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, BOGUS_STR ":" BOGUS_STR);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), CommandInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), CommandInvalidError,
"invalid command 'BOGUS:BOGUS'");
// -------------------------------------------------------------------------------------------------------------------------
@ -727,7 +727,8 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--c");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError, "invalid option '--c'");
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"invalid option '--c'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error on ambiguous deprecated partial option");
@ -736,7 +737,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--retention");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"invalid option '--retention'");
// -------------------------------------------------------------------------------------------------------------------------
@ -746,14 +747,14 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, " --config=/path/to");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), CommandInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), CommandInvalidError,
"invalid command ' --config=/path/to'");
argList = strLstNew();
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--config =/path/to");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"invalid option '--config =/path/to'");
// -------------------------------------------------------------------------------------------------------------------------
@ -763,7 +764,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--" BOGUS_STR);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"invalid option '--BOGUS'");
// -------------------------------------------------------------------------------------------------------------------------
@ -780,7 +781,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddFmt(argList, "--%s", optionMax);
TEST_ERROR_FMT(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option '%s' exceeds maximum size of 64", optionMax);
// -------------------------------------------------------------------------------------------------------------------------
@ -790,14 +791,14 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--no-force");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'no-force' cannot be negated");
argList = strLstNew();
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--reset-force");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'reset-force' cannot be reset");
// -------------------------------------------------------------------------------------------------------------------------
@ -807,7 +808,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--pg257-path");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'pg257-path' key exceeds maximum of 256");
// -------------------------------------------------------------------------------------------------------------------------
@ -817,7 +818,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--257-path");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option '257-path' cannot begin with a number");
// -------------------------------------------------------------------------------------------------------------------------
@ -827,7 +828,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "---pg1-path");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option '-pg1-path' cannot begin with a dash");
// -------------------------------------------------------------------------------------------------------------------------
@ -837,14 +838,14 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--compress77-type");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'compress77-type' cannot have an index");
argList = strLstNew();
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--retention128-full");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"deprecated option 'retention128-full' cannot have an index");
// -------------------------------------------------------------------------------------------------------------------------
@ -854,7 +855,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--repo-storage-ca-file");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'repo-storage-ca-file' requires an index\n"
"HINT: add the required index, e.g. repo1-storage-ca-file.");
@ -862,7 +863,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--repo-azure-ca-path");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"deprecated option 'repo-azure-ca-path' requires an index\n"
"HINT: add the required index, e.g. repo1-azure-ca-path.\n"
"HINT: consider using the non-deprecated name, e.g. repo1-storage-ca-path.");
@ -879,7 +880,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "--pg1-host");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option '--pg1-host' requires an argument");
// -------------------------------------------------------------------------------------------------------------------------
@ -890,7 +891,7 @@ testRun(void)
strLstAddZ(argList, "backup");
strLstAddZ(argList, "param1");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), ParamInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), ParamInvalidError,
"command does not allow parameters");
// -------------------------------------------------------------------------------------------------------------------------
@ -902,7 +903,8 @@ testRun(void)
strLstAddZ(argList, "backup");
strLstAddZ(argList, "param1");
TEST_RESULT_VOID(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "ignore params when help command");
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true),
"ignore params when help command");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("duplicate negation");
@ -912,7 +914,7 @@ testRun(void)
hrnCfgArgRawNegate(argList, cfgOptOnline);
hrnCfgArgRawNegate(argList, cfgOptOnline);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'online' is negated multiple times");
// -------------------------------------------------------------------------------------------------------------------------
@ -923,7 +925,7 @@ testRun(void)
hrnCfgArgKeyRawReset(argList, cfgOptPgHost, 1);
hrnCfgArgKeyRawReset(argList, cfgOptPgHost, 1);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'pg1-host' is reset multiple times");
// -------------------------------------------------------------------------------------------------------------------------
@ -934,7 +936,7 @@ testRun(void)
hrnCfgArgRawNegate(argList, cfgOptConfig);
hrnCfgArgRawZ(argList, cfgOptConfig, "/etc/config");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'config' cannot be set and negated");
// -------------------------------------------------------------------------------------------------------------------------
@ -945,7 +947,7 @@ testRun(void)
hrnCfgArgRawReset(argList, cfgOptLogPath);
hrnCfgArgRawZ(argList, cfgOptLogPath, "/var/log");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'log-path' cannot be set and reset");
// -------------------------------------------------------------------------------------------------------------------------
@ -956,7 +958,7 @@ testRun(void)
hrnCfgArgRawNegate(argList, cfgOptDelta);
hrnCfgArgRawReset(argList, cfgOptDelta);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'delta' cannot be negated and reset");
// reverse the option order
@ -965,7 +967,7 @@ testRun(void)
hrnCfgArgRawReset(argList, cfgOptDelta);
hrnCfgArgRawNegate(argList, cfgOptDelta);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'delta' cannot be negated and reset");
// -------------------------------------------------------------------------------------------------------------------------
@ -976,7 +978,7 @@ testRun(void)
hrnCfgArgRawBool(argList, cfgOptDelta, true);
hrnCfgArgRawBool(argList, cfgOptDelta, true);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'delta' cannot be set multiple times");
argList = strLstNew();
@ -986,7 +988,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptCompressLevel, "3");
hrnCfgArgRawZ(argList, cfgOptCompressLevel, "3");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'compress-level' cannot be set multiple times");
// -------------------------------------------------------------------------------------------------------------------------
@ -996,7 +998,8 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
hrnCfgArgRawBool(argList, cfgOptOnline, true);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), CommandRequiredError, "no command found");
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), CommandRequiredError,
"no command found");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("invalid values");
@ -1007,7 +1010,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
hrnCfgArgRawZ(argList, cfgOptManifestSaveThreshold, "123Q");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'123Q' is not valid for 'manifest-save-threshold' option");
argList = strLstNew();
@ -1016,7 +1019,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
hrnCfgArgRawZ(argList, cfgOptManifestSaveThreshold, "999999999999999999p");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'999999999999999999p' is not valid for 'manifest-save-threshold' option");
argList = strLstNew();
@ -1025,7 +1028,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
hrnCfgArgRawZ(argList, cfgOptManifestSaveThreshold, "999t");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'999t' is out of range for 'manifest-save-threshold' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1037,7 +1040,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, "");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'' must be >= 1 character for 'pg1-path' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1049,7 +1052,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, "bogus");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'bogus' must begin with / for 'pg1-path' option");
argList = strLstNew();
@ -1058,7 +1061,7 @@ testRun(void)
strLstAddZ(argList, "--stanz=db"); // Partial option to test matching
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, "/path1//path2");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'/path1//path2' cannot contain // for 'pg1-path' option");
argList = strLstNew();
@ -1067,7 +1070,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, "/path1/path2//");
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'/path1/path2//' cannot contain // for 'pg1-path' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1086,7 +1089,7 @@ testRun(void)
hrnLogLevelStdOutSet(logLevelError);
hrnLogLevelStdErrSet(logLevelError);
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), true), "load local config");
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList)), "load local config");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/2", "default pg-path");
TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleLocal, "command role is local");
TEST_RESULT_BOOL(cfgLockRequired(), false, "backup:local command does not require lock");
@ -1105,7 +1108,7 @@ testRun(void)
hrnLogLevelStdOutSet(logLevelError);
hrnLogLevelStdErrSet(logLevelError);
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), true), "load remote config");
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList)), "load remote config");
TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleRemote, "command role is remote");
TEST_RESULT_STR_Z(cfgParseCommandRoleStr(cfgCmdRoleRemote), "remote", "remote role name");
TEST_RESULT_INT(hrnLogLevelStdOut(), logLevelError, "console logging is error");
@ -1120,7 +1123,7 @@ testRun(void)
hrnLogLevelStdOutSet(logLevelError);
hrnLogLevelStdErrSet(logLevelError);
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), true), "load async config");
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList)), "load async config");
TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleAsync, "command role is async");
TEST_RESULT_INT(hrnLogLevelStdOut(), logLevelError, "console logging is error");
TEST_RESULT_INT(hrnLogLevelStdErr(), logLevelError, "stderr logging is error");
@ -1135,14 +1138,14 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
strLstAddZ(argList, TEST_COMMAND_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionRequiredError,
"backup command requires option: pg1-path\nHINT: does this stanza exist?");
argList = strLstNew();
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, TEST_COMMAND_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionRequiredError,
"backup command requires option: stanza");
// -------------------------------------------------------------------------------------------------------------------------
@ -1158,7 +1161,7 @@ testRun(void)
hrnCfgArgKeyRawZ(argList, cfgOptRepoS3Endpoint, 1, "xxx");
strLstAddZ(argList, TEST_COMMAND_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), 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 a configuration file or an environment variable instead.");
@ -1205,7 +1208,7 @@ testRun(void)
hrnCfgArgKeyRawZ(argList, cfgOptRepoS3Bucket, 1, "xxx");
strLstAddZ(argList, TEST_COMMAND_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'repo1-s3-bucket' not valid without option 'repo1-type' = 's3'");
argList = strLstNew();
@ -1215,7 +1218,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'repo1-host-user' not valid without option 'repo1-host'");
argList = strLstNew();
@ -1225,7 +1228,7 @@ testRun(void)
hrnCfgArgRawBool(argList, cfgOptForce, true);
strLstAddZ(argList, TEST_COMMAND_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'force' not valid without option 'no-online'");
argList = strLstNew();
@ -1235,7 +1238,7 @@ testRun(void)
hrnCfgArgRawBool(argList, cfgOptRepoBlock, true);
strLstAddZ(argList, TEST_COMMAND_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'repo1-block' not valid without option 'repo1-bundle'");
argList = strLstNew();
@ -1245,7 +1248,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptSpoolPath, "/path/to/spool");
strLstAddZ(argList, TEST_COMMAND_ARCHIVE_GET);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'spool-path' not valid without option 'archive-async'");
argList = strLstNew();
@ -1255,7 +1258,7 @@ testRun(void)
hrnCfgArgRawBool(argList, cfgOptTargetExclusive, true);
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'target-exclusive' not valid without option 'type' in ('lsn', 'time', 'xid')");
// -------------------------------------------------------------------------------------------------------------------------
@ -1268,7 +1271,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptRecoveryOption, "a=b");
strLstAddZ(argList, TEST_COMMAND_BACKUP);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'recovery-option' not valid for command 'backup'");
// -------------------------------------------------------------------------------------------------------------------------
@ -1281,7 +1284,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptType, "^bogus");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'^bogus' is not allowed for 'type' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1294,7 +1297,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptBufferSize, "777");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'777' is not allowed for 'buffer-size' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1307,7 +1310,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptType, "bogus");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'bogus' is not allowed for 'type' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1320,7 +1323,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptProcessMax, "0");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'0' is out of range for 'process-max' option");
argList = strLstNew();
@ -1330,7 +1333,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptProcessMax, "65536");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'65536' is out of range for 'process-max' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1343,7 +1346,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptProcessMax, "bogus");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'bogus' is not valid for 'process-max' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1356,7 +1359,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptProtocolTimeout, ".01");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'.01' is out of range for 'protocol-timeout' option");
argList = strLstNew();
@ -1366,7 +1369,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptProtocolTimeout, "bogus");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"'bogus' is not valid for 'protocol-timeout' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1379,7 +1382,7 @@ testRun(void)
hrnCfgEnvRawZ(cfgOptProtocolTimeout, "");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"environment variable 'protocol-timeout' must have a value");
hrnCfgEnvRemoveRaw(cfgOptProtocolTimeout);
@ -1391,7 +1394,7 @@ testRun(void)
hrnCfgEnvRawZ(cfgOptDelta, "x");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"environment boolean option 'delta' must be 'y' or 'n'");
hrnCfgEnvRemoveRaw(cfgOptDelta);
@ -1412,7 +1415,7 @@ testRun(void)
"delta=bogus\n"));
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"boolean option 'delta' must be 'y' or 'n'");
argList = strLstNew();
@ -1428,7 +1431,7 @@ testRun(void)
"delta=\n"));
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidValueError,
"section 'global', key 'delta' must have a value");
// -------------------------------------------------------------------------------------------------------------------------
@ -1448,7 +1451,7 @@ testRun(void)
"db-path=/also/path/to/db\n"));
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"configuration file contains duplicate options ('db-path', 'pg1-path') in section '[db]'");
// -------------------------------------------------------------------------------------------------------------------------
@ -1468,7 +1471,7 @@ testRun(void)
"pg1-path=/also/path/to/db\n"));
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'pg1-path' cannot be set multiple times");
// Also test with a boolean option since this gets converted immediately and will blow up if it is multi
@ -1480,7 +1483,7 @@ testRun(void)
"start-fast=n\n"));
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"option 'start-fast' cannot be set multiple times");
// -------------------------------------------------------------------------------------------------------------------------
@ -1491,7 +1494,7 @@ testRun(void)
hrnLogLevelStdOutSet(logLevelOff);
hrnLogLevelStdErrSet(logLevelOff);
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), true), "no command");
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList)), "no command");
TEST_RESULT_BOOL(cfgCommandHelp(), true, "help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdNone, "command is none");
TEST_RESULT_INT(hrnLogLevelStdOut(), logLevelWarn, "console logging is warn");
@ -1505,7 +1508,7 @@ testRun(void)
strLstAddZ(argList, TEST_BACKREST_EXE);
strLstAddZ(argList, "help");
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "help command");
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "help command");
TEST_RESULT_BOOL(cfgCommandHelp(), true, "help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdHelp, "command is help");
TEST_RESULT_Z(cfgCommandName(), "help", "command name is help");
@ -1515,7 +1518,8 @@ testRun(void)
strLstAddZ(argList, "help");
strLstAddZ(argList, "version");
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "help for version command");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "help for version command");
TEST_RESULT_BOOL(cfgCommandHelp(), true, "help is set");
TEST_RESULT_INT(cfgCommand(), cfgCmdVersion, "command is version");
@ -1527,7 +1531,8 @@ testRun(void)
strLstAddZ(argList, "help");
strLstAddZ(argList, "backup");
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "help for backup command");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "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");
@ -1543,7 +1548,8 @@ testRun(void)
strLstAddZ(argList, TEST_COMMAND_ARCHIVE_GET);
strLstAddZ(argList, "000000010000000200000003");
strLstAddZ(argList, "/path/to/wal/RECOVERYWAL");
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "command arguments");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "command arguments");
TEST_RESULT_STRLST_Z(
cfgCommandParam(), "000000010000000200000003\n/path/to/wal/RECOVERYWAL\n", "check command arguments");
@ -1564,7 +1570,9 @@ testRun(void)
strLstAddZ(argList, TEST_COMMAND_BACKUP);
hrnCfgEnvKeyRawZ(cfgOptRepoS3Key, 1, "xxx");
hrnCfgEnvKeyRawZ(cfgOptRepoS3KeySecret, 1, "xxx");
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true),
TEST_COMMAND_BACKUP " command");
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, "command is " TEST_COMMAND_BACKUP);
TEST_RESULT_BOOL(cfgLockRequired(), true, "backup command requires lock");
TEST_RESULT_UINT(cfgLockType(), lockTypeBackup, "backup command requires backup lock type");
@ -1616,7 +1624,7 @@ testRun(void)
hrnCfgArgRaw(argList, cfgOptConfig, configFile);
strLstAddZ(argList, TEST_COMMAND_BACKUP);
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "parse config");
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "parse config");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/global/stanza", "default pg-path");
@ -1686,7 +1694,9 @@ testRun(void)
"recovery-option=c=d\n",
cfgParseOptionKeyIdxName(cfgOptPgHost, 1), cfgParseOptionKeyIdxName(cfgOptPgPath, 1))));
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true),
TEST_COMMAND_BACKUP " command");
TEST_RESULT_LOG(
"P00 WARN: environment contains invalid option 'bogus'\n"
"P00 WARN: environment contains invalid option 'onlin'\n"
@ -1819,7 +1829,8 @@ testRun(void)
"[global]\n"
"spool-path=/path/to/spool\n"));
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "archive-push command");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "archive-push command");
TEST_RESULT_STR_Z(jsonFromVar(varNewVarLst(cfgCommandJobRetry())), "[0]", "default job retry");
TEST_RESULT_BOOL(cfgLockRequired(), true, "archive-push:async command requires lock");
@ -1843,7 +1854,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_ERROR(
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), OptionInvalidError,
"key/value 'a' not valid for 'recovery-option' option");
// -------------------------------------------------------------------------------------------------------------------------
@ -1854,7 +1865,7 @@ testRun(void)
strLstAddZ(argList, TEST_COMMAND_BACKUP);
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, "/path/to/1");
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), true), "load local config");
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList)), "load local config");
TEST_RESULT_STR_Z(cfgExe(), "pgbackrest", "--cmd not provided; cfgExe() returns " TEST_BACKREST_EXE);
@ -1871,7 +1882,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, "/path/to/1");
hrnCfgArgRawZ(argList, cfgOptCmd, "pgbackrest_wrapper.sh");
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), true), "load local config");
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList)), "load local config");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptCmd), "pgbackrest_wrapper.sh", "--cmd provided; cmd is returned as pgbackrest_wrapper.sh");
@ -1885,7 +1896,9 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptDbInclude, "def");
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true),
TEST_COMMAND_RESTORE " command");
TEST_RESULT_STR_Z(jsonFromVar(varNewVarLst(cfgCommandJobRetry())), "[0,15000]", "default job retry");
@ -1905,7 +1918,9 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptStanza, "db");
hrnCfgArgRawZ(argList, cfgOptJobRetry, "0");
strLstAddZ(argList, TEST_COMMAND_RESTORE);
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true),
TEST_COMMAND_RESTORE " command");
TEST_RESULT_PTR(cfgCommandJobRetry(), NULL, "no job retries");
@ -1937,7 +1952,9 @@ testRun(void)
"[db]\n"
"pg1-path=/path/to/db\n"));
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true),
TEST_COMMAND_RESTORE " command");
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, VARSTRDEF("f"))), "g", "check recovery option");
@ -1956,7 +1973,9 @@ testRun(void)
hrnCfgEnvRawZ(cfgOptRecoveryOption, "f=g:hijk=l");
hrnCfgEnvRawZ(cfgOptDbInclude, "77");
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
TEST_RESULT_VOID(
cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true),
TEST_COMMAND_RESTORE " command");
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, VARSTRDEF("f"))), "g", "check recovery option");
@ -2018,7 +2037,7 @@ testRun(void)
"[db]\n"
"repo1-path=/not/the/path\n"));
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "info command");
TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "info command");
TEST_RESULT_BOOL(cfgLogFile(), false, "info command does not do file logging");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoPath), "/path/to/repo", "check repo1-path option");