From 3e95f9bf08bdeefa54fe0dbddec895bf8d118517 Mon Sep 17 00:00:00 2001 From: Josh Hoffer Date: Thu, 8 Oct 2026 22:35:22 -0700 Subject: [PATCH] test: add repart testcase for --size=auto with foreign partitions Adding a partition with --size=auto to an image whose existing partitions have no definitions used to hit assert(!PARTITION_IS_FOREIGN(p)). Check that the existing partition keeps its UUID and label and the new one is appended. (cherry picked from commit ba56bc4376f24d52479fdf8153132f889a9b00b0) --- test/units/TEST-58-REPART.sh | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/units/TEST-58-REPART.sh b/test/units/TEST-58-REPART.sh index c862c07d2e..326c66e2af 100755 --- a/test/units/TEST-58-REPART.sh +++ b/test/units/TEST-58-REPART.sh @@ -715,6 +715,46 @@ EOF assert_in "$imgs/auto3 : start= 45056, size= 20480, type=${root_guid}," "$output" } +testcase_size_auto_foreign_partitions() { + local defs imgs output + + defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")" + imgs="$(mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")" + # shellcheck disable=SC2064 + trap "rm -rf '$defs' '$imgs'" RETURN + chmod 0755 "$defs" + + echo "*** Adding a partition with --size=auto to an image with foreign partitions ***" + + # --size=auto reloads the partition table, which must not lose the UUID and label of the existing + # partitions that have no definition. + truncate -s 12M "$imgs/foreign.img" + sfdisk "$imgs/foreign.img" <