From b096346252edf98d5427887720476cb0b1fe6cce Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Thu, 24 Aug 2023 15:39:18 +0100 Subject: [PATCH] test: add FreeBSD/PVH boottest Adds a test that attempts to boot a FreeBSD microvm inside of firecracker. FreeBSD boots using PVH, so this is implicitly also a test of the PVH support. Signed-off-by: Patrick Roy --- .../integration_tests/functional/test_pvh.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/integration_tests/functional/test_pvh.py diff --git a/tests/integration_tests/functional/test_pvh.py b/tests/integration_tests/functional/test_pvh.py new file mode 100644 index 000000000000..818f5e0910e6 --- /dev/null +++ b/tests/integration_tests/functional/test_pvh.py @@ -0,0 +1,45 @@ +# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Tests for PVH boot mode""" + +# pylint:disable=redefined-outer-name + +import pytest + +from framework import defs +from framework.artifacts import NetIfaceConfig +from framework.properties import global_props + +pytestmark = pytest.mark.skipif( + global_props.cpu_architecture != "x86_64", reason="x86_64 specific tests" +) + + +@pytest.fixture +def uvm_freebsd(microvm_factory): + """Create a FreeBSD microVM""" + + # Cant use the rootfs_fxt and guest_kernel_fxt, because they only allow us to get supported kernels (and I am + # reluctant to add a freebsd regex to the list of supported kernels) + return microvm_factory.build( + defs.ARTIFACT_DIR / "freebsd/freebsd-kern.bin", + defs.ARTIFACT_DIR / "freebsd/freebsd-rootfs.bin", + ) + + +def test_freebsd_pvh_boot(uvm_freebsd): + """Tries to boot a FreeBSD microVM""" + + freebsd_iface = NetIfaceConfig( + host_ip="10.0.0.1", guest_ip="10.0.0.2", tap_name="tap0", dev_name="eth0" + ) + + uvm_freebsd.spawn() + uvm_freebsd.basic_config(boot_args="vfs.root.mountfrom=ufs:/dev/vtbd0") + uvm_freebsd.add_net_iface(iface=freebsd_iface) + uvm_freebsd.start() + + # TODO: Figure out how to verify that FreeBSD successfully booted, without SSH-ing into it, given the limited + # tooling we have available in the devctr (we cannot SSH into it as the rootfs does not contain SSH keys, + # but automating password-based SSH is seemingly impossible).