#!/usr/bin/env bash # SPDX-License-Identifier: LGPL-2.1-or-later set -eux set -o pipefail if systemd-detect-virt --quiet --container; then echo "running on container, skipping." exit 0 fi if ! command -v bootctl >/dev/null; then echo "bootctl not found, skipping." exit 0 fi if [[ ! -d /usr/lib/systemd/boot/efi ]]; then echo "sd-boot is not installed, skipping." exit 0 fi # shellcheck source=test/units/util.sh . "$(dirname "$0")"/util.sh # shellcheck source=test/units/test-control.sh . "$(dirname "$0")"/test-control.sh basic_tests() { bootctl "$@" --help bootctl "$@" --version bootctl "$@" install --make-entry-directory=yes bootctl "$@" remove --make-entry-directory=yes bootctl "$@" install --all-architectures bootctl "$@" remove --all-architectures bootctl "$@" install --make-entry-directory=yes --all-architectures bootctl "$@" remove --make-entry-directory=yes --all-architectures bootctl "$@" install (! bootctl "$@" update) bootctl "$@" update --graceful bootctl "$@" is-installed bootctl "$@" is-installed --graceful bootctl "$@" random-seed bootctl "$@" bootctl "$@" status bootctl "$@" status --quiet bootctl "$@" list bootctl "$@" list --quiet bootctl "$@" list --json=short bootctl "$@" list --json=pretty bootctl "$@" remove (! bootctl "$@" is-installed) (! bootctl "$@" is-installed --graceful) } testcase_bootctl_basic() { assert_eq "$(bootctl --print-esp-path)" "/efi" assert_eq "$(bootctl --print-boot-path)" "/boot" bootctl --print-root-device basic_tests } cleanup_image() ( set +e if [[ -z "${IMAGE_DIR:-}" ]]; then return 0 fi umount "${IMAGE_DIR}/root" if [[ -n "${LOOPDEV:-}" ]]; then losetup -d "${LOOPDEV}" unset LOOPDEV fi udevadm settle rm -rf "${IMAGE_DIR}" unset IMAGE_DIR return 0 ) testcase_bootctl_image() { IMAGE_DIR="$(mktemp --directory /tmp/test-bootctl.XXXXXXXXXX)" trap cleanup_image RETURN truncate -s 256m "${IMAGE_DIR}/image" cat >"${IMAGE_DIR}/partscript" </dev/null; then echo "mdadm not found, skipping." return 0 fi if ! command -v mkfs.btrfs >/dev/null; then echo "mkfs.btrfs not found, skipping." return 0 fi IMAGE_DIR="$(mktemp --directory /tmp/test-bootctl.XXXXXXXXXX)" trap cleanup_raid RETURN truncate -s 256m "${IMAGE_DIR}/image1" truncate -s 256m "${IMAGE_DIR}/image2" cat >"${IMAGE_DIR}/partscript" <