1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-03 00:26:59 +02:00

Only run test-level stack trace by default for unit-tested modules.

This amends 70c30dfb which disabled test tracing in general.

Instead, only enable test tracing by default for modules that are being unit tested. This saves lots of time but still ensures that test tracing is working and helps with debugging in unit tests.

Also rename the option to --debug-test-trace for a clarity.
This commit is contained in:
David Steele
2019-02-27 17:09:19 +02:00
parent 3a05359087
commit 18b62a4220
5 changed files with 12 additions and 11 deletions

View File

@ -124,7 +124,7 @@
</release-item> </release-item>
<release-item> <release-item>
<p>Disable test-level stack trace by default.</p> <p>Only run test-level stack trace by default for unit-tested modules.</p>
</release-item> </release-item>
<release-item> <release-item>

View File

@ -291,7 +291,7 @@ Function Test Macros
In debug builds these macros will update the stack trace with function names and parameters but not log. In production builds all In debug builds these macros will update the stack trace with function names and parameters but not log. In production builds all
test macros are compiled out. test macros are compiled out.
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#ifdef DEBUG_TRACE #ifdef DEBUG_TEST_TRACE
#define FUNCTION_TEST_BEGIN() \ #define FUNCTION_TEST_BEGIN() \
if (stackTraceTest()) \ if (stackTraceTest()) \
{ \ { \

View File

@ -176,7 +176,7 @@ infoArchiveIdHistoryMatch(
strPtr(pgVersionToStr(pgVersion)), pgSystemId); strPtr(pgVersionToStr(pgVersion)), pgSystemId);
} }
FUNCTION_TEST_RETURN(archiveId); FUNCTION_LOG_RETURN(STRING, archiveId);
} }
/*********************************************************************************************************************************** /***********************************************************************************************************************************

View File

@ -74,7 +74,7 @@ sub new
$self->{bBackTrace}, $self->{bBackTrace},
$self->{bProfile}, $self->{bProfile},
$self->{bDebug}, $self->{bDebug},
$self->{bDebugTrace}, $self->{bDebugTestTrace},
) = ) =
logDebugParam logDebugParam
( (
@ -102,7 +102,7 @@ sub new
{name => 'bBackTrace'}, {name => 'bBackTrace'},
{name => 'bProfile'}, {name => 'bProfile'},
{name => 'bDebug'}, {name => 'bDebug'},
{name => 'bDebugTrace'}, {name => 'bDebugTestTrace'},
); );
# Set try to 0 # Set try to 0
@ -391,7 +391,7 @@ sub run
($self->{oTest}->{&TEST_DEBUG_UNIT_SUPPRESS} ? '' : " -DDEBUG_UNIT") . ($self->{oTest}->{&TEST_DEBUG_UNIT_SUPPRESS} ? '' : " -DDEBUG_UNIT") .
(vmWithBackTrace($self->{oTest}->{&TEST_VM}) && $self->{bBackTrace} ? ' -DWITH_BACKTRACE' : '') . (vmWithBackTrace($self->{oTest}->{&TEST_VM}) && $self->{bBackTrace} ? ' -DWITH_BACKTRACE' : '') .
($self->{oTest}->{&TEST_CDEF} ? " $self->{oTest}->{&TEST_CDEF}" : '') . ($self->{oTest}->{&TEST_CDEF} ? " $self->{oTest}->{&TEST_CDEF}" : '') .
($self->{bDebug} ? '' : ' -DNDEBUG') . ($self->{bDebugTrace} ? ' -DDEBUG_TRACE' : ''); ($self->{bDebug} ? '' : ' -DNDEBUG') . ($self->{bDebugTestTrace} ? ' -DDEBUG_TEST_TRACE' : '');
# Flags used to buid harness files # Flags used to buid harness files
my $strHarnessFlags = my $strHarnessFlags =
@ -404,6 +404,7 @@ sub run
my $strTestFlags = my $strTestFlags =
'-Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wconversion -Wformat=2' . '-Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wconversion -Wformat=2' .
' -Wformat-nonliteral -Wstrict-prototypes -Wpointer-arith -Wvla' . ' -Wformat-nonliteral -Wstrict-prototypes -Wpointer-arith -Wvla' .
' -DDEBUG_TEST_TRACE' .
($self->{oTest}->{&TEST_VM} eq VM_U16 || $self->{oTest}->{&TEST_VM} eq VM_U18 ? ($self->{oTest}->{&TEST_VM} eq VM_U16 || $self->{oTest}->{&TEST_VM} eq VM_U18 ?
' -Wformat-signedness' : '') . ' -Wformat-signedness' : '') .
($self->{oTest}->{&TEST_VM} eq VM_U18 ? ($self->{oTest}->{&TEST_VM} eq VM_U18 ?

View File

@ -96,7 +96,7 @@ test.pl [options]
--backtrace enable backtrace when available (adds stack trace line numbers -- very slow) --backtrace enable backtrace when available (adds stack trace line numbers -- very slow)
--profile generate profile info --profile generate profile info
--no-debug don't generate a debug build --no-debug don't generate a debug build
--debug-trace stack trace for low-level functions (slow, esp w/valgrind, may cause timeouts) --debug-test-trace test stack trace for low-level functions (slow, esp w/valgrind, may cause timeouts)
Configuration Options: Configuration Options:
--psql-bin path to the psql executables (e.g. /usr/lib/postgresql/9.3/bin/) --psql-bin path to the psql executables (e.g. /usr/lib/postgresql/9.3/bin/)
@ -160,7 +160,7 @@ my $bExpect = false;
my $bNoValgrind = false; my $bNoValgrind = false;
my $bNoOptimize = false; my $bNoOptimize = false;
my $bNoDebug = false; my $bNoDebug = false;
my $bDebugTrace = false; my $bDebugTestTrace = false;
my $iRetry = 0; my $iRetry = 0;
GetOptions ('q|quiet' => \$bQuiet, GetOptions ('q|quiet' => \$bQuiet,
@ -203,7 +203,7 @@ GetOptions ('q|quiet' => \$bQuiet,
'no-valgrind' => \$bNoValgrind, 'no-valgrind' => \$bNoValgrind,
'no-optimize' => \$bNoOptimize, 'no-optimize' => \$bNoOptimize,
'no-debug', => \$bNoDebug, 'no-debug', => \$bNoDebug,
'debug-trace', => \$bDebugTrace, 'debug-test-trace', => \$bDebugTestTrace,
'retry=s' => \$iRetry) 'retry=s' => \$iRetry)
or pod2usage(2); or pod2usage(2);
@ -816,7 +816,7 @@ eval
(vmWithBackTrace($strBuildVM) && $bNoLint && $bBackTrace ? ' -DWITH_BACKTRACE' : ''); (vmWithBackTrace($strBuildVM) && $bNoLint && $bBackTrace ? ' -DWITH_BACKTRACE' : '');
my $strLdExtra = vmWithBackTrace($strBuildVM) && $bNoLint && $bBackTrace ? '-lbacktrace' : ''; my $strLdExtra = vmWithBackTrace($strBuildVM) && $bNoLint && $bBackTrace ? '-lbacktrace' : '';
my $strCDebug = my $strCDebug =
(vmDebugIntegration($strBuildVM) ? '' : '-DNDEBUG') . ($bDebugTrace ? ' -DDEBUG_TRACE' : ''); (vmDebugIntegration($strBuildVM) ? '' : '-DNDEBUG') . ($bDebugTestTrace ? ' -DDEBUG_TEST_TRACE' : '');
executeTest( executeTest(
'docker exec -i test-build' . 'docker exec -i test-build' .
@ -1231,7 +1231,7 @@ eval
my $oJob = new pgBackRestTest::Common::JobTest( my $oJob = new pgBackRestTest::Common::JobTest(
$oStorageTest, $strBackRestBase, $strTestPath, $strCoveragePath, $$oyTestRun[$iTestIdx], $bDryRun, $bVmOut, $oStorageTest, $strBackRestBase, $strTestPath, $strCoveragePath, $$oyTestRun[$iTestIdx], $bDryRun, $bVmOut,
$iVmIdx, $iVmMax, $iTestIdx, $iTestMax, $strLogLevel, $strLogLevelTest, $bLogForce, $bShowOutputAsync, $bNoCleanup, $iRetry, $iVmIdx, $iVmMax, $iTestIdx, $iTestMax, $strLogLevel, $strLogLevelTest, $bLogForce, $bShowOutputAsync, $bNoCleanup, $iRetry,
!$bNoValgrind, !$bNoCoverage, !$bNoOptimize, $bBackTrace, $bProfile, !$bNoDebug, $bDebugTrace); !$bNoValgrind, !$bNoCoverage, !$bNoOptimize, $bBackTrace, $bProfile, !$bNoDebug, $bDebugTestTrace);
$iTestIdx++; $iTestIdx++;
if ($oJob->run()) if ($oJob->run())