1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-18 04:58:51 +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:
David Steele 2024-02-17 19:16:39 +13:00
parent d41b21c8f7
commit 6356a2b76c
6 changed files with 28 additions and 9 deletions

View File

@ -187,7 +187,7 @@ sub run
}
# 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'});
}

View File

@ -641,6 +641,9 @@ testBldUnit(TestBuild *const this)
// Path to source -- used to construct __FILENAME__ tests
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
strReplace(
testC, STRDEF("{[C_LOG_LEVEL_TEST]}"),

View File

@ -33,6 +33,7 @@ static uint64_t timeMSecBegin;
static const char *testExeData = NULL;
static const char *testProjectExeData = NULL;
static bool testContainerData = false;
static bool testLogExpectData = false;
static unsigned int testIdxData = 0;
static bool testTiming = true;
static const char *testPathData = NULL;
@ -66,8 +67,8 @@ Initialize harness
***********************************************************************************************************************************/
void
hrnInit(
const char *testExe, const char *testProjectExe, bool testContainer, unsigned int testIdx, bool timing, const char *testPath,
const char *testDataPath, const char *testRepoPath)
const char *testExe, const char *testProjectExe, bool testContainer, bool testLogExpect, unsigned int testIdx, bool timing,
const char *testPath, const char *testDataPath, const char *testRepoPath)
{
FUNCTION_HARNESS_VOID();
@ -75,6 +76,8 @@ hrnInit(
testExeData = testExe;
testProjectExeData = testProjectExe;
testContainerData = testContainer;
testLogExpectData = testLogExpect;
(void)testLogExpectData;
testIdxData = testIdx;
testTiming = timing;
testPathData = testPath;
@ -129,7 +132,8 @@ testBegin(const char *name)
if (!testFirst)
{
// 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
if (chdir(testPath()) != 0)
@ -165,7 +169,8 @@ testBegin(const char *name)
}
// Clear any log replacements
hrnLogReplaceClear();
if (testLogExpectData)
hrnLogReplaceClear();
}
#endif
// No longer the first test
@ -182,7 +187,8 @@ testBegin(const char *name)
#ifdef HRN_FEATURE_LOG
// Initialize logging
harnessLogInit();
if (testLogExpectData)
harnessLogInit();
#endif
result = true;
@ -203,7 +209,8 @@ hrnComplete(void)
#ifdef HRN_FEATURE_LOG
// Make sure there is nothing untested left in the log
harnessLogFinal();
if (testLogExpectData)
harnessLogFinal();
#endif
// Check that all tests ran

View File

@ -40,8 +40,8 @@ const char *testProjectExe(void);
Functions
***********************************************************************************************************************************/
void hrnInit(
const char *testExe, const char *testProjectExe, bool testContainer, unsigned int testIdx, bool timing, const char *testPath,
const char *testDataPath, const char *testRepoPath);
const char *testExe, const char *testProjectExe, bool testContainer, bool testLogExpect, unsigned int testIdx, bool timing,
const char *testPath, const char *testDataPath, const char *testRepoPath);
void hrnAdd(int run, bool selected);
void hrnComplete(void);

View File

@ -348,6 +348,7 @@ testRun(void)
String *const testCDup = strCat(strNew(), testC);
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_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/none/build"));
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("false"));
@ -464,6 +465,7 @@ testRun(void)
String *const testCDup = strCat(strNew(), testC);
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_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/none/build"));
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("false"));
@ -691,6 +693,7 @@ testRun(void)
String *const testCDup = strCat(strNew(), testC);
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_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/uXX/build"));
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("true"));
@ -864,6 +867,7 @@ testRun(void)
String *const testCDup = strCat(strNew(), testC);
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_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/uXX/build"));
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("true"));
@ -903,6 +907,7 @@ testRun(void)
String *const testCDup = strCat(strNew(), testC);
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_PATH_BUILD]}"), STRDEF(TEST_PATH "/test/unit-3/uXX/build"));
strReplace(testCDup, STRDEF("{[C_TEST_PROFILE]}"), STRDEF("false"));

View File

@ -104,6 +104,9 @@ STRING_EXTERN(TEST_GROUP_STR, TEST_GROUP);
#include "common/harnessDebug.h"
#include "common/harnessTest.intern.h"
// Is log expect testing enabled?
#define TEST_LOG_EXPECT {[C_TEST_LOG_EXPECT]}
#ifdef HRN_FEATURE_LOG
#include "common/harnessLog.h"
void harnessLogLevelDefaultSet(LogLevel logLevel);
@ -196,6 +199,7 @@ main(int argListSize, const char *argList[])
argList[0], // Test exe
TEST_PROJECT_EXE, // Project exe
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_TIMING]}, // Is timing enabled (may be disabled for reproducible documentation)
TEST_PATH, // Path where tests write data