From ce3237e5189c50719f96710f11bfc0bd67352055 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 | 43 +++++++++++++++++++ 1 file changed, 43 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..b7998f78fb5f --- /dev/null +++ b/tests/integration_tests/functional/test_pvh.py @@ -0,0 +1,43 @@ +# 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() + + uvm_freebsd.ssh.run("true")