mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
19d9941367
Build pgbackrest binary and auto-generated code automatically. Remove --module option and allow modules to run by parameter. This is less verbose and multiple modules can be run at a time. Allow filtering of modules. Multiple tests can be passed as parameters and if the module ends in / it will be used as a prefix filter. For example, common/ will run all the common modules. If a test errors the remaining tests will still run but the test process will eventually exit with an error. CI tests are included but unit tests remain on the development branch. With these changes all unit tests run except those that specify the define (e.g. common/assert-off) or containerReq (e.g. protocol/protocol) keywords. Building the C test harness has been simplified: meson -Dwerror=true -Dfatal-errors=true -Dbuildtype=debug test/build/none pgbackrest ninja -C test/build/none test/src/test-pgbackrest To run all modules: test/build/none/test/src/test-pgbackrest test Just the common/error module: test/build/none/test/src/test-pgbackrest test common/error All info modules: test/build/none/test/src/test-pgbackrest test info/
108 lines
4.0 KiB
C
108 lines
4.0 KiB
C
/***********************************************************************************************************************************
|
|
Main
|
|
***********************************************************************************************************************************/
|
|
#include "build.auto.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "command/command.h"
|
|
#include "command/exit.h"
|
|
#include "command/help/help.h"
|
|
#include "command/test/test.h"
|
|
#include "common/debug.h"
|
|
#include "common/error.h"
|
|
#include "common/log.h"
|
|
#include "common/macro.h"
|
|
#include "common/memContext.h"
|
|
#include "common/stat.h"
|
|
#include "config/load.h"
|
|
#include "config/parse.h"
|
|
#include "storage/posix/storage.h"
|
|
#include "version.h"
|
|
|
|
/***********************************************************************************************************************************
|
|
Include automatically generated help data
|
|
***********************************************************************************************************************************/
|
|
#include "command/help/help.auto.c.inc"
|
|
|
|
int
|
|
main(int argListSize, const char *argList[])
|
|
{
|
|
// Set stack trace and mem context error cleanup handlers
|
|
static const ErrorHandlerFunction errorHandlerList[] = {stackTraceClean, memContextClean};
|
|
errorHandlerSet(errorHandlerList, LENGTH_OF(errorHandlerList));
|
|
|
|
FUNCTION_LOG_BEGIN(logLevelDebug);
|
|
FUNCTION_LOG_PARAM(INT, argListSize);
|
|
FUNCTION_LOG_PARAM(CHARPY, argList);
|
|
FUNCTION_LOG_END();
|
|
|
|
// Initialize command with the start time
|
|
cmdInit();
|
|
|
|
// Initialize statistics collector
|
|
statInit();
|
|
|
|
// Initialize exit handler
|
|
exitInit();
|
|
|
|
// Process commands
|
|
volatile int result = 0;
|
|
volatile bool error = false;
|
|
|
|
TRY_BEGIN()
|
|
{
|
|
// Load the configuration
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
cfgLoad((unsigned int)argListSize, argList);
|
|
|
|
// Display help
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
if (cfgCommandHelp())
|
|
{
|
|
cmdHelp(BUF(helpData, sizeof(helpData)));
|
|
}
|
|
else
|
|
{
|
|
switch (cfgCommand())
|
|
{
|
|
// Test
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
case cfgCmdTest:
|
|
{
|
|
cmdTest(
|
|
cfgOptionStr(cfgOptRepoPath), cfgOptionStr(cfgOptTestPath), cfgOptionStr(cfgOptVm),
|
|
cfgOptionUInt(cfgOptVmId), cfgCommandParam(), cfgOptionTest(cfgOptTest) ? cfgOptionUInt(cfgOptTest) : 0,
|
|
cfgOptionUInt64(cfgOptScale), logLevelEnum(cfgOptionStrId(cfgOptLogLevelTest)),
|
|
cfgOptionBool(cfgOptLogTimestamp), cfgOptionStrNull(cfgOptTz), cfgOptionBool(cfgOptRepoCopy));
|
|
|
|
break;
|
|
}
|
|
|
|
// Display version
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
case cfgCmdVersion:
|
|
printf(PROJECT_NAME " Test " PROJECT_VERSION "\n");
|
|
fflush(stdout);
|
|
break;
|
|
|
|
// Error on commands that should have already been handled
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
case cfgCmdHelp:
|
|
case cfgCmdNone:
|
|
case cfgCmdNoop:
|
|
THROW_FMT(AssertError, "'%s' command should have been handled", cfgCommandName());
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
CATCH_FATAL()
|
|
{
|
|
error = true;
|
|
result = exitSafe(result, true, 0);
|
|
}
|
|
TRY_END();
|
|
|
|
FUNCTION_LOG_RETURN(INT, error ? result : exitSafe(result, false, 0));
|
|
}
|