diff --git a/tests/integration_tests/test_dirty_pages_after_full_snapshot.py b/tests/integration_tests/test_dirty_pages_after_full_snapshot.py new file mode 100644 index 000000000000..fe4795568832 --- /dev/null +++ b/tests/integration_tests/test_dirty_pages_after_full_snapshot.py @@ -0,0 +1,25 @@ +def test_dirty_pages_after_full_snapshot(uvm_plain): + """ + Test if dirty pages are erased after making a full snapshot of a VM + """ + + vm_mem_size = 128 + uvm = uvm_plain + uvm.spawn() + uvm.basic_config(mem_size_mib=vm_mem_size, track_dirty_pages=True) + uvm.add_net_iface() + uvm.start() + uvm.ssh.run("true") + + snap_full = uvm.snapshot_full(vmstate_path="vmstate_full", mem_path="mem_full") + snap_diff = uvm.snapshot_diff(vmstate_path="vmstate_diff", mem_path="mem_diff") + snap_diff2 = uvm.snapshot_diff(vmstate_path="vmstate_diff2", mem_path="mem_diff2") + + # file size is the same, but the `diff` snapshot is actually a sparse file + assert snap_full.mem.stat().st_size == snap_diff.mem.stat().st_size + + # diff -> diff there should be no differences + assert snap_diff2.mem.stat().st_blocks == 0 + + # full -> diff there should be no differences + assert snap_diff.mem.stat().st_blocks == 0