Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/firecracker
Path: blob/main/tests/integration_tests/functional/test_error_code.py
1958 views
1
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
# SPDX-License-Identifier: Apache-2.0
3
"""Tests scenarios for Firecracker kvm exit handling."""
4
5
import os
6
import platform
7
import pytest
8
from framework.utils import wait_process_termination
9
10
11
@pytest.mark.skipif(
12
platform.machine() != "aarch64",
13
reason="The error code returned on aarch64 will not be returned on x86 "
14
"under the same conditions."
15
)
16
def test_enosys_error_code(test_microvm_with_initrd):
17
"""Test that ENOSYS error is caught and firecracker exits gracefully."""
18
# On aarch64 we trigger this error by adding to initrd a C program that
19
# maps a file into memory and then tries to load the content from an
20
# offset in the file bigger than its length into a register asm volatile
21
# ("ldr %0, [%1], 4" : "=r" (ret), "+r" (buf));
22
vm = test_microvm_with_initrd
23
vm.jailer.daemonize = False
24
vm.spawn()
25
vm.memory_monitor = None
26
27
vm.initrd_file = os.path.join(vm.path, "fsfiles/", "initrd_enosys.img")
28
vm.basic_config(
29
add_root_device=False,
30
vcpu_count=1,
31
boot_args='console=ttyS0 reboot=k panic=1 pci=off',
32
use_initrd=True
33
)
34
35
vm.start()
36
37
# Check if FC process is closed
38
wait_process_termination(vm.jailer_clone_pid)
39
40
log_data = vm.log_data
41
assert "Received ENOSYS error because KVM failed to emulate " \
42
"an instruction." in log_data
43
assert "Vmm is stopping." in log_data
44
45