1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-10-30 23:37:45 +02:00

Add testRepoPath() to let C unit tests know where the code repository is located.

This allows a C unit test to access data in the code repository that might be useful for testing.

Add testRepoPathSet() to set the repository path.

In passing remove extra whitespace in the TEST_RESULT_VOID() macro.
This commit is contained in:
David Steele
2018-11-20 15:48:56 -05:00
parent b0659278cc
commit f743d4e924
5 changed files with 37 additions and 1 deletions

View File

@@ -28,6 +28,14 @@
</release-item>
</release-development-list>
</release-core-list>
<release-test-list>
<release-development-list>
<release-item>
<p>Add <code>testRepoPath()</code> to let C unit tests know where the code repository is located.</p>
</release-item>
</release-development-list>
</release-test-list>
</release>
<release date="2018-11-16" version="2.07" title="Automatic Backup Checksum Delta">

View File

@@ -354,6 +354,7 @@ sub run
# Set globals
$strTestC =~ s/\{\[C\_TEST\_PATH\]\}/$strVmTestPath/g;
$strTestC =~ s/\{\[C\_TEST\_EXPECT_PATH\]\}/$self->{strExpectPath}/g;
$strTestC =~ s/\{\[C\_TEST\_REPO_PATH\]\}/$self->{strBackRestBase}/g;
# Set defalt log level
my $strLogLevelTestC = "logLevel" . ucfirst($self->{strLogLevelTest});

View File

@@ -27,6 +27,7 @@ static uint64_t timeMSecBegin;
static const char *testExeData = NULL;
static const char *testPathData = NULL;
static const char *testRepoPathData = NULL;
static const char *testExpectPathData = NULL;
/***********************************************************************************************************************************
@@ -61,6 +62,30 @@ testExeSet(const char *testExe)
FUNCTION_HARNESS_RESULT_VOID();
}
/***********************************************************************************************************************************
Get and set the path for the pgbackrest repo
***********************************************************************************************************************************/
const char *
testRepoPath(void)
{
FUNCTION_HARNESS_VOID();
FUNCTION_HARNESS_RESULT(STRINGZ, testRepoPathData);
}
void
testRepoPathSet(const char *testRepoPath)
{
FUNCTION_HARNESS_BEGIN();
FUNCTION_HARNESS_PARAM(STRINGZ, testRepoPath);
FUNCTION_HARNESS_ASSERT(testRepoPath != NULL);
FUNCTION_HARNESS_END();
testRepoPathData = testRepoPath;
FUNCTION_HARNESS_RESULT_VOID();
}
/***********************************************************************************************************************************
Get and set the test path, i.e., the path where this test should write its files
***********************************************************************************************************************************/

View File

@@ -30,6 +30,8 @@ const char *testPath(void);
void testPathSet(const char *testPath);
const char *testExpectPath(void);
void testExpectPathSet(const char *testExpectPath);
const char *testRepoPath(void);
void testRepoPathSet(const char *testRepoPath);
/***********************************************************************************************************************************
Convert a macro to a string -- handy for testing debug macros
@@ -211,7 +213,6 @@ Test that a void statement returns and does not throw an error
THROW_FMT( \
AssertError, "EXPECTED VOID RESULT FROM STATEMENT: %s\n\nBUT GOT %s: %s\n\nTHROWN AT:\n%s", #statement, errorName(), \
errorMessage(), errorStackTrace()); \
\
} \
TRY_END(); \
}

View File

@@ -73,6 +73,7 @@ main(int argListSize, const char *argList[])
// Set globals
testExeSet(argList[0]);
testPathSet("{[C_TEST_PATH]}");
testRepoPathSet("{[C_TEST_REPO_PATH]}");
testExpectPathSet("{[C_TEST_EXPECT_PATH]}");
// Set default test log level