Skip to content

Commit

Permalink
tests: simplify rootfs fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
pb8o committed Nov 29, 2024
1 parent b6c695d commit 2098015
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
23 changes: 12 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import host_tools.cargo_build as build_tools
from framework import defs, utils
from framework.artifacts import kernel_params, rootfs_params
from framework.artifacts import disks, kernel_params
from framework.microvm import MicroVMFactory
from framework.properties import global_props
from framework.utils_cpu_templates import (
Expand Down Expand Up @@ -354,13 +354,6 @@ def guest_kernel_fxt(request, record_property):
return kernel


def rootfs_fxt(request, record_property):
"""Return all supported rootfs."""
fs = request.param
record_property("rootfs", fs.name)
return fs


# Fixtures for all guest kernels, and specific versions
guest_kernel = pytest.fixture(guest_kernel_fxt, params=kernel_params("vmlinux-*"))
guest_kernel_acpi = pytest.fixture(
Expand All @@ -380,9 +373,17 @@ def rootfs_fxt(request, record_property):
params=kernel_params("vmlinux-6.1*"),
)

# Fixtures for all Ubuntu rootfs, and specific versions
rootfs = pytest.fixture(rootfs_fxt, params=rootfs_params("ubuntu-24*.squashfs"))
rootfs_rw = pytest.fixture(rootfs_fxt, params=rootfs_params("*.ext4"))

@pytest.fixture
def rootfs():
"""Return an Ubuntu 24.04 read-only rootfs"""
return disks("ubuntu-24.04.squashfs")[0]


@pytest.fixture
def rootfs_rw():
"""Return an Ubuntu 24.04 ext4 rootfs"""
return disks("ubuntu-24.04.ext4")[0]


@pytest.fixture
Expand Down
10 changes: 2 additions & 8 deletions tests/framework/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def kernels(glob, artifact_dir: Path = ARTIFACT_DIR) -> Iterator:
break


def disks(glob) -> Iterator:
def disks(glob) -> list:
"""Return supported rootfs"""
yield from sorted(ARTIFACT_DIR.glob(glob))
return sorted(ARTIFACT_DIR.glob(glob))


def kernel_params(
Expand All @@ -57,12 +57,6 @@ def kernel_params(
yield pytest.param(kernel, id=kernel.name)


def rootfs_params(glob="ubuntu-*.squashfs") -> Iterator:
"""Return supported rootfs as pytest parameters"""
for rootfs in disks(glob=glob):
yield pytest.param(rootfs, id=rootfs.name)


@dataclass(frozen=True, repr=True)
class FirecrackerArtifact:
"""Utility class for Firecracker binary artifacts."""
Expand Down

0 comments on commit 2098015

Please sign in to comment.