augment test/run_tests.pl to filter indirect leaks
authorNeil Horman <nhorman@openssl.org>
Thu, 9 Nov 2023 14:12:51 +0000 (09:12 -0500)
committerNeil Horman <nhorman@openssl.org>
Thu, 21 Dec 2023 14:05:42 +0000 (09:05 -0500)
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)

test/run_tests.pl

index 90fba194b11bec4e82dcff9420fe54701b39cc66..1f4406a49fa1db9dc77ceba864f3f45ac8e5d828 100644 (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;