1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add mem context test missing from 0f7b6a33.

A coverage exception was added during development but was not removed before commit.

Remove the exception and add a test for coverage.
This commit is contained in:
David Steele 2022-09-14 10:06:06 -07:00
parent 8fb61a809d
commit 240cd755d1
3 changed files with 30 additions and 2 deletions

View File

@ -100,7 +100,10 @@
<release-development-list>
<release-item>
<github-pull-request id="1842"/>
<commit subject="Skip mem context cleanup in CATCH_FATAL() block.">
<github-pull-request id="1842"/>
</commit>
<commit subject="Add mem context test missing from 0f7b6a33."/>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>

View File

@ -1064,7 +1064,7 @@ memContextClean(const unsigned int tryDepth, const bool fatal)
// mask the original error.
if (memContextStack[memContextMaxStackIdx].type == memContextStackTypeNew)
{
if (!fatal) // {uncovered !!!}
if (!fatal)
memContextFree(memContextStack[memContextMaxStackIdx].memContext);
}
// Else find the prior context and make it the current context

View File

@ -426,6 +426,31 @@ testRun(void)
TEST_RESULT_BOOL(catch, true, "new context error was caught");
TEST_RESULT_PTR(memContextCurrent(), memContextTop(), "context is now 'TOP'");
// ------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("new context not freed on fatal error");
MemContext *volatile memContextFatal;
catch = false;
TRY_BEGIN()
{
MEM_CONTEXT_NEW_BEGIN(test-new-failed-fatal-block, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
memContextFatal = MEM_CONTEXT_NEW();
THROW(AssertError, "create failed");
}
MEM_CONTEXT_NEW_END();
}
CATCH_FATAL()
{
catch = true;
}
TRY_END();
TEST_RESULT_VOID(memContextFree(memContextFatal), "free new context not freed by catch fatal");
TEST_RESULT_BOOL(catch, true, "new context error was caught");
TEST_RESULT_PTR(memContextCurrent(), memContextTop(), "context is now 'TOP'");
}
// *****************************************************************************************************************************