Skip to content

Commit 0ab122a

Browse files
committed
test: add intergration test for physical counter reset
Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent b5be991 commit 0ab122a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/integration_tests/functional/test_snapshot_basic.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
"""Basic tests scenarios for snapshot save/restore."""
44

5+
import platform
56
import filecmp
67
import logging
78
import os
@@ -11,7 +12,9 @@
1112
from pathlib import Path
1213

1314
import pytest
15+
from framework import utils
1416

17+
import host_tools.cargo_build as host
1518
import host_tools.drive as drive_tools
1619
from framework.microvm import SnapshotType
1720
from framework.utils import check_filesystem, check_output
@@ -29,6 +32,7 @@
2932
# Kernel emits this message when it resumes from a snapshot with VMGenID device
3033
# present
3134
DMESG_VMGENID_RESUME = "random: crng reseeded due to virtual machine fork"
35+
PLATFORM = platform.machine()
3236

3337

3438
def check_vmgenid_update_count(vm, resume_count):
@@ -540,3 +544,41 @@ def test_vmgenid(guest_kernel_linux_6_1, rootfs, microvm_factory, snapshot_type)
540544

541545
# Update the base for next iteration
542546
base_snapshot = snapshot
547+
548+
549+
# @pytest.mark.skipif(
550+
# platform != "aarch64",
551+
# reason="This is aarch64 specific test.",
552+
# )
553+
def test_physical_couter_reset_aarch64(uvm_nano, microvm_factory):
554+
"""
555+
Test that the CNTPCT_EL0 register is reset on VM boot.
556+
Because we cannot read the CNTVCT_EL0 (Virtual counter)
557+
from python, we assume the smallesd VM will not consume more than
558+
MAX_VALUE cycles to be created and snapshotted.
559+
"""
560+
vm = uvm_nano
561+
vm.add_net_iface()
562+
vm.start()
563+
564+
snapshot = vm.snapshot_full()
565+
vm.kill()
566+
snap_editor = host.get_binary("snapshot-editor")
567+
568+
CNTPCT_EL0 = hex(0x603000000013DF01)
569+
MAX_VALUE = 800_000_000
570+
571+
cmd = [
572+
str(snap_editor),
573+
"info-vmstate",
574+
"vcpu-states",
575+
"--vmstate-path",
576+
str(snapshot.vmstate),
577+
]
578+
_, stdout, _ = utils.check_output(cmd)
579+
for line in stdout.splitlines():
580+
s = line.split(" ")
581+
if len(s) == 2:
582+
reg_id, reg_value = line.split(" ")
583+
if reg_id == CNTPCT_EL0:
584+
assert int(reg_value, 16) < MAX_VALUE

0 commit comments

Comments
 (0)