594167
From 332ac78ab1febc89e04dc095bdd2259044f7d6b6 Mon Sep 17 00:00:00 2001
594167
From: Frantisek Sumsal <frantisek@sumsal.cz>
594167
Date: Thu, 7 Jul 2022 14:13:32 +0200
594167
Subject: [PATCH] test: bump the data partition size if we don't strip binaries
594167
594167
so we can run TEST-24 under sanitizers as well.
594167
594167
Also, when at it, use the 'named-fields' sfdisk format to make the code
594167
a bit more descriptive without needing a manual.
594167
594167
(cherry picked from commit 98b27937cb02dac98d8a9f0c48ba677b45df0831)
594167
594167
Related: #2087652
594167
---
594167
 test/test-functions | 23 ++++++++++++++---------
594167
 1 file changed, 14 insertions(+), 9 deletions(-)
594167
594167
diff --git a/test/test-functions b/test/test-functions
594167
index b596ce1382..b0f3b28def 100644
594167
--- a/test/test-functions
594167
+++ b/test/test-functions
594167
@@ -1194,33 +1194,38 @@ create_empty_image() {
594167
         exit 1
594167
     fi
594167
 
594167
-    local size=500
594167
+    # Partition sizes are in MiBs
594167
+    local root_size=500
594167
+    local data_size=50
594167
     if ! get_bool "$NO_BUILD"; then
594167
         if meson configure "${BUILD_DIR:?}" | grep 'static-lib\|standalone-binaries' | awk '{ print $2 }' | grep -q 'true'; then
594167
-            size=$((size+=200))
594167
+            root_size=$((root_size+=200))
594167
         fi
594167
         if meson configure "${BUILD_DIR:?}" | grep 'link-.*-shared' | awk '{ print $2 }' | grep -q 'false'; then
594167
-            size=$((size+=200))
594167
+            root_size=$((root_size+=200))
594167
         fi
594167
         if get_bool "$IS_BUILT_WITH_COVERAGE"; then
594167
-            size=$((size+=250))
594167
+            root_size=$((root_size+=250))
594167
         fi
594167
     fi
594167
     if ! get_bool "$STRIP_BINARIES"; then
594167
-        size=$((4 * size))
594167
+        root_size=$((4 * root_size))
594167
+        data_size=$((2 * data_size))
594167
     fi
594167
 
594167
-    echo "Setting up ${IMAGE_PUBLIC:?} (${size} MB)"
594167
+    echo "Setting up ${IMAGE_PUBLIC:?} (${root_size} MB)"
594167
     rm -f "${IMAGE_PRIVATE:?}" "$IMAGE_PUBLIC"
594167
 
594167
     # Create the blank file to use as a root filesystem
594167
-    truncate -s "${size}M" "$IMAGE_PUBLIC"
594167
+    truncate -s "${root_size}M" "$IMAGE_PUBLIC"
594167
 
594167
     LOOPDEV=$(losetup --show -P -f "$IMAGE_PUBLIC")
594167
     [ -b "$LOOPDEV" ] || return 1
594167
+    # Create two partitions - a root one and a data one (utilized by some tests)
594167
     sfdisk "$LOOPDEV" <
594167
-,$((size - 50))M,L,*
594167
-,
594167
+label: gpt
594167
+type=0FC63DAF-8483-4772-8E79-3D69D8477DE4 name=root size=$((root_size - data_size))M bootable
594167
+type=0FC63DAF-8483-4772-8E79-3D69D8477DE4 name=data
594167
 EOF
594167
 
594167
     udevadm settle