test: add reproducer for issue #28225

This commit is contained in:
Yu Watanabe 2023-07-03 12:11:50 +09:00
parent 264668a817
commit beba8f2e1e

View file

@ -1021,6 +1021,86 @@ EOF
systemd-dissect -U "$imgs/mnt"
}
testcase_free_area_calculation() {
local defs imgs output
if ! command -v mksquashfs >/dev/null; then
echo "Skipping free area calculation test without squashfs."
return
fi
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 a+rx "$defs"
# https://github.com/systemd/systemd/issues/28225
echo "*** free area calculation ***"
tee "$defs/00-ESP.conf" <<EOF
[Partition]
Type = esp
Label = ESP
Format = vfat
SizeMinBytes = 128M
SizeMaxBytes = 128M
# Sufficient for testing
CopyFiles = /etc:/
EOF
tee "$defs/10-os.conf" <<EOF
[Partition]
Type = root-${architecture}
Label = test
Format = squashfs
Minimize = best
# Sufficient for testing
CopyFiles = /etc/:/
VerityMatchKey = os
Verity = data
EOF
tee "$defs/11-os-verity.conf" <<EOF
[Partition]
Type = root-${architecture}-verity
Label = test
Minimize = best
VerityMatchKey = os
Verity = hash
EOF
# Set sector size for VFAT to 512 bytes because there will not be enough FAT clusters otherwise
output1=$(SYSTEMD_REPART_MKFS_OPTIONS_VFAT="-S 512" systemd-repart \
--definitions="$defs" \
--seed="$seed" \
--dry-run=no \
--empty=create \
--size=auto \
--sector-size=4096 \
--defer-partitions=esp \
--json=pretty \
"$imgs/zzz")
# FIXME: the second invocation fails.
output2=$(SYSTEMD_REPART_MKFS_OPTIONS_VFAT="-S 512" systemd-repart \
--definitions="$defs" \
--seed="$seed" \
--dry-run=no \
--empty=allow \
--size=auto \
--sector-size=4096 \
--defer-partitions=esp \
--json=pretty \
"$imgs/zzz") || :
}
test_sector() {
local defs imgs output loop
local start size ratio