augment test/run_tests.pl to filter indirect leaks

When verbosity isn't set to 1 or higher, suppress indirect leaks (i.e.
only print direct leaks) to make output more human-readable.  Setting
V=1 on make test produces all leaks (direct and indirect)

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22678)
This commit is contained in:
Neil Horman 2023-11-09 09:12:51 -05:00
parent d59c3febdc
commit d1093fa92c

View File

@ -175,6 +175,7 @@ $eres = eval {
my $failure_verbosity = $openssl_args{failure_verbosity};
my @plans = (); # initial level, no plan yet
my $output_buffer = "";
my $in_indirect = 0;
# We rely heavily on perl closures to make failure verbosity work
# We need to do so, because there's no way to safely pass extra
@ -211,7 +212,21 @@ $eres = eval {
$output_buffer = ""; # ignore comments etc. until plan
} elsif ($is_test) { # result of a test
pop @plans if @plans && --($plans[-1]) <= 0;
print $output_buffer if !$is_ok;
if ($output_buffer =~ /.*Indirect leak of.*/ == 1) {
my @asan_array = split("\n", $output_buffer);
foreach (@asan_array) {
if ($_ =~ /.*Indirect leak of.*/ == 1) {
$in_indirect = 1;
} else {
if ($_ =~ /^ #.*/ == 0) {
$in_indirect = 0;
}
}
print "$_\n" if !$in_indirect;
}
} else {
print $output_buffer if !$is_ok;
}
print "\n".$self->as_string
if !$is_ok || $failure_verbosity == 2;
print "\n# ------------------------------------------------------------------------------" if !$is_ok;