From 389e55ddfcd5a8a2d7c75fdca905768a8318ed2a Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Sun, 15 Jun 2014 10:55:19 -0400 Subject: [PATCH] [test suite] consolidate valgrind success/failure criteria into a single function --- test/test-fwknop.pl | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/test/test-fwknop.pl b/test/test-fwknop.pl index c307d80f..79e6d59c 100755 --- a/test/test-fwknop.pl +++ b/test/test-fwknop.pl @@ -954,16 +954,8 @@ sub run_test() { next unless -e $file; if (&file_find_regex([qr/^==\d+==\sHEAP\sSUMMARY/], $MATCH_ALL, $NO_APPEND_RESULTS, $file)) { - unless (&file_find_regex( - [qr/no\sleaks\sare\spossible/], - $MATCH_ALL, $APPEND_RESULTS, $file)) { - $rv = 0 unless &file_find_regex( - [qr/definitely\slost\:\s0\sbytes/], - $MATCH_ALL, $APPEND_RESULTS, $file); - $rv = 0 unless &file_find_regex( - [qr/indirectly\slost\:\s0\sbytes/], - $MATCH_ALL, $APPEND_RESULTS, $file); - } + + $rv = 0 unless &valgrind_results($file); } } } @@ -1429,8 +1421,7 @@ sub fko_wrapper_exec() { "../$cmd_out_tmp", "../$curr_test_file"); if ($test_hr->{'wrapper_script'} =~ /valgrind/) { - $rv = 0 unless &file_find_regex([qr/no\sleaks\sare\spossible/], - $MATCH_ALL, $APPEND_RESULTS, "../$curr_test_file"); + $rv = 0 unless &valgrind_results("../$curr_test_file"); } } @@ -1461,6 +1452,24 @@ sub fko_wrapper_exec() { return $rv; } +sub valgrind_results() { + my $file = shift; + + my $rv = 1; + + unless (&file_find_regex( + [qr/no\sleaks\sare\spossible/], + $MATCH_ALL, $APPEND_RESULTS, $file)) { + $rv = 0 unless &file_find_regex( + [qr/definitely\slost\:\s0\sbytes/], + $MATCH_ALL, $APPEND_RESULTS, $file); + $rv = 0 unless &file_find_regex( + [qr/indirectly\slost\:\s0\sbytes/], + $MATCH_ALL, $APPEND_RESULTS, $file); + } + return $rv; +} + sub test_suite_conf_files() { my $make_file = '../Makefile.am'; my $rv = 1;