diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-12-18 15:11:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-18 15:11:54 +0100 |
commit | a19e7f3101b40900fc49eb0c72d7c77ea181930e (patch) | |
tree | 85a26c984bc5a6a988c6f61c4a813c13020f7eeb /test/test-functions | |
parent | Merge pull request #30150 from poettering/homectl-interactive (diff) | |
parent | test: add basic coverity tests for bootctl (diff) | |
download | systemd-a19e7f3101b40900fc49eb0c72d7c77ea181930e.tar.xz systemd-a19e7f3101b40900fc49eb0c72d7c77ea181930e.zip |
Merge pull request #30321 from yuwata/find-esp
find-esp: gracefully handle btrfs RAID
Diffstat (limited to 'test/test-functions')
-rw-r--r-- | test/test-functions | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/test/test-functions b/test/test-functions index f887346b34..5af7b8cd91 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1198,6 +1198,11 @@ install_lvm() { mkdir -p "${initdir:?}/etc/lvm" } +host_has_btrfs() ( + set -e + modprobe -nv btrfs && command -v mkfs.btrfs && command -v btrfs || return $? +) + install_btrfs() { instmods btrfs # Not all utilities provided by btrfs-progs are listed here; extend the list @@ -1265,6 +1270,11 @@ install_iscsi() { fi } +host_has_mdadm() ( + set -e + command -v mdadm || return $? +) + install_mdadm() { local unit local mdadm_units=( @@ -1278,6 +1288,7 @@ install_mdadm() { system-shutdown/mdadm.shutdown ) + instmods "=md" image_install mdadm mdmon inst_rules 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-assembly.rules 69-md-clustered-confirm-device.rules # Fedora/CentOS/RHEL ships this rule file @@ -1286,6 +1297,10 @@ install_mdadm() { for unit in "${mdadm_units[@]}"; do image_install "${ROOTLIBDIR:?}/$unit" done + + # Disable the mdmonitor service, since it fails if there's no valid email address + # configured in /etc/mdadm.conf, which just unnecessarily pollutes the logs + "${SYSTEMCTL:?}" mask --root "${initdir:?}" mdmonitor.service || : } install_compiled_systemd() { @@ -1597,6 +1612,9 @@ create_empty_image() { # Partition sizes are in MiBs local root_size=768 local data_size=100 + local esp_size=128 + local boot_size=128 + local total= if ! get_bool "$NO_BUILD"; then if meson configure "${BUILD_DIR:?}" | grep 'static-lib\|standalone-binaries' | awk '{ print $2 }' | grep -q 'true'; then root_size=$((root_size + 200)) @@ -1619,28 +1637,44 @@ create_empty_image() { data_size=$((data_size + IMAGE_ADDITIONAL_DATA_SIZE)) fi - echo "Setting up ${IMAGE_PUBLIC:?} (${root_size} MB)" + total=$((root_size + data_size + esp_size + boot_size)) + + echo "Setting up ${IMAGE_PUBLIC:?} (${total} MB)" rm -f "${IMAGE_PRIVATE:?}" "$IMAGE_PUBLIC" # Create the blank file to use as a root filesystem - truncate -s "${root_size}M" "$IMAGE_PUBLIC" + truncate -s "${total}M" "$IMAGE_PUBLIC" LOOPDEV="$(losetup --show -P -f "$IMAGE_PUBLIC")" [[ -b "$LOOPDEV" ]] || return 1 # Create two partitions - a root one and a data one (utilized by some tests) sfdisk "$LOOPDEV" <<EOF label: gpt -type=0FC63DAF-8483-4772-8E79-3D69D8477DE4 name=root size=$((root_size - data_size))M bootable +type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B name=esp size=${esp_size}M +type=0FC63DAF-8483-4772-8E79-3D69D8477DE4 name=root size=${root_size}M bootable +type=BC13C2FF-59E6-4262-A352-B275FD6F7172 name=boot size=${boot_size}M type=0FC63DAF-8483-4772-8E79-3D69D8477DE4 name=data EOF udevadm settle + if ! mkfs -t vfat "${LOOPDEV}p1"; then + dfatal "Failed to mkfs -t vfat ${LOOPDEV}p1" + exit 1 + fi + local label=(-L systemd_boot) # mkfs.reiserfs doesn't know -L. so, use --label instead [[ "$FSTYPE" == "reiserfs" ]] && label=(--label systemd_boot) - if ! mkfs -t "${FSTYPE}" "${label[@]}" "${LOOPDEV}p1" -q; then - dfatal "Failed to mkfs -t ${FSTYPE}" + if ! mkfs -t "${FSTYPE}" "${label[@]}" "${LOOPDEV}p2" -q; then + dfatal "Failed to mkfs -t ${FSTYPE} ${label[*]} ${LOOPDEV}p2 -q" + exit 1 + fi + + local label=(-L xbootldr) + [[ "$FSTYPE" == "reiserfs" ]] && label=(--label xbootldr) + if ! mkfs -t "${FSTYPE}" "${label[@]}" "${LOOPDEV}p3" -q; then + dfatal "Failed to mkfs -t ${FSTYPE} ${label[*]} ${LOOPDEV}p3 -q" exit 1 fi } @@ -1656,7 +1690,7 @@ mount_initdir() { if ! mountpoint -q "${initdir:?}"; then mkdir -p "$initdir" - mount "${LOOPDEV}p1" "$initdir" + mount "${LOOPDEV}p2" "$initdir" TEST_SETUP_CLEANUP_ROOTDIR=1 fi } |