From 9a9cc27761c2ce5a5c5ff7e3c57b7d96c162da63 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 25 Jun 2024 10:24:47 +0200 Subject: [PATCH] ci: add small test case for /dev/urandom as source for CopyBlocks= --- test/units/TEST-58-REPART.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/units/TEST-58-REPART.sh b/test/units/TEST-58-REPART.sh index 8a014ac9fb4..fc06fde0ee7 100755 --- a/test/units/TEST-58-REPART.sh +++ b/test/units/TEST-58-REPART.sh @@ -1287,6 +1287,26 @@ testcase_dropped_partitions() { [[ "$(sfdisk -q -l "$image" | grep -c "$image")" -eq 2 ]] } +testcase_urandom() { + local workdir image defs + + workdir="$(mktemp --directory "/tmp/test-repart.urandom.XXXXXXXXXX")" + # shellcheck disable=SC2064 + trap "rm -rf '${workdir:?}'" RETURN + + image="$workdir/image.img" + truncate -s 32M "$image" + + defs="$workdir/defs" + mkdir "$defs" + echo -ne "[Partition]\nType=swap\nCopyBlocks=/dev/urandom\n" >"$defs/10-urandom.conf" + + systemd-repart --empty=force --pretty=yes --dry-run=no --definitions="$defs" "$image" + + sfdisk -q -l "$image" + [[ "$(sfdisk -q -l "$image" | grep -c "$image")" -eq 1 ]] +} + OFFLINE="yes" run_testcases -- 2.47.3