From 7e6ec092f6eadb2c0ee670ad884a77626e304809 Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Sun, 14 Jun 2015 19:23:18 -0800 Subject: [PATCH] [test suite] consolidate crash detection into a single function --- test/test-fwknop.pl | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/test/test-fwknop.pl b/test/test-fwknop.pl index efc42730..443ceaf5 100755 --- a/test/test-fwknop.pl +++ b/test/test-fwknop.pl @@ -1592,12 +1592,7 @@ sub fko_wrapper_exec() { } } - if (&file_find_regex([qr/segmentation\sfault/i, qr/core\sdumped/i], - $MATCH_ANY, $NO_APPEND_RESULTS, $curr_test_file)) { - &write_test_file("[-] crash message found in: $curr_test_file\n", - $curr_test_file); - $rv = 0; - } + $rv = 0 if &is_crash($curr_test_file); } return $rv; @@ -1678,20 +1673,7 @@ sub look_for_crashes() { next if &file_find_regex([qr/ASAN.*crash\sverification/i], $MATCH_ALL, $NO_APPEND_RESULTS, $f); - if (&file_find_regex([qr/segmentation\sfault/i, qr/core\sdumped/i], - $MATCH_ANY, $NO_APPEND_RESULTS, $f)) { - &write_test_file("[-] crash message found in: $f\n", - $curr_test_file); - $rv = 0; - } - - if (&file_find_regex([qr/ERROR\:\sAddressSanitizer/, - qr/SUMMARY\:\sAddressSanitizer/], - $MATCH_ANY, $NO_APPEND_RESULTS, $f)) { - &write_test_file("[-] AddressSanitizer crash found in: $f\n", - $curr_test_file); - $rv = 0; - } + $rv = 0 if &is_crash($f); } $do_crash_check = 0; @@ -1699,6 +1681,26 @@ sub look_for_crashes() { return $rv; } +sub is_crash() { + my $file = shift; + my $rv = 0; + if (&file_find_regex([qr/segmentation\sfault/i, qr/core\sdumped/i], + $MATCH_ANY, $NO_APPEND_RESULTS, $file)) { + &write_test_file("[-] crash message found in: $file\n", + $curr_test_file); + $rv = 1; + } + + if (&file_find_regex([qr/ERROR\:\sAddressSanitizer/, + qr/SUMMARY\:\sAddressSanitizer/], + $MATCH_ANY, $NO_APPEND_RESULTS, $file)) { + &write_test_file("[-] AddressSanitizer crash found in: $file\n", + $curr_test_file); + $rv = 1; + } + return $rv; +} + sub config_recompile() { my $config_cmd = shift;