8d419f
From 3e31fc66a206c272e7f73581c5ca752b4439fec3 Mon Sep 17 00:00:00 2001
8d419f
From: Frantisek Sumsal <frantisek@sumsal.cz>
8d419f
Date: Tue, 21 Jun 2022 12:09:35 +0200
8d419f
Subject: [PATCH] test: allow overriding $QEMU_MEM when running w/ ASan
8d419f
8d419f
(cherry picked from commit dc350e78fe66ae8698574202b2e30e5d650219ec)
8d419f
8d419f
Related: #2087652
8d419f
---
8d419f
 test/TEST-36-NUMAPOLICY/test.sh | 2 +-
8d419f
 test/test-functions             | 5 ++---
8d419f
 2 files changed, 3 insertions(+), 4 deletions(-)
8d419f
8d419f
diff --git a/test/TEST-36-NUMAPOLICY/test.sh b/test/TEST-36-NUMAPOLICY/test.sh
8d419f
index 5f38bf1009..7909b1dce3 100755
8d419f
--- a/test/TEST-36-NUMAPOLICY/test.sh
8d419f
+++ b/test/TEST-36-NUMAPOLICY/test.sh
8d419f
@@ -9,7 +9,7 @@ TEST_NO_NSPAWN=1
8d419f
 . "${TEST_BASE_DIR:?}/test-functions"
8d419f
 
8d419f
 if qemu_min_version "5.2.0"; then
8d419f
-    QEMU_OPTIONS="-object memory-backend-ram,id=mem0,size=${QEMU_MEM:?} -numa node,memdev=mem0,nodeid=0"
8d419f
+    QEMU_OPTIONS="-object memory-backend-ram,id=mem0,size=${QEMU_MEM:-512M} -numa node,memdev=mem0,nodeid=0"
8d419f
 else
8d419f
     QEMU_OPTIONS="-numa node,nodeid=0"
8d419f
 fi
8d419f
diff --git a/test/test-functions b/test/test-functions
8d419f
index 079a7249e4..98efd047d7 100644
8d419f
--- a/test/test-functions
8d419f
+++ b/test/test-functions
8d419f
@@ -30,7 +30,6 @@ TIMED_OUT=  # will be 1 after run_* if *_TIMEOUT is set and test timed out
8d419f
 [[ "$LOOKS_LIKE_SUSE" ]] && FSTYPE="${FSTYPE:-btrfs}" || FSTYPE="${FSTYPE:-ext4}"
8d419f
 UNIFIED_CGROUP_HIERARCHY="${UNIFIED_CGROUP_HIERARCHY:-default}"
8d419f
 EFI_MOUNT="${EFI_MOUNT:-$(bootctl -x 2>/dev/null || echo /boot)}"
8d419f
-QEMU_MEM="${QEMU_MEM:-512M}"
8d419f
 # Note that defining a different IMAGE_NAME in a test setup script will only result
8d419f
 # in default.img being copied and renamed. It can then be extended by defining
8d419f
 # a test_append_files() function. The $1 parameter will be the root directory.
8d419f
@@ -255,7 +254,7 @@ if get_bool "$IS_BUILT_WITH_ASAN"; then
8d419f
     STRIP_BINARIES=no
8d419f
     SKIP_INITRD="${SKIP_INITRD:-yes}"
8d419f
     PATH_TO_INIT=$ROOTLIBDIR/systemd-under-asan
8d419f
-    QEMU_MEM="2048M"
8d419f
+    QEMU_MEM="${QEMU_MEM:-2G}"
8d419f
     QEMU_SMP="${QEMU_SMP:-4}"
8d419f
 
8d419f
     # We need to correctly distinguish between gcc's and clang's ASan DSOs.
8d419f
@@ -444,7 +443,7 @@ run_qemu() {
8d419f
     qemu_options+=(
8d419f
         -smp "$QEMU_SMP"
8d419f
         -net none
8d419f
-        -m "$QEMU_MEM"
8d419f
+        -m "${QEMU_MEM:-512M}"
8d419f
         -nographic
8d419f
         -kernel "$KERNEL_BIN"
8d419f
         -drive "format=raw,cache=unsafe,file=$image"