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

Disable test-level stack trace by default.

Detailed stack traces for low-level functions (e.g. strCat, bufMove) can be very useful for debugging but leaving them on for all tests has become quite burdensome in terms of time.  Complex operations like generating JSON on a large KevValue can lead to timeouts even with generous values.

Add a new param, --debug-trace, to enable test-level stack trace, but leave it off by default.
This commit is contained in:
David Steele 2019-02-22 11:40:30 +02:00
parent ae86e6d5b2
commit 70c30dfb61
4 changed files with 18 additions and 7 deletions

View File

@ -93,6 +93,10 @@
<release-test-list>
<release-development-list>
<release-item>
<p>Disable test-level stack trace by default.</p>
</release-item>
<release-item>
<p>Add missing ToLog() coverage to <code>String</code>, <code>List</code>, and <code>PgControl</code>.</p>
</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
test macros are compiled out.
***********************************************************************************************************************************/
#ifdef DEBUG
#ifdef DEBUG_TRACE
#define FUNCTION_TEST_BEGIN() \
if (stackTraceTest()) \
{ \

View File

@ -74,6 +74,7 @@ sub new
$self->{bBackTrace},
$self->{bProfile},
$self->{bDebug},
$self->{bDebugTrace},
) =
logDebugParam
(
@ -101,6 +102,7 @@ sub new
{name => 'bBackTrace'},
{name => 'bProfile'},
{name => 'bDebug'},
{name => 'bDebugTrace'},
);
# Set try to 0
@ -389,7 +391,7 @@ sub run
($self->{oTest}->{&TEST_DEBUG_UNIT_SUPPRESS} ? '' : " -DDEBUG_UNIT") .
(vmWithBackTrace($self->{oTest}->{&TEST_VM}) && $self->{bBackTrace} ? ' -DWITH_BACKTRACE' : '') .
($self->{oTest}->{&TEST_CDEF} ? " $self->{oTest}->{&TEST_CDEF}" : '') .
($self->{bDebug} ? '' : " -DNDEBUG");
($self->{bDebug} ? '' : ' -DNDEBUG') . ($self->{bDebugTrace} ? ' -DDEBUG_TRACE' : '');
# Flags used to buid harness files
my $strHarnessFlags =

View File

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