1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Improvements to test harness memory debugging.

Only set -DDEBUG_MEM for the modules currently being tested rather than globally.

Also run tests in a temp mem context. Running in the top context can confuse memory accounting when a new context is created in the top context.
This commit is contained in:
David Steele 2022-04-28 12:33:39 -04:00
parent 90f939b36f
commit 4872a3f121
2 changed files with 22 additions and 4 deletions

View File

@ -302,7 +302,6 @@ sub run
"\n" .
"CFLAGS_TEST =" .
" \\\n\t" . (($self->{bOptimize} && ($self->{bProfile} || $bPerformance)) ? '-O2' : '-O0') .
" \\\n\t-DDEBUG_MEM" .
(!$self->{bDebugTestTrace} && $self->{bDebug} ? " \\\n\t-DDEBUG_TEST_TRACE" : '') .
($bCoverage ? " \\\n\t-fprofile-arcs -ftest-coverage" : '') .
($self->{oTest}->{&TEST_VM} eq VM_NONE ? '' : " \\\n\t-DTEST_CONTAINER_REQUIRED") .

View File

@ -5,6 +5,11 @@ This wrapper runs the C unit tests.
***********************************************************************************************************************************/
#include "build.auto.h"
// This must be before all includes except build.auto.h
#ifdef HRN_FEATURE_MEMCONTEXT
#define DEBUG_MEM
#endif
/***********************************************************************************************************************************
C files to be tested
@ -168,7 +173,11 @@ main(int argListSize, const char *argList[])
// Initialize statistics
#if defined(HRN_INTEST_STAT) || defined(HRN_FEATURE_STAT)
statInit();
MEM_CONTEXT_TEMP_BEGIN()
{
statInit();
}
MEM_CONTEXT_TEMP_END();
#endif
// Set neutral umask for testing
@ -212,8 +221,18 @@ main(int argListSize, const char *argList[])
TRY_BEGIN()
{
#endif
// Run the tests
testRun();
#ifdef HRN_FEATURE_MEMCONTEXT
MEM_CONTEXT_TEMP_BEGIN()
{
#endif
// Run the tests
testRun();
#ifdef HRN_FEATURE_MEMCONTEXT
}
MEM_CONTEXT_TEMP_END();
#endif
#ifdef HRN_FEATURE_ERROR
}
CATCH_ANY()