test/eject: guard asan LD_PRELOAD with use-system-commands check

This test tries to add asan to LD_PRELOAD because the just-built eject
will call the host /bin/umount, and apparently asan doesn't like this.

However, if ldd isn't present, this fails as the path to asan is the
error message saying that ldd isn't present.

As the asan workaround is only needed when executing the binaries that
have just been built and not the system binaries, only use it if the
test is on the built binaries.

Closes #1373.

Signed-off-by: Ross Burton <ross.burton@arm.com>
This commit is contained in:
Ross Burton 2021-07-01 20:44:31 +01:00 committed by Karel Zak
parent 9ada40d3cc
commit be39647ac4
1 changed files with 9 additions and 7 deletions

View File

@ -60,13 +60,15 @@ function deinit_device {
ts_scsi_debug_rmmod ts_scsi_debug_rmmod
} }
# As the eject binary execl()s an uninstrumented /bin/umount binary, we need if [ "$TS_USE_SYSTEM_COMMANDS" != "yes" ]; then
# to explicitly $LD_PRELOAD the ASan's runtime DSO, otherwise ASan will complain. # As the eject binary execl()s an uninstrumented /bin/umount binary, we need
# Since all three utilities used by this test (eject, fdisk, mount) are just # to explicitly $LD_PRELOAD the ASan's runtime DSO, otherwise ASan will complain.
# libtool wrappers, let's check the kill binary instead, which should have # Since all three utilities used by this test (eject, fdisk, mount) are just
# the needed DSO information. # libtool wrappers, let's check the kill binary instead, which should have
ASAN_RT_PATH="$(ts_get_asan_rt_path "$TS_CMD_KILL")" # the needed DSO information.
[ -n "$ASAN_RT_PATH" ] && export LD_PRELOAD="$ASAN_RT_PATH:$LD_PRELOAD" ASAN_RT_PATH="$(ts_get_asan_rt_path "$TS_CMD_KILL")"
[ -n "$ASAN_RT_PATH" ] && export LD_PRELOAD="$ASAN_RT_PATH:$LD_PRELOAD"
fi
ts_init_subtest "by-disk" ts_init_subtest "by-disk"
init_device init_device