mirror of
https://github.com/systemd/systemd
synced 2024-10-14 12:04:49 +00:00
repart: Add Minimize= integration test
This commit is contained in:
parent
c4a87b76c3
commit
14697c4156
|
@ -3,6 +3,8 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
TEST_DESCRIPTION="test systemd-repart"
|
TEST_DESCRIPTION="test systemd-repart"
|
||||||
|
IMAGE_NAME="repart"
|
||||||
|
TEST_FORCE_NEWIMAGE=1
|
||||||
|
|
||||||
# shellcheck source=test/test-functions
|
# shellcheck source=test/test-functions
|
||||||
. "$TEST_BASE_DIR/test-functions"
|
. "$TEST_BASE_DIR/test-functions"
|
||||||
|
@ -15,6 +17,7 @@ test_append_files() {
|
||||||
fi
|
fi
|
||||||
instmods dm_verity =md
|
instmods dm_verity =md
|
||||||
generate_module_dependencies
|
generate_module_dependencies
|
||||||
|
image_install -o /sbin/mksquashfs
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1346,6 +1346,9 @@ create_empty_image() {
|
||||||
root_size=$((4 * root_size))
|
root_size=$((4 * root_size))
|
||||||
data_size=$((2 * data_size))
|
data_size=$((2 * data_size))
|
||||||
fi
|
fi
|
||||||
|
if [ "$IMAGE_NAME" = "repart" ]; then
|
||||||
|
root_size=$((root_size+=1000))
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Setting up ${IMAGE_PUBLIC:?} (${root_size} MB)"
|
echo "Setting up ${IMAGE_PUBLIC:?} (${root_size} MB)"
|
||||||
rm -f "${IMAGE_PRIVATE:?}" "$IMAGE_PUBLIC"
|
rm -f "${IMAGE_PRIVATE:?}" "$IMAGE_PUBLIC"
|
||||||
|
|
|
@ -831,6 +831,58 @@ EOF
|
||||||
losetup -d "$loop"
|
losetup -d "$loop"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_minimize() {
|
||||||
|
local defs imgs output
|
||||||
|
|
||||||
|
if systemd-detect-virt --quiet --container; then
|
||||||
|
echo "Skipping minimize test in container."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
defs="$(mktemp --directory "/tmp/test-repart.XXXXXXXXXX")"
|
||||||
|
imgs="$(mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")"
|
||||||
|
# shellcheck disable=SC2064
|
||||||
|
trap "rm -rf '$defs' '$imgs'" RETURN
|
||||||
|
|
||||||
|
for format in ext4 vfat; do
|
||||||
|
if ! command -v "mkfs.$format" >/dev/null; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >"$defs/root-$format.conf" <<EOF
|
||||||
|
[Partition]
|
||||||
|
Type=root-${architecture}
|
||||||
|
Format=${format}
|
||||||
|
CopyFiles=${defs}
|
||||||
|
Minimize=yes
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! command -v mksquashfs >/dev/null; then
|
||||||
|
cat >"$defs/root-squashfs.conf" <<EOF
|
||||||
|
[Partition]
|
||||||
|
Type=root-${architecture}
|
||||||
|
Format=squashfs
|
||||||
|
CopyFiles=${defs}
|
||||||
|
Minimize=yes
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
output=$(systemd-repart --definitions="$defs" \
|
||||||
|
--seed="$seed" \
|
||||||
|
--dry-run=no \
|
||||||
|
--empty=create \
|
||||||
|
--size=auto \
|
||||||
|
--json=pretty \
|
||||||
|
"$imgs/zzz")
|
||||||
|
|
||||||
|
# Check that we can dissect, mount and unmount a minimized image.
|
||||||
|
|
||||||
|
systemd-dissect "$imgs/zzz"
|
||||||
|
systemd-dissect "$imgs/zzz" -M "$imgs/mnt"
|
||||||
|
systemd-dissect -U "$imgs/mnt"
|
||||||
|
}
|
||||||
|
|
||||||
test_sector() {
|
test_sector() {
|
||||||
local defs imgs output loop
|
local defs imgs output loop
|
||||||
local start size ratio
|
local start size ratio
|
||||||
|
@ -900,6 +952,7 @@ test_issue_24553
|
||||||
test_zero_uuid
|
test_zero_uuid
|
||||||
test_verity
|
test_verity
|
||||||
test_issue_24786
|
test_issue_24786
|
||||||
|
test_minimize
|
||||||
|
|
||||||
# Valid block sizes on the Linux block layer are >= 512 and <= PAGE_SIZE, and
|
# 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
|
# must be powers of 2. Which leaves exactly four different ones to test on
|
||||||
|
|
Loading…
Reference in a new issue