]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ci: add small test case for /dev/urandom as source for CopyBlocks= 33003/head
authorLennart Poettering <lennart@poettering.net>
Tue, 25 Jun 2024 08:24:47 +0000 (10:24 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 25 Jun 2024 08:24:47 +0000 (10:24 +0200)
test/units/TEST-58-REPART.sh

index 8a014ac9fb43fab771e702699fdc58f636ece70c..fc06fde0ee7f8dc236d1ef10c509f755d12980a7 100755 (executable)
@@ -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