[test suite] improve ASAN instrumentation check (m32 vs. non-m32 Makefile option)

This commit is contained in:
Michael Rash 2018-08-10 07:44:10 -07:00
parent 6438771965
commit 5a305ffe07
5 changed files with 46 additions and 27 deletions

View File

@ -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 \

View File

@ -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

6
test/asan/Makefile-m32 Normal file
View File

@ -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

View File

@ -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;
}

View File

@ -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,
},
);