Skip to content

Commit 8d6b26e

Browse files
committed
[tests] Check that BaseVM tracks snapshot totals
1 parent 93ee5a9 commit 8d6b26e

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/test_base_virtual_machine.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -346,4 +346,36 @@ TEST(BaseVMSnapshots, countsCurrentSnapshots)
346346
vm.take_snapshot(specs, "s4", "");
347347
EXPECT_EQ(vm.get_num_snapshots(), 1);
348348
}
349+
350+
TEST(BaseVMSnapshots, countsTotalSnapshots)
351+
{
352+
const mp::VMSpecs specs{};
353+
MockBaseVirtualMachine vm{"mock-vm"};
354+
EXPECT_EQ(vm.get_num_snapshots(), 0);
355+
356+
auto snapshot = std::make_shared<MockSnapshot>();
357+
EXPECT_CALL(vm, make_specific_snapshot(_, _, _, _)).WillRepeatedly(Return(snapshot));
358+
EXPECT_CALL(*snapshot, capture).Times(AnyNumber());
359+
EXPECT_CALL(*snapshot, erase).Times(AnyNumber());
360+
361+
vm.take_snapshot(specs, "s1", "");
362+
vm.take_snapshot(specs, "s2", "");
363+
vm.take_snapshot(specs, "s3", "");
364+
EXPECT_EQ(vm.get_snapshot_count(), 3);
365+
366+
vm.take_snapshot(specs, "s4", "");
367+
vm.take_snapshot(specs, "s5", "");
368+
EXPECT_EQ(vm.get_snapshot_count(), 5);
369+
370+
vm.delete_snapshot("s1");
371+
vm.delete_snapshot("s2");
372+
EXPECT_EQ(vm.get_snapshot_count(), 5);
373+
374+
vm.delete_snapshot("s4");
375+
EXPECT_EQ(vm.get_snapshot_count(), 5);
376+
377+
vm.take_snapshot(specs, "s6", "");
378+
EXPECT_EQ(vm.get_snapshot_count(), 6);
379+
}
380+
349381
} // namespace

0 commit comments

Comments
 (0)