Skip to content

Commit f553778

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

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/integration_tests/functional/test_snapshot_basic.py

Lines changed: 36 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
@@ -540,3 +541,38 @@ def test_vmgenid(guest_kernel_linux_6_1, rootfs, microvm_factory, snapshot_type)
540541

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

0 commit comments

Comments
 (0)