Skip to content

Commit aeb1754

Browse files
committed
test: generalize initrd test
Run it with all supported guest kernels, and handle the huge page configuration via pytest parametrization, so that we do not have the same test twice. Signed-off-by: Patrick Roy <[email protected]>
1 parent acf806d commit aeb1754

File tree

3 files changed

+18
-42
lines changed

3 files changed

+18
-42
lines changed

tests/conftest.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -498,20 +498,6 @@ def uvm_plain_debug(microvm_factory, guest_kernel_6_1_debug, rootfs_rw):
498498
return microvm_factory.build(guest_kernel_6_1_debug, rootfs_rw)
499499

500500

501-
@pytest.fixture
502-
def uvm_with_initrd(
503-
microvm_factory, guest_kernel_linux_5_10, record_property, artifact_dir
504-
):
505-
"""
506-
See file:../docs/initrd.md
507-
"""
508-
fs = artifact_dir / "initramfs.cpio"
509-
record_property("rootfs", fs.name)
510-
uvm = microvm_factory.build(guest_kernel_linux_5_10)
511-
uvm.initrd_file = fs
512-
yield uvm
513-
514-
515501
@pytest.fixture
516502
def vcpu_count():
517503
"""Return default vcpu_count. Use indirect parametrization to override."""

tests/integration_tests/performance/test_huge_pages.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
import pytest
88

99
from framework import utils
10-
from framework.microvm import HugePagesConfig, Serial
10+
from framework.microvm import HugePagesConfig
1111
from framework.properties import global_props
1212
from framework.utils_ftrace import ftrace_events
13-
from integration_tests.functional.test_initrd import INITRD_FILESYSTEM
1413
from integration_tests.functional.test_uffd import SOCKET_PATH, spawn_pf_handler
1514

1615

@@ -252,27 +251,3 @@ def test_negative_huge_pages_plus_balloon(uvm_plain):
252251
match="Machine config error: Firecracker's huge pages support is incompatible with memory ballooning.",
253252
):
254253
uvm_plain.basic_config(huge_pages=HugePagesConfig.HUGETLBFS_2MB)
255-
256-
257-
def test_negative_huge_pages_plus_initrd(uvm_with_initrd):
258-
"""Tests that huge pages and initrd cannot be used together"""
259-
uvm_with_initrd.jailer.daemonize = False
260-
uvm_with_initrd.spawn()
261-
uvm_with_initrd.memory_monitor = None
262-
263-
# `basic_config` first does a PUT to /machine-config, which will apply the huge pages configuration,
264-
# and then a PUT to /boot-source, which will register the initrd
265-
uvm_with_initrd.basic_config(
266-
boot_args="console=ttyS0 reboot=k panic=1 pci=off",
267-
use_initrd=True,
268-
huge_pages=HugePagesConfig.HUGETLBFS_2MB,
269-
add_root_device=False,
270-
vcpu_count=1,
271-
)
272-
273-
uvm_with_initrd.start()
274-
serial = Serial(uvm_with_initrd)
275-
serial.open()
276-
serial.rx(token="# ")
277-
serial.tx("mount |grep rootfs")
278-
serial.rx(token=f"rootfs on / type {INITRD_FILESYSTEM}")

tests/integration_tests/functional/test_initrd.py renamed to tests/integration_tests/performance/test_initrd.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
"""Tests for initrd."""
4+
import pytest
45

5-
from framework.microvm import Serial
6+
from framework.microvm import HugePagesConfig, Serial
67

78
INITRD_FILESYSTEM = "rootfs"
89

910

10-
def test_microvm_initrd_with_serial(uvm_with_initrd):
11+
@pytest.fixture
12+
def uvm_with_initrd(microvm_factory, guest_kernel, record_property, artifact_dir):
13+
"""
14+
See file:../docs/initrd.md
15+
"""
16+
fs = artifact_dir / "initramfs.cpio"
17+
record_property("rootfs", fs.name)
18+
uvm = microvm_factory.build(guest_kernel)
19+
uvm.initrd_file = fs
20+
yield uvm
21+
22+
23+
@pytest.mark.parametrize("huge_pages", HugePagesConfig)
24+
def test_microvm_initrd_with_serial(uvm_with_initrd, huge_pages):
1125
"""
1226
Test that a boot using initrd successfully loads the root filesystem.
1327
"""
@@ -21,6 +35,7 @@ def test_microvm_initrd_with_serial(uvm_with_initrd):
2135
vcpu_count=1,
2236
boot_args="console=ttyS0 reboot=k panic=1 pci=off",
2337
use_initrd=True,
38+
huge_pages=huge_pages,
2439
)
2540

2641
vm.start()

0 commit comments

Comments
 (0)