Skip to content

Commit 29c2b1a

Browse files
committed
test(virtio-mem): add integ test to verify device is detected
Check that the driver correctly detects the virtio-mem device, with the correct parameters. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent 1c9e948 commit 29c2b1a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""Tests for verifying the virtio-mem is working correctly"""
5+
6+
7+
def test_virtio_mem_detected(uvm_plain_6_1):
8+
"""
9+
Check that the guest kernel has enabled PV steal time.
10+
"""
11+
uvm = uvm_plain_6_1
12+
uvm.spawn()
13+
uvm.memory_monitor = None
14+
uvm.basic_config(
15+
boot_args="console=ttyS0 reboot=k panic=1 memhp_default_state=online_movable"
16+
)
17+
uvm.add_net_iface()
18+
uvm.api.memory_hotplug.put(total_size_mib=1024)
19+
uvm.start()
20+
21+
_, stdout, _ = uvm.ssh.check_output("dmesg | grep 'virtio_mem'")
22+
for line in stdout.splitlines():
23+
_, key, value = line.strip().split(":")
24+
key = key.strip()
25+
value = int(value.strip(), base=0)
26+
match key:
27+
case "start address":
28+
assert value == (512 << 30), "start address doesn't match"
29+
case "region size":
30+
assert value == 1024 << 20, "region size doesn't match"
31+
case "device block size":
32+
assert value == 2 << 20, "block size doesn't match"
33+
case "plugged size":
34+
assert value == 0, "plugged size doesn't match"
35+
case "requested size":
36+
assert value == 0, "requested size doesn't match"
37+
case _:
38+
continue

0 commit comments

Comments
 (0)