test: add test case for systemd-repart --seed=random
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 5 Sep 2024 08:58:29 +0000 (17:58 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 5 Sep 2024 09:01:42 +0000 (18:01 +0900)
For issue #34257.

test/units/TEST-58-REPART.sh

index b2a3be686cab31034272d6b0a6f433a421d8a044..6110dc4e5295402083a5405bb012024990d2e7de 100755 (executable)
@@ -1347,6 +1347,49 @@ EOF
     done
 }
 
+testcase_random_seed() {
+    local defs imgs output
+
+    # For issue #34257
+
+    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"
+
+    tee "$defs/root.conf" <<EOF
+[Partition]
+Type=root
+EOF
+
+    tee "$defs/home.conf" <<EOF
+[Partition]
+Type=home
+Label=home-first
+EOF
+
+    tee "$defs/swap.conf" <<EOF
+[Partition]
+Type=swap
+SizeMaxBytes=64M
+PaddingMinBytes=92M
+EOF
+
+    systemd-repart --offline="$OFFLINE" \
+                   --definitions="$defs" \
+                   --empty=create \
+                   --size=1G \
+                   --dry-run=no \
+                   --seed=random \
+                   --offline="$OFFLINE" \
+                   --json=pretty \
+                   "$imgs/zzz"
+
+    sfdisk -d "$imgs/zzz"
+    [[ "$(sfdisk -d "$imgs/zzz" | grep -F 'uuid=' | awk '{ print $8 }' | sort -u | wc -l)" == "3" ]]
+}
+
 OFFLINE="yes"
 run_testcases