Path: blob/main/tests/integration_tests/functional/test_rtc.py
1958 views
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.1# SPDX-License-Identifier: Apache-2.02"""Check the well functioning af the RTC device on aarch64 platforms."""3import re4import platform5import pytest67import framework.utils as utils8from host_tools.network import SSHConnection910DMESG_LOG_REGEX = r'rtc-pl031\s+(\d+).rtc: setting system clock to'111213@pytest.mark.skipif(14platform.machine() != "aarch64",15reason="RTC exists only on aarch64."16)17def test_rtc(test_microvm_with_ssh, network_config):18"""Test RTC functionality on aarch64."""19vm = test_microvm_with_ssh20vm.spawn()21vm.memory_monitor = None22vm.basic_config()23_tap, _, _ = vm.ssh_network_config(network_config, '1')2425vm.start()26conn = SSHConnection(vm.ssh_config)2728# check that the kernel creates an rtcpl031 base device.29_, stdout, _ = conn.execute_command("dmesg")30rtc_log = re.findall(DMESG_LOG_REGEX, stdout.read())31assert rtc_log is not None3233_, stdout, _ = conn.execute_command("stat /dev/rtc0")34assert "character special file" in stdout.read()3536_, host_stdout, _ = utils.run_cmd("date +%s")37_, guest_stdout, _ = conn.execute_command("date +%s")38assert abs(int(guest_stdout.read()) - int(host_stdout)) < 5394041