From 1786fae3668fa94359ee58a8c11031dc46459255 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Tue, 3 Jul 2018 03:25:53 +0000 Subject: [PATCH 1/2] tests: add a wrapper for when systemd is built with ASAN --- test/test-functions | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/test/test-functions b/test/test-functions index 1cefec04f5..951b7e5a89 100644 --- a/test/test-functions +++ b/test/test-functions @@ -21,7 +21,7 @@ if ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then ROOTLIBDIR=/usr/lib/systemd fi -BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln" +BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs" DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find" STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))" @@ -293,6 +293,39 @@ EOF chmod 0755 $_valgrind_wrapper } +create_asan_wrapper() { + local _asan_wrapper=$initdir/$ROOTLIBDIR/systemd-under-asan + ddebug "Create $_asan_wrapper" + cat >$_asan_wrapper <>/etc/systemd/system.conf + +# ASAN and syscall filters aren't compatible with each other. +find / -name '*.service' -type f | xargs sed -i 's/^\\(MemoryDeny\\|SystemCall\\)/#\\1/' + +export ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS:log_path=/systemd.asan.log +exec $ROOTLIBDIR/systemd "\$@" +EOF + + chmod 0755 $_asan_wrapper +} + create_strace_wrapper() { local _strace_wrapper=$initdir/$ROOTLIBDIR/systemd-under-strace ddebug "Create $_strace_wrapper" From 88ed0f261ba8164a689395ddee8b92d00e073515 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Tue, 3 Jul 2018 19:29:42 +0000 Subject: [PATCH 2/2] tests: redirect ASAN reports on journald to a file Otherwise, they will end up in /dev/null. --- test/test-functions | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test-functions b/test/test-functions index 951b7e5a89..1b3d75210f 100644 --- a/test/test-functions +++ b/test/test-functions @@ -319,6 +319,12 @@ echo DefaultEnvironment=\$DEFAULT_ENVIRONMENT >>/etc/systemd/system.conf # ASAN and syscall filters aren't compatible with each other. find / -name '*.service' -type f | xargs sed -i 's/^\\(MemoryDeny\\|SystemCall\\)/#\\1/' +# The redirection of ASAN reports to a file prevents them from ending up in /dev/null. +# But, apparently, sometimes it doesn't work: https://github.com/google/sanitizers/issues/886. +JOURNALD_CONF_DIR=/etc/systemd/system/systemd-journald.service.d +mkdir -p "\$JOURNALD_CONF_DIR" +printf "[Service]\nEnvironment=ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS:log_path=/systemd-journald.asan.log\n" >"\$JOURNALD_CONF_DIR/env.conf" + export ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS:log_path=/systemd.asan.log exec $ROOTLIBDIR/systemd "\$@" EOF