Signed-off-by: Yu Mingfei<[email protected]>
---
libvirt/tests/cfg/virsh_suspend.cfg | 1 +
libvirt/tests/virsh_suspend.py | 23 +++++++++++++----------
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/libvirt/tests/cfg/virsh_suspend.cfg
b/libvirt/tests/cfg/virsh_suspend.cfg
index e53fb7d..d8d30dc 100644
--- a/libvirt/tests/cfg/virsh_suspend.cfg
+++ b/libvirt/tests/cfg/virsh_suspend.cfg
@@ -3,6 +3,7 @@
kill_vm = "yes"
suspend_vm_ref = "name"
suspend_extra = ""
+ start_vm = "yes"
variants:
- normal_test:
status_error = "no"
diff --git a/libvirt/tests/virsh_suspend.py b/libvirt/tests/virsh_suspend.py
index 1dbf922..d40909b 100644
--- a/libvirt/tests/virsh_suspend.py
+++ b/libvirt/tests/virsh_suspend.py
@@ -1,6 +1,7 @@
from autotest.client.shared import error
from virttest import virsh
+
def run_virsh_suspend(test, params, env):
"""
Test command: virsh suspend.
@@ -10,7 +11,7 @@ def run_virsh_suspend(test, params, env):
2.Perform virsh suspend operation.
3.Confirm the test result.
"""
- vm_name = params.get("main_vm", "virt-test-vm1")
+ vm_name = params.get("main_vm")
vm = env.get_vm(vm_name)
domid = vm.get_id()
@@ -20,28 +21,30 @@ def run_virsh_suspend(test, params, env):
extra = params.get("suspend_extra", "")
status_error = params.get("status_error", "no")
- #run test case
+ # Run test case
if vm_ref == "id":
- vm_ref = domid
+ vm_ref = domid
elif vm_ref == "hex_id":
- vm_ref = hex(int(domid.strip()))
+ vm_ref = hex(int(domid.strip()))
elif vm_ref.find("invalid") != -1:
- vm_ref = params.get(vm_ref)
+ vm_ref = params.get(vm_ref)
elif vm_ref == "name":
- vm_ref = "%s %s" % (vm_name, extra)
+ vm_ref = "%s %s" % (vm_name, extra)
elif vm_ref == "uuid":
- vm_ref = domuuid
+ vm_ref = domuuid
- result = virsh.suspend(vm_ref, ignore_status=True)
+ result = virsh.suspend(vm_ref, ignore_status=True, debug=True)
status = result.exit_status
output = result.stdout.strip()
err = result.stderr.strip()
if status == 0 and not vm.is_paused():
status = 1
- #check status_error
+ # Check result
if status_error == "yes":
- if status == 0 or err == "":
+ if not err:
+ raise error.TestFail("No error hint to user about bad command!")
+ if status == 0:
raise error.TestFail("Run successfully with wrong command!")
elif status_error == "no":
if status != 0 or output == "":
-- 1.7.11.7
--
Best Regards
Yu Mingfei
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel