ff6046
From 26b213f1dc3d869bc8b22607b2e1b5f27717ddc1 Mon Sep 17 00:00:00 2001
ff6046
From: Evgeny Vereshchagin <evvers@ya.ru>
ff6046
Date: Thu, 5 Jul 2018 15:14:07 +0000
ff6046
Subject: [PATCH] tests: use the asan wrapper to boot a VM/container if systemd
ff6046
 is built with ASAN
ff6046
ff6046
(cherry picked from commit 016fa3b9e8c3550d49f659c49b5ff4d93337aefe)
ff6046
---
ff6046
 test/test-functions | 8 ++++++--
ff6046
 1 file changed, 6 insertions(+), 2 deletions(-)
ff6046
ff6046
diff --git a/test/test-functions b/test/test-functions
ff6046
index 822136913b..76eef8aa4d 100644
ff6046
--- a/test/test-functions
ff6046
+++ b/test/test-functions
ff6046
@@ -21,6 +21,8 @@ if ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then
ff6046
     ROOTLIBDIR=/usr/lib/systemd
ff6046
 fi
ff6046
 
ff6046
+PATH_TO_INIT=$ROOTLIBDIR/systemd
ff6046
+
ff6046
 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"
ff6046
 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"
ff6046
 
ff6046
@@ -47,6 +49,8 @@ IS_BUILT_WITH_ASAN=$(is_built_with_asan && echo yes || echo no)
ff6046
 
ff6046
 if [[ "$IS_BUILT_WITH_ASAN" = "yes" ]]; then
ff6046
     STRIP_BINARIES=no
ff6046
+    SKIP_INITRD=yes
ff6046
+    PATH_TO_INIT=$ROOTLIBDIR/systemd-under-asan
ff6046
 fi
ff6046
 
ff6046
 function find_qemu_bin() {
ff6046
@@ -142,7 +146,7 @@ KERNEL_APPEND="$PARAMS \
ff6046
 root=/dev/sda1 \
ff6046
 raid=noautodetect \
ff6046
 loglevel=2 \
ff6046
-init=$ROOTLIBDIR/systemd \
ff6046
+init=$PATH_TO_INIT \
ff6046
 console=ttyS0 \
ff6046
 selinux=0 \
ff6046
 printk.devkmsg=on \
ff6046
@@ -186,7 +190,7 @@ $KERNEL_APPEND \
ff6046
 run_nspawn() {
ff6046
     [[ -d /run/systemd/system ]] || return 1
ff6046
 
ff6046
-    local _nspawn_cmd="$BUILD_DIR/systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND"
ff6046
+    local _nspawn_cmd="$BUILD_DIR/systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $PATH_TO_INIT $KERNEL_APPEND"
ff6046
     if [[ "$NSPAWN_TIMEOUT" != "infinity" ]]; then
ff6046
         _nspawn_cmd="timeout --foreground $NSPAWN_TIMEOUT $_nspawn_cmd"
ff6046
     fi