You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-05-22 10:15:16 +02:00
Disable log expect testing for non-unit tests.
This has never been a problem for performance tests since they do not call functions that log at info level or above, but the upcoming integration tests may do so. In any case it is better to disable this functionality outside of unit tests.
This commit is contained in:
@@ -187,7 +187,7 @@ sub run
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Create data directory
|
# Create data directory
|
||||||
if ($self->{oTest}->{&TEST_C} && !$self->{oStorageTest}->pathExists($self->{strDataPath}))
|
if ($self->{oTest}->{&TEST_TYPE} eq TESTDEF_UNIT && !$self->{oStorageTest}->pathExists($self->{strDataPath}))
|
||||||
{
|
{
|
||||||
$self->{oStorageTest}->pathCreate($self->{strDataPath}, {strMode => '0770'});
|
$self->{oStorageTest}->pathCreate($self->{strDataPath}, {strMode => '0770'});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -641,6 +641,9 @@ testBldUnit(TestBuild *const this)
|
|||||||
// Path to source -- used to construct __FILENAME__ tests
|
// Path to source -- used to construct __FILENAME__ tests
|
||||||
strReplace(testC, STRDEF("{[C_TEST_PGB_PATH]}"), strNewFmt("../%s", strZ(pathRepoRel)));
|
strReplace(testC, STRDEF("{[C_TEST_PGB_PATH]}"), strNewFmt("../%s", strZ(pathRepoRel)));
|
||||||
|
|
||||||
|
// Test expect logging
|
||||||
|
strReplace(testC, STRDEF("{[C_TEST_LOG_EXPECT]}"), module->type == testDefTypeUnit ? TRUE_STR : FALSE_STR);
|
||||||
|
|
||||||
// Test log level
|
// Test log level
|
||||||
strReplace(
|
strReplace(
|
||||||
testC, STRDEF("{[C_LOG_LEVEL_TEST]}"),
|
testC, STRDEF("{[C_LOG_LEVEL_TEST]}"),
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ static uint64_t timeMSecBegin;
|
|||||||
static const char *testExeData = NULL;
|
static const char *testExeData = NULL;
|
||||||
static const char *testProjectExeData = NULL;
|
static const char *testProjectExeData = NULL;
|
||||||
static bool testContainerData = false;
|
static bool testContainerData = false;
|
||||||
|
static bool testLogExpectData = false;
|
||||||
static unsigned int testIdxData = 0;
|
static unsigned int testIdxData = 0;
|
||||||
static bool testTiming = true;
|
static bool testTiming = true;
|
||||||
static const char *testPathData = NULL;
|
static const char *testPathData = NULL;
|
||||||
@@ -66,8 +67,8 @@ Initialize harness
|
|||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
void
|
void
|
||||||
hrnInit(
|
hrnInit(
|
||||||
const char *testExe, const char *testProjectExe, bool testContainer, unsigned int testIdx, bool timing, const char *testPath,
|
const char *testExe, const char *testProjectExe, bool testContainer, bool testLogExpect, unsigned int testIdx, bool timing,
|
||||||
const char *testDataPath, const char *testRepoPath)
|
const char *testPath, const char *testDataPath, const char *testRepoPath)
|
||||||
{
|
{
|
||||||
FUNCTION_HARNESS_VOID();
|
FUNCTION_HARNESS_VOID();
|
||||||
|
|
||||||
@@ -75,6 +76,8 @@ hrnInit(
|
|||||||
testExeData = testExe;
|
testExeData = testExe;
|
||||||
testProjectExeData = testProjectExe;
|
testProjectExeData = testProjectExe;
|
||||||
testContainerData = testContainer;
|
testContainerData = testContainer;
|
||||||
|
testLogExpectData = testLogExpect;
|
||||||
|
(void)testLogExpectData;
|
||||||
testIdxData = testIdx;
|
testIdxData = testIdx;
|
||||||
testTiming = timing;
|
testTiming = timing;
|
||||||
testPathData = testPath;
|
testPathData = testPath;
|
||||||
@@ -129,7 +132,8 @@ testBegin(const char *name)
|
|||||||
if (!testFirst)
|
if (!testFirst)
|
||||||
{
|
{
|
||||||
// Make sure there is nothing untested left in the log
|
// Make sure there is nothing untested left in the log
|
||||||
harnessLogFinal();
|
if (testLogExpectData)
|
||||||
|
harnessLogFinal();
|
||||||
|
|
||||||
// It is possible the test left the cwd in a weird place
|
// It is possible the test left the cwd in a weird place
|
||||||
if (chdir(testPath()) != 0)
|
if (chdir(testPath()) != 0)
|
||||||
@@ -165,7 +169,8 @@ testBegin(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear any log replacements
|
// Clear any log replacements
|
||||||
hrnLogReplaceClear();
|
if (testLogExpectData)
|
||||||
|
hrnLogReplaceClear();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// No longer the first test
|
// No longer the first test
|
||||||
@@ -182,7 +187,8 @@ testBegin(const char *name)
|
|||||||
|
|
||||||
#ifdef HRN_FEATURE_LOG
|
#ifdef HRN_FEATURE_LOG
|
||||||
// Initialize logging
|
// Initialize logging
|
||||||
harnessLogInit();
|
if (testLogExpectData)
|
||||||
|
harnessLogInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
@@ -203,7 +209,8 @@ hrnComplete(void)
|
|||||||
|
|
||||||
#ifdef HRN_FEATURE_LOG
|
#ifdef HRN_FEATURE_LOG
|
||||||
// Make sure there is nothing untested left in the log
|
// Make sure there is nothing untested left in the log
|
||||||
harnessLogFinal();
|
if (testLogExpectData)
|
||||||
|
harnessLogFinal();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check that all tests ran
|
// Check that all tests ran
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ const char *testProjectExe(void);
|
|||||||
Functions
|
Functions
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
void hrnInit(
|
void hrnInit(
|
||||||
const char *testExe, const char *testProjectExe, bool testContainer, unsigned int testIdx, bool timing, const char *testPath,
|
const char *testExe, const char *testProjectExe, bool testContainer, bool testLogExpect, unsigned int testIdx, bool timing,
|
||||||
const char *testDataPath, const char *testRepoPath);
|
const char *testPath, const char *testDataPath, const char *testRepoPath);
|
||||||
void hrnAdd(int run, bool selected);
|
void hrnAdd(int run, bool selected);
|
||||||
void hrnComplete(void);
|
void hrnComplete(void);
|
||||||
|
|
||||||
|
|||||||
@@ -348,6 +348,7 @@ testRun(void)
|
|||||||
String *const testCDup = strCat(strNew(), testC);
|
String *const testCDup = strCat(strNew(), testC);
|
||||||
|
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("false"));
|
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("false"));
|
||||||
|
strReplace(testCDup, STRDEF("{[C_TEST_LOG_EXPECT]}"), STRDEF("true"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("#define DEBUG_TEST_TRACE"));
|
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("#define DEBUG_TEST_TRACE"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/none/build"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/none/build"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("false"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("false"));
|
||||||
@@ -464,6 +465,7 @@ testRun(void)
|
|||||||
String *const testCDup = strCat(strNew(), testC);
|
String *const testCDup = strCat(strNew(), testC);
|
||||||
|
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("false"));
|
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("false"));
|
||||||
|
strReplace(testCDup, STRDEF("{[C_TEST_LOG_EXPECT]}"), STRDEF("true"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("#define DEBUG_TEST_TRACE"));
|
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("#define DEBUG_TEST_TRACE"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/none/build"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/none/build"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("false"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("false"));
|
||||||
@@ -691,6 +693,7 @@ testRun(void)
|
|||||||
String *const testCDup = strCat(strNew(), testC);
|
String *const testCDup = strCat(strNew(), testC);
|
||||||
|
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("true"));
|
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("true"));
|
||||||
|
strReplace(testCDup, STRDEF("{[C_TEST_LOG_EXPECT]}"), STRDEF("true"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("// Debug test trace not enabled"));
|
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("// Debug test trace not enabled"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/uXX/build"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/uXX/build"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("true"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("true"));
|
||||||
@@ -864,6 +867,7 @@ testRun(void)
|
|||||||
String *const testCDup = strCat(strNew(), testC);
|
String *const testCDup = strCat(strNew(), testC);
|
||||||
|
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("true"));
|
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("true"));
|
||||||
|
strReplace(testCDup, STRDEF("{[C_TEST_LOG_EXPECT]}"), STRDEF("false"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("// Debug test trace not enabled"));
|
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("// Debug test trace not enabled"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/uXX/build"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/uXX/build"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("true"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("true"));
|
||||||
@@ -903,6 +907,7 @@ testRun(void)
|
|||||||
String *const testCDup = strCat(strNew(), testC);
|
String *const testCDup = strCat(strNew(), testC);
|
||||||
|
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("true"));
|
strReplace(testCDup, STRDEF("{[C_TEST_CONTAINER]}"), STRDEF("true"));
|
||||||
|
strReplace(testCDup, STRDEF("{[C_TEST_LOG_EXPECT]}"), STRDEF("false"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("// Debug test trace not enabled"));
|
strReplace(testCDup, STRDEF("{[C_TEST_DEBUG_TEST_TRACE]}"), STRDEF("// Debug test trace not enabled"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/uXX/build"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/uXX/build"));
|
||||||
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("false"));
|
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("false"));
|
||||||
|
|||||||
@@ -104,6 +104,9 @@ STRING_EXTERN(TEST_GROUP_STR, TEST_GROUP);
|
|||||||
#include "common/harnessDebug.h"
|
#include "common/harnessDebug.h"
|
||||||
#include "common/harnessTest.intern.h"
|
#include "common/harnessTest.intern.h"
|
||||||
|
|
||||||
|
// Is log expect testing enabled?
|
||||||
|
#define TEST_LOG_EXPECT {[C_TEST_LOG_EXPECT]}
|
||||||
|
|
||||||
#ifdef HRN_FEATURE_LOG
|
#ifdef HRN_FEATURE_LOG
|
||||||
#include "common/harnessLog.h"
|
#include "common/harnessLog.h"
|
||||||
void harnessLogLevelDefaultSet(LogLevel logLevel);
|
void harnessLogLevelDefaultSet(LogLevel logLevel);
|
||||||
@@ -196,6 +199,7 @@ main(int argListSize, const char *argList[])
|
|||||||
argList[0], // Test exe
|
argList[0], // Test exe
|
||||||
TEST_PROJECT_EXE, // Project exe
|
TEST_PROJECT_EXE, // Project exe
|
||||||
TEST_IN_CONTAINER, // Is this test running in a container?
|
TEST_IN_CONTAINER, // Is this test running in a container?
|
||||||
|
TEST_LOG_EXPECT, // Is log expect testing enabled?
|
||||||
{[C_TEST_IDX]}, // The 0-based index of this test
|
{[C_TEST_IDX]}, // The 0-based index of this test
|
||||||
{[C_TEST_TIMING]}, // Is timing enabled (may be disabled for reproducible documentation)
|
{[C_TEST_TIMING]}, // Is timing enabled (may be disabled for reproducible documentation)
|
||||||
TEST_PATH, // Path where tests write data
|
TEST_PATH, // Path where tests write data
|
||||||
|
|||||||
Reference in New Issue
Block a user