1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-12 08:58:20 +03:00

test: add test case for systemd-repart --seed=random

For issue #34257.

(cherry picked from commit 56d6ebd40468e2a743b39ad7d87b0675bdf9a042)
(cherry picked from commit 69282da9aab90c2dc1e440b04af5b2163779515a)
(cherry picked from commit fbfe769c4553b49640733efc82577cf30b02cd94)
(cherry picked from commit 1211e6c7709681dac4d3f93e54166c2b846e8e73)
(cherry picked from commit 2fa6459cb381b6ed4f0af91631666b7261f24f8f)
This commit is contained in:
Yu Watanabe 2024-09-05 17:58:29 +09:00 committed by Luca Boccassi
parent 648d06616f
commit b268f50e39

View File

@ -914,6 +914,47 @@ EOF
assert_in "${loop}p3 : start= *${start}, size= *${size}, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=DB081670-07AE-48CA-9F5E-813D5E40B976, name=\"linux-generic-2\"" "$output"
}
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 --definitions="$defs" \
--empty=create \
--size=1G \
--dry-run=no \
--seed=random \
--json=pretty \
"$imgs/zzz"
sfdisk -d "$imgs/zzz"
[[ "$(sfdisk -d "$imgs/zzz" | grep -F 'uuid=' | awk '{ print $8 }' | sort -u | wc -l)" == "3" ]]
}
test_basic
test_dropin
test_multiple_definitions
@ -923,6 +964,7 @@ test_issue_21817
test_issue_24553
test_zero_uuid
test_verity
testcase_random_seed
# Valid block sizes on the Linux block layer are >= 512 and <= PAGE_SIZE, and
# must be powers of 2. Which leaves exactly four different ones to test on