Skip to content

Commit dfdabd4

Browse files
author
Alexandra Iordache
committed
tests: add integ test for SIGBUS/SIGSEGV handling
The test checks that Firecracker logs the appropriate mesage when intercepting the signal. Exit code is not checked because, as the jailer clones into a new pid namespace, it's no longer in the test process' tree and its pid cannot be waited on. Signed-off-by: Alexandra Iordache <[email protected]>
1 parent cb06533 commit dfdabd4

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
"""Tests scenarios for Firecracker signal handling."""
4+
5+
import os
6+
from signal import SIGBUS, SIGSEGV
7+
from time import sleep
8+
9+
import pytest
10+
11+
import host_tools.logging as log_tools
12+
13+
14+
@pytest.mark.parametrize(
15+
"signum",
16+
[SIGBUS, SIGSEGV]
17+
)
18+
def test_sigbus(test_microvm_with_api, signum):
19+
"""Test reboot from guest kernel."""
20+
test_microvm = test_microvm_with_api
21+
test_microvm.spawn()
22+
23+
# We don't need to monitor the memory for this test.
24+
test_microvm.memory_events_queue = None
25+
26+
test_microvm.basic_config()
27+
28+
# Configure logging.
29+
log_fifo_path = os.path.join(test_microvm.path, 'log_fifo')
30+
metrics_fifo_path = os.path.join(test_microvm.path, 'metrics_fifo')
31+
log_fifo = log_tools.Fifo(log_fifo_path)
32+
metrics_fifo = log_tools.Fifo(metrics_fifo_path)
33+
34+
response = test_microvm.logger.put(
35+
log_fifo=test_microvm.create_jailed_resource(log_fifo.path),
36+
metrics_fifo=test_microvm.create_jailed_resource(metrics_fifo.path),
37+
level='Error',
38+
show_level=False,
39+
show_log_origin=False
40+
)
41+
assert test_microvm.api_session.is_status_no_content(response.status_code)
42+
43+
test_microvm.start()
44+
firecracker_pid = int(test_microvm.jailer_clone_pid)
45+
46+
sleep(0.5)
47+
os.kill(firecracker_pid, signum)
48+
49+
msg = 'Shutting down VM after intercepting signal {}'.format(signum)
50+
lines = log_fifo.sequential_reader(3)
51+
assert msg in lines[1]

0 commit comments

Comments
 (0)