Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/firecracker
Path: blob/main/tests/integration_tests/functional/test_rtc.py
1958 views
1
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
# SPDX-License-Identifier: Apache-2.0
3
"""Check the well functioning af the RTC device on aarch64 platforms."""
4
import re
5
import platform
6
import pytest
7
8
import framework.utils as utils
9
from host_tools.network import SSHConnection
10
11
DMESG_LOG_REGEX = r'rtc-pl031\s+(\d+).rtc: setting system clock to'
12
13
14
@pytest.mark.skipif(
15
platform.machine() != "aarch64",
16
reason="RTC exists only on aarch64."
17
)
18
def test_rtc(test_microvm_with_ssh, network_config):
19
"""Test RTC functionality on aarch64."""
20
vm = test_microvm_with_ssh
21
vm.spawn()
22
vm.memory_monitor = None
23
vm.basic_config()
24
_tap, _, _ = vm.ssh_network_config(network_config, '1')
25
26
vm.start()
27
conn = SSHConnection(vm.ssh_config)
28
29
# check that the kernel creates an rtcpl031 base device.
30
_, stdout, _ = conn.execute_command("dmesg")
31
rtc_log = re.findall(DMESG_LOG_REGEX, stdout.read())
32
assert rtc_log is not None
33
34
_, stdout, _ = conn.execute_command("stat /dev/rtc0")
35
assert "character special file" in stdout.read()
36
37
_, host_stdout, _ = utils.run_cmd("date +%s")
38
_, guest_stdout, _ = conn.execute_command("date +%s")
39
assert abs(int(guest_stdout.read()) - int(host_stdout)) < 5
40
41