Test Automation: How to simulate power failure/machine crash?

强颜欢笑 提交于 2019-12-19 03:13:23

问题


I have a delphi application that relies on SQLite3, a DB engine that's advertised as crash-proof.

So far I was able to make my whole application crash-proof, but now I need to simulate brutal machine reboot / power failure.

Obviously it would crazy/unpractical to brutally reboot my machine 100 times / per day just to conduct this test, so...

I wonder if there's a way to simulate power failure using VirtualBox (or something similar) programmatically / in an automated fashion?

Any other method/thought would be more than welcome, my goal is to make sure my users' data is never corrupted.

PS. This question is for Windows XP or later


回答1:


Running this on the virtual box host should do the trick

VBoxManage controlvm (vmname) reset/poweroff

VBoxManage controlvm (vmname) reset has the same effect on a virtual machine as pressing the "Reset" button on a real computer: a cold reboot of the virtual machine, which will restart and boot the guest operating system again immediately. The state of the VM is not saved beforehand, and data may be lost. (This is equivalent to selecting the "Reset" item in the "Machine" menu of the GUI.)

VBoxManage controlvm (vmname) poweroff has the same effect on a virtual machine as pulling the power cable on a real computer. Again, the state of the VM is not saved beforehand, and data may be lost. (This is equivalent to selecting the "Close" item in the "Machine" menu of the GUI or pressing the window's close button, and then selecting "Power off the machine" in the dialog.)



来源:https://stackoverflow.com/questions/13910565/test-automation-how-to-simulate-power-failure-machine-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!