Skip to content

Commit bca0979

Browse files
committed
fix: Make test_cmp_full_and_first_diff_mem not cmp file to itself
The Microvm.snapshot_*() functions by default always write the snapshot to the same file system location. This means that full_snapshot.mem and diff_snapshot.mem point to the same path, making the final assert in the test trivially true (as a file is the same as itself - the diff snapshot will have overwritten the full snapshot). The fix is to use a different path for the full snapshot. Signed-off-by: Patrick Roy <[email protected]>
1 parent 695b5bc commit bca0979

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/integration_tests/functional/test_snapshot_basic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,14 @@ def test_cmp_full_and_first_diff_mem(microvm_factory, guest_kernel, rootfs):
257257

258258
logger.info("Create full snapshot.")
259259
# Create full snapshot.
260-
full_snapshot = vm.snapshot_full()
260+
full_snapshot = vm.snapshot_full(mem_path="mem_full")
261261

262262
logger.info("Create diff snapshot.")
263263
# Create diff snapshot.
264264
diff_snapshot = vm.snapshot_diff()
265265

266-
assert filecmp.cmp(full_snapshot.mem, diff_snapshot.mem)
266+
assert full_snapshot.mem != diff_snapshot.mem
267+
assert filecmp.cmp(full_snapshot.mem, diff_snapshot.mem, shallow=False)
267268

268269

269270
def test_negative_postload_api(test_microvm_with_api, microvm_factory):

0 commit comments

Comments
 (0)