Skip to content

Commit

Permalink
Get stack traces from TAP tests
Browse files Browse the repository at this point in the history
for TAP tests we have to look for data directories in the tmp_check
directory, and then look in those for core files.

Should cover the vast majority of cases where we are not getting stack
traces.
  • Loading branch information
adunstan committed May 7, 2021
1 parent eb3a57b commit 5361bb5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
22 changes: 21 additions & 1 deletion PGBuild/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use warnings;
use Carp;
use Config;
use Fcntl qw(:seek);
use File::Find qw();
use File::Path;
use File::Copy;
use File::Temp qw(tempfile);
Expand Down Expand Up @@ -177,8 +178,27 @@ sub get_stack_trace
my $bindir = shift;
my $pgdata = shift;

my @cores;

if (-e "$pgdata/postgresql.conf")
{
@cores = glob("$pgdata/$core_file_glob");
}
else
{
# if this isn't a data directory, go hunting for subdirectories
# that are data directories and then look in those for core files
my @datadirs;
my $wanted = sub
{ $_ eq 'postgresql.conf' && push @datadirs, $File::Find::dir; } ;
File::Find::find($wanted, $pgdata);
foreach my $dir (@datadirs)
{
push(@cores, glob("$dir/$core_file_glob"));
}
}

# no core = no result
my @cores = glob("$pgdata/$core_file_glob");
return () unless @cores;

# no gdb = no result
Expand Down
7 changes: 7 additions & 0 deletions run_build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,13 @@ sub run_tap_test

$log->add_log($_) foreach (@logs);

if ($status)
{
my @trace = get_stack_trace("$pgsql/tmp_install/$installdir/bin",
"$dir/tmp_check");
$log->add_log_lines("stack-trace", \@trace) if @trace;
}

push(@makeout, $log->log_string);

writelog("$testname-$taptarget", \@makeout);
Expand Down

0 comments on commit 5361bb5

Please sign in to comment.