Let's reduce the amount of duplication in the tests.
/usr/lib/kernel/install.d/50-dracut.install
# Make sure that SELinux doesn't run in enforcing mode even if it's pulled in as a dependency.
-KernelCommandLine=enforcing=0
+KernelCommandLine=
+ enforcing=0
+ systemd.log_ratelimit_kmsg=0
+ systemd.crash_shell
+ printk.devkmsg=on
+ systemd.early_core_pattern=/core
KernelModulesInitrdExclude=.*
KernelModulesInitrdInclude=default
import pytest
-from mkosi.config import finalize_term
from mkosi.distributions import Distribution
from mkosi.run import run
from mkosi.types import _FILE, CompletedProcess, PathString
check: bool = True,
) -> CompletedProcess:
kcl = [
- f"TERM={finalize_term()}",
"loglevel=6",
- "systemd.crash_shell",
"systemd.log_level=debug",
"udev.log_level=info",
- "systemd.log_ratelimit_kmsg=0",
"systemd.show_status=false",
"systemd.journald.forward_to_console",
"systemd.journald.max_level_console=info",
- "printk.devkmsg=on",
- "systemd.early_core_pattern=/core",
"systemd.firstboot=no",
+ "systemd.unit=mkosi-check-and-shutdown.service",
]
return run([
else []
),
*(["--tools-tree-release", self.config.tools_tree_release] if self.config.tools_tree_release else []),
+ "--incremental",
+ "--ephemeral",
+ "--runtime-build-sources=no",
*self.options,
*options,
"--output-dir", self.output_dir,
- # Some tests ignore the default image config but we still want them to reuse the cache directory for the
- # tools tree cache.
- "--cache-dir", "mkosi.cache",
*(f"--kernel-command-line={i}" for i in kcl),
"--qemu-vsock=yes",
# TODO: Drop once both Hyper-V bugs are fixed in Github Actions.
@pytest.mark.parametrize("format", [f for f in OutputFormat if f not in (OutputFormat.confext, OutputFormat.sysext)])
def test_format(config: ImageConfig, format: OutputFormat) -> None:
- with Image(
- config,
- options=[
- "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
- "--incremental",
- "--ephemeral",
- ],
- ) as image:
+ with Image(config) as image:
if image.config.distribution == Distribution.rhel_ubi and format in (OutputFormat.esp, OutputFormat.uki):
pytest.skip("Cannot build RHEL-UBI images with format 'esp' or 'uki'")
with Image(
config,
options=[
- "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
- "--incremental",
- "--ephemeral",
"--format=disk",
"--bootloader", str(bootloader),
"--qemu-firmware", str(firmware)
def test_initrd(config: ImageConfig) -> None:
- with Image(
- config,
- options=[
- "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
- "--incremental",
- "--ephemeral",
- "--format=disk",
- ]
- ) as image:
+ with Image(config, options=["--format=disk"]) as image:
image.build()
image.qemu()
with Image(
config,
options=[
- "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
# LVM confuses systemd-repart so we mask it for this test.
"--kernel-command-line=systemd.mask=systemd-repart.service",
"--kernel-command-line=root=LABEL=root",
- "--kernel-command-line=rw",
- "--incremental",
- "--ephemeral",
"--qemu-firmware=linux",
]
) as image, contextlib.ExitStack() as stack:
options=[
"--repart-dir", repartd,
"--passphrase", passphrase,
- "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
"--credential=cryptsetup.passphrase=mkosi",
- "--incremental",
- "--ephemeral",
"--format=disk",
]
) as image:
with Image(
config,
options=[
- "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
"--kernel-command-line=root=LABEL=root",
- "--kernel-command-line=rw",
"--credential=cryptsetup.passphrase=mkosi",
- "--incremental",
- "--ephemeral",
"--qemu-firmware=linux",
]
) as image, contextlib.ExitStack() as stack:
def test_initrd_size(config: ImageConfig) -> None:
- with Image(
- config,
- options=["--incremental", "--format=directory"],
- ) as image:
+ with Image(config) as image:
image.build()
# The fallback value is for CentOS and related distributions.
with Image(
config,
options=[
- "--incremental",
"--clean-package-metadata=no",
"--format=directory",
],
image.config,
options=[
"--directory", "",
+ "--incremental=no",
"--base-tree", Path(image.output_dir) / "image",
"--overlay",
"--package=dnsmasq",