1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

selftest: Allow make test to run with --address-sanitizer

Recent GCC versions enforce that the library must be in LD_PRELOAD if linked to a plugin
(like a python module).

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2018-05-03 15:47:45 +12:00
parent 7e091e5051
commit 6124499804
2 changed files with 35 additions and 0 deletions

View File

@ -60,6 +60,7 @@ my $opt_libnss_wrapper_so_path = "";
my $opt_libresolv_wrapper_so_path = "";
my $opt_libsocket_wrapper_so_path = "";
my $opt_libuid_wrapper_so_path = "";
my $opt_libasan_so_path = "";
my $opt_use_dns_faking = 0;
my @testlists = ();
@ -225,6 +226,7 @@ Preload cwrap:
--resolv_wrapper_so_path=FILE the resolv_wrapper library to preload
--socket_wrapper_so_path=FILE the socket_wrapper library to preload
--uid_wrapper_so_path=FILE the uid_wrapper library to preload
--asan_so_path=FILE the asan library to preload
DNS:
--use-dns-faking Fake DNS entries rather than talking to our
@ -275,6 +277,7 @@ my $result = GetOptions (
'resolv_wrapper_so_path=s' => \$opt_libresolv_wrapper_so_path,
'socket_wrapper_so_path=s' => \$opt_libsocket_wrapper_so_path,
'uid_wrapper_so_path=s' => \$opt_libuid_wrapper_so_path,
'asan_so_path=s' => \$opt_libasan_so_path,
'use-dns-faking' => \$opt_use_dns_faking
);
@ -378,6 +381,14 @@ if ($opt_socket_wrapper_pcap) {
my $ld_preload = $ENV{LD_PRELOAD};
if ($opt_libasan_so_path) {
if ($ld_preload) {
$ld_preload = "$ld_preload:$opt_libasan_so_path";
} else {
$ld_preload = "$opt_libasan_so_path";
}
}
if ($opt_libnss_wrapper_so_path) {
if ($ld_preload) {
$ld_preload = "$ld_preload:$opt_libnss_wrapper_so_path";

View File

@ -249,9 +249,32 @@ def cmd_testonly(opt):
# GSS_KRB5_CRED_NO_CI_FLAGS_X
env.OPTIONS += " --exclude=${srcdir}/selftest/skip.no-GSS_KRB5_CRED_NO_CI_FLAGS_X"
if env.ADDRESS_SANITIZER:
# We try to find the correct libasan automatically
libasan = Utils.cmd_output('ldd bin/texpect | grep libasan| cut -f 3 -d \ ',
silent=True).strip()
# Have the selftest.pl LD_PRELOAD libasan in the right spot
env.OPTIONS += " --asan_so_path=" + libasan
subunit_cache = None
# We use the full path rather than relative path to avoid problems on some platforms (ie. solaris 8).
env.CORE_COMMAND = '${PERL} ${srcdir}/selftest/selftest.pl --target=${SELFTEST_TARGET} --prefix=${SELFTEST_PREFIX} --srcdir=${srcdir} --exclude=${srcdir}/selftest/skip ${TESTLISTS} ${OPTIONS} ${TESTS}'
if env.ADDRESS_SANITIZER:
# For now we cannot run with leak detection
no_leak_check = "ASAN_OPTIONS=detect_leaks=0"
env.CORE_COMMAND = no_leak_check + " " + env.CORE_COMMAND
# We need to have the subunit filter and formatter preload
# libasan otherwise the tests fail at startup.
#
# Also, we do not care about leaks in python
asan_envs = no_leak_check + " LD_PRELOAD=" + libasan + ' '
env.FILTER_OPTIONS = asan_envs + env.FILTER_OPTIONS
env.SUBUNIT_FORMATTER = asan_envs + env.SUBUNIT_FORMATTER
if Options.options.LIST:
cmd = '${CORE_COMMAND} --list'
else:
@ -263,6 +286,7 @@ def cmd_testonly(opt):
cmd += ' | tee %s | ${FORMAT_TEST_OUTPUT}' % subunit_cache
else:
cmd += ' | ${FILTER_OPTIONS}'
runcmd = EXPAND_VARIABLES(opt, cmd)
print("test: running %s" % runcmd)