diff --git a/test/test-fwknop.pl b/test/test-fwknop.pl index f761a148..8691a0a1 100755 --- a/test/test-fwknop.pl +++ b/test/test-fwknop.pl @@ -220,6 +220,7 @@ my $valgrind_disable_child_silent = 0; my $valgrind_suppressions_file = cwd() . '/valgrind_suppressions'; our $valgrind_str = ''; my $asan_mode = 0; +my $ubsan_mode = 0; my %cached_fw_policy = (); my $cpan_valgrind_mod = 'Test::Valgrind'; my %prev_valgrind_cov = (); @@ -1454,11 +1455,7 @@ sub asan_verification() { if ($rv) { &run_cmd('./a.out', "../$cmd_out_tmp", "../$curr_test_file"); - unless (&file_find_regex([qr/ERROR\:\s\w+Sanitizer/, - qr/SUMMARY\:\s\w+Sanitizer/], - $MATCH_ALL, $NO_APPEND_RESULTS, "../$curr_test_file")) { - $rv = 0; - } + $rv = 0 unless &is_sanitizer_crash("../$curr_test_file"); } chdir '..' or die $!; @@ -1641,6 +1638,7 @@ sub fko_wrapper_exec() { my $make_arg = $test_hr->{'wrapper_compile'}; $make_arg = 'asan' if $asan_mode; + $make_arg = 'ubsan' if $asan_mode; if ($test_hr->{'wrapper_binary'} =~ m|/fko_wrapper$|) { if ($enable_fuzzing_interfaces_tests) { @@ -1793,6 +1791,22 @@ sub look_for_crashes() { return $rv; } +sub is_sanitizer_crash() { + my $file = shift; + + my $rv = 0; + + if (&file_find_regex([qr/ERROR\:\s\w+Sanitizer/, + qr/SUMMARY\:\s\w+Sanitizer/], + $MATCH_ANY, $NO_APPEND_RESULTS, $file)) { + &write_test_file("[-] Sanitizer crash found in: $file\n", + $curr_test_file); + $rv = 1; + } + + return $rv; +} + sub is_crash() { my $file = shift; my $rv = 0; @@ -1803,19 +1817,14 @@ sub is_crash() { $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; - } + $rv = 1 if &is_sanitizer_crash($file); ### ASan and valgrind don't appear to be compatible, and and ASan ### will throw an error when the two are mixed if (&file_find_regex([qr/Shadow memory range interleaves/], $MATCH_ANY, $NO_APPEND_RESULTS, $file)) { - &write_test_file("[-] AddressSanitizer not compatible with valgrind: $file\n", + &write_test_file("[-] Sanitizer infrastructure not " . + "compatible with valgrind: $file\n", $curr_test_file); $rv = 1; } @@ -7324,7 +7333,7 @@ sub init() { push @tests_to_exclude, qr/down interface/; } - ### see if we're compiled with ASAN support + ### see if we're compiled with AddressSanitizer support if (&file_find_regex([qr/enable\-asan\-support/], $MATCH_ALL, $NO_APPEND_RESULTS, $config_log)) { $asan_mode = 1; @@ -7334,6 +7343,16 @@ sub init() { push @tests_to_exclude, qr/ASAN/; } + ### see if we're compiled with UndefinedBehaviorSanitizer support + if (&file_find_regex([qr/enable\-ubsan\-support/], + $MATCH_ALL, $NO_APPEND_RESULTS, $config_log)) { + $asan_mode = 1; + } else { + &write_test_file("[-] Can't find --enable-ubsan-support in $config_log\n", + $curr_test_file); + push @tests_to_exclude, qr/UBSAN/; + } + if ($gcov_path) { if ($enable_profile_coverage_check and not $list_mode) {