diff --git a/test/test_build.py b/test/test_build.py index a3fd6d17e..6aaf575eb 100644 --- a/test/test_build.py +++ b/test/test_build.py @@ -178,7 +178,6 @@ def test_image_is_generated(image_type): f"content: {os.listdir(os.fspath(image_type.img_path))}" -@pytest.mark.skipif(platform.system() != "Linux", reason="boot test only runs on linux right now") @pytest.mark.parametrize("image_type", gen_testcases("direct-boot"), indirect=["image_type"]) def test_image_boots(image_type): with QEMU(image_type.img_path, arch=image_type.img_arch) as test_vm: diff --git a/test/testcases.py b/test/testcases.py index 09e754af2..680d526d9 100644 --- a/test/testcases.py +++ b/test/testcases.py @@ -46,12 +46,12 @@ def gen_testcases(what): ] # do a cross arch test too if platform.machine() == "x86_64": - # todo: add fedora:eln + # todo: add fedora:eln(?) test_cases.append( f'{CONTAINERS_TO_TEST["centos"]},raw,arm64') elif platform.machine() == "arm64": - # TODO: add arm64->x86_64 cross build test too - pass + test_cases.append( + f'{CONTAINERS_TO_TEST["centos"]},raw,amd64') return test_cases elif what == "all": test_cases = [] diff --git a/test/vm.py b/test/vm.py index 43c376363..bd0ccbc76 100644 --- a/test/vm.py +++ b/test/vm.py @@ -1,4 +1,5 @@ import abc +import glob import os import pathlib import platform @@ -83,12 +84,18 @@ def __exit__(self, exc_type, exc_value, traceback): # needed as each distro puts the OVMF.fd in a different location def find_ovmf(): + # linux for p in [ "/usr/share/ovmf/OVMF.fd", # Debian "/usr/share/OVMF/OVMF_CODE.fd", # Fedora ]: if os.path.exists(p): return p + # macos + p = "/opt/homebrew/Cellar/qemu/*/share/qemu/edk2-aarch64-code.fd" + m = glob.glob(p) + if len(m) > 0: + return m[0] raise ValueError("cannot find a OVMF bios") @@ -122,10 +129,18 @@ def _gen_qemu_cmdline(self, snapshot, use_ovmf): elif self._arch in ("amd64", "x86_64"): qemu_cmdline = [ "qemu-system-x86_64", - "-M", "accel=kvm", - # get "illegal instruction" inside the VM otherwise - "-cpu", "host", ] + if platform.machine() == "x86_64": + qemu_cmdline.append([ + "-M", "accel=kvm", + # get "illegal instruction" inside the VM otherwise + "-cpu", "host", + ]) + elif platform.machine() == "arm64": + qemu_cmdline.append([ + "-machine", "q35", + "-cpu", "SkyLake", + ]) if use_ovmf: qemu_cmdline.extend(["-bios", find_ovmf()]) else: