Skip to content

Commit 9a53cd6

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 e046783 commit 9a53cd6

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
@@ -256,13 +256,14 @@ def test_cmp_full_and_first_diff_mem(microvm_factory, guest_kernel, rootfs):
256256

257257
logger.info("Create full snapshot.")
258258
# Create full snapshot.
259-
full_snapshot = vm.snapshot_full()
259+
full_snapshot = vm.snapshot_full(mem_path="mem_full")
260260

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

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

267268

268269
def test_negative_postload_api(test_microvm_with_api, microvm_factory):

0 commit comments

Comments
 (0)