diff --git a/test/lib/pgBackRestTest/Common/JobTest.pm b/test/lib/pgBackRestTest/Common/JobTest.pm index 9cf1d4ccc..0a02b5de5 100644 --- a/test/lib/pgBackRestTest/Common/JobTest.pm +++ b/test/lib/pgBackRestTest/Common/JobTest.pm @@ -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'}); } diff --git a/test/src/command/test/build.c b/test/src/command/test/build.c index 3e23524e7..c485703a8 100644 --- a/test/src/command/test/build.c +++ b/test/src/command/test/build.c @@ -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]}"), diff --git a/test/src/common/harnessTest.c b/test/src/common/harnessTest.c index 2c6ec36ca..4171ed122 100644 --- a/test/src/common/harnessTest.c +++ b/test/src/common/harnessTest.c @@ -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 diff --git a/test/src/common/harnessTest.intern.h b/test/src/common/harnessTest.intern.h index 1a3e94e5e..1de00a0b2 100644 --- a/test/src/common/harnessTest.intern.h +++ b/test/src/common/harnessTest.intern.h @@ -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); diff --git a/test/src/module/test/testTest.c b/test/src/module/test/testTest.c index ad9f39cdc..fa758c87a 100644 --- a/test/src/module/test/testTest.c +++ b/test/src/module/test/testTest.c @@ -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")); diff --git a/test/src/test.c b/test/src/test.c index cee5ef9cb..93dde44da 100644 --- a/test/src/test.c +++ b/test/src/test.c @@ -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