Path: blob/main/tests/integration_tests/functional/test_error_code.py
1958 views
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.1# SPDX-License-Identifier: Apache-2.02"""Tests scenarios for Firecracker kvm exit handling."""34import os5import platform6import pytest7from framework.utils import wait_process_termination8910@pytest.mark.skipif(11platform.machine() != "aarch64",12reason="The error code returned on aarch64 will not be returned on x86 "13"under the same conditions."14)15def test_enosys_error_code(test_microvm_with_initrd):16"""Test that ENOSYS error is caught and firecracker exits gracefully."""17# On aarch64 we trigger this error by adding to initrd a C program that18# maps a file into memory and then tries to load the content from an19# offset in the file bigger than its length into a register asm volatile20# ("ldr %0, [%1], 4" : "=r" (ret), "+r" (buf));21vm = test_microvm_with_initrd22vm.jailer.daemonize = False23vm.spawn()24vm.memory_monitor = None2526vm.initrd_file = os.path.join(vm.path, "fsfiles/", "initrd_enosys.img")27vm.basic_config(28add_root_device=False,29vcpu_count=1,30boot_args='console=ttyS0 reboot=k panic=1 pci=off',31use_initrd=True32)3334vm.start()3536# Check if FC process is closed37wait_process_termination(vm.jailer_clone_pid)3839log_data = vm.log_data40assert "Received ENOSYS error because KVM failed to emulate " \41"an instruction." in log_data42assert "Vmm is stopping." in log_data434445