1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-03 00:26:59 +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" . "\n" .
"CFLAGS_TEST =" . "CFLAGS_TEST =" .
" \\\n\t" . (($self->{bOptimize} && ($self->{bProfile} || $bPerformance)) ? '-O2' : '-O0') . " \\\n\t" . (($self->{bOptimize} && ($self->{bProfile} || $bPerformance)) ? '-O2' : '-O0') .
" \\\n\t-DDEBUG_MEM" .
(!$self->{bDebugTestTrace} && $self->{bDebug} ? " \\\n\t-DDEBUG_TEST_TRACE" : '') . (!$self->{bDebugTestTrace} && $self->{bDebug} ? " \\\n\t-DDEBUG_TEST_TRACE" : '') .
($bCoverage ? " \\\n\t-fprofile-arcs -ftest-coverage" : '') . ($bCoverage ? " \\\n\t-fprofile-arcs -ftest-coverage" : '') .
($self->{oTest}->{&TEST_VM} eq VM_NONE ? '' : " \\\n\t-DTEST_CONTAINER_REQUIRED") . ($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" #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 C files to be tested
@ -168,7 +173,11 @@ main(int argListSize, const char *argList[])
// Initialize statistics // Initialize statistics
#if defined(HRN_INTEST_STAT) || defined(HRN_FEATURE_STAT) #if defined(HRN_INTEST_STAT) || defined(HRN_FEATURE_STAT)
MEM_CONTEXT_TEMP_BEGIN()
{
statInit(); statInit();
}
MEM_CONTEXT_TEMP_END();
#endif #endif
// Set neutral umask for testing // Set neutral umask for testing
@ -212,8 +221,18 @@ main(int argListSize, const char *argList[])
TRY_BEGIN() TRY_BEGIN()
{ {
#endif #endif
#ifdef HRN_FEATURE_MEMCONTEXT
MEM_CONTEXT_TEMP_BEGIN()
{
#endif
// Run the tests // Run the tests
testRun(); testRun();
#ifdef HRN_FEATURE_MEMCONTEXT
}
MEM_CONTEXT_TEMP_END();
#endif
#ifdef HRN_FEATURE_ERROR #ifdef HRN_FEATURE_ERROR
} }
CATCH_ANY() CATCH_ANY()