diff --git a/Makefile.am b/Makefile.am index a4ead871..160142fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -401,6 +401,7 @@ EXTRA_DIST = \ test/misc/pf.sh \ test/asan/use-after-free.c \ test/asan/Makefile \ + test/asan/Makefile-m32 \ test/afl/compile/afl-compile-code-coverage.sh \ test/afl/compile/afl-compile.sh \ test/afl/compile/fcns \ diff --git a/test/asan/Makefile b/test/asan/Makefile index aa6f6452..420d038b 100644 --- a/test/asan/Makefile +++ b/test/asan/Makefile @@ -1,6 +1,6 @@ all : use-after-free.c - cc -Wall -m32 -O1 -g -fsanitize=address -fno-omit-frame-pointer use-after-free.c + cc -Wall -O1 -g -fsanitize=address -fno-omit-frame-pointer use-after-free.c clean: rm -f a.out diff --git a/test/asan/Makefile-m32 b/test/asan/Makefile-m32 new file mode 100644 index 00000000..aa6f6452 --- /dev/null +++ b/test/asan/Makefile-m32 @@ -0,0 +1,6 @@ + +all : use-after-free.c + cc -Wall -m32 -O1 -g -fsanitize=address -fno-omit-frame-pointer use-after-free.c + +clean: + rm -f a.out diff --git a/test/test-fwknop.pl b/test/test-fwknop.pl index 3461a48e..23602170 100755 --- a/test/test-fwknop.pl +++ b/test/test-fwknop.pl @@ -1632,39 +1632,51 @@ sub build_results_hash() { return; } -sub asan_verification() { +sub is_asan_instrumentation_working() { my $test_hr = shift; my $rv = 1; - chdir $asan_dir or die $!; - unless (&run_cmd('make clean', "../$cmd_out_tmp", - "../$curr_test_file")) { - chdir '..' or die $!; - return 0; - } - - if ($sudo_path) { - unless (&run_cmd("$sudo_path -u $username make", - "../$cmd_out_tmp", "../$curr_test_file")) { - unless (&run_cmd('make', "../$cmd_out_tmp", - "../$curr_test_file")) { - $rv = 0; - } - } - } else { - unless (&run_cmd('make', "../$cmd_out_tmp", + for my $file ('Makefile', 'Makefile-m32') { + $rv = 1; + unless (&run_cmd("make -f $file clean", "../$cmd_out_tmp", "../$curr_test_file")) { $rv = 0; + next; + } + + if ($sudo_path) { + unless (&run_cmd("$sudo_path -u $username make -f $file", + "../$cmd_out_tmp", "../$curr_test_file")) { + unless (&run_cmd("make -f $file", "../$cmd_out_tmp", + "../$curr_test_file")) { + $rv = 0; + next; + } + } + } else { + unless (&run_cmd("make -f $file", "../$cmd_out_tmp", + "../$curr_test_file")) { + $rv = 0; + next; + } + } + + if ($rv) { + &run_cmd('./a.out', "../$cmd_out_tmp", "../$curr_test_file"); + chdir '..' or die $!; + if (&is_sanitizer_crash($curr_test_file)) { + chdir $asan_dir or die $!; + $rv = 1; + last; + } else { + $rv = 0; + chdir $asan_dir or die $!; + next; + } } } - - if ($rv) { - &run_cmd('./a.out', "../$cmd_out_tmp", "../$curr_test_file"); - $rv = 0 unless &is_sanitizer_crash("../$curr_test_file"); - } - chdir '..' or die $!; return $rv; } diff --git a/test/tests/address_sanitizer.pl b/test/tests/address_sanitizer.pl index 5e3c47eb..961c0f41 100644 --- a/test/tests/address_sanitizer.pl +++ b/test/tests/address_sanitizer.pl @@ -3,8 +3,8 @@ ### if fwknop has been compiled with it. { 'category' => 'ASAN', - 'subcategory' => 'Address Sanitizer', + 'subcategory' => 'Address Sanitizer instrumentation check', 'detail' => 'crash verification', - 'function' => \&asan_verification, + 'function' => \&is_asan_instrumentation_working, }, );