virsh freecell has libvirt=on & libvirt=off as the main variants and hence
evey test under freecell will include either on of them as the parameter.
Hence while preparing libvirt service for every test, this check can be
avoided.
# Prepare libvirtd service
check_libvirtd = params.has_key("libvirtd")
if check_libvirtd:
Params will always have either libvirtd as on or off as variants show
below in subtests.cfg.sample
variants:
- libvirton:
libvirtd = "on"
- libvirtoff:
libvirtd = "off"
status_error = "yes"
Cleaning up to avoid the unnecessary check and introducing a check to
see the status of libvirt daemon and if its not running, will start the
service on "libvirtd = on" variant.
Signed-off-by: Prem Karat <[email protected]>
---
client/tests/virt/libvirt/tests/virsh_freecell.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/client/tests/virt/libvirt/tests/virsh_freecell.py
b/client/tests/virt/libvirt/tests/virsh_freecell.py
index 6f8d2e8..81a8fa0 100644
--- a/client/tests/virt/libvirt/tests/virsh_freecell.py
+++ b/client/tests/virt/libvirt/tests/virsh_freecell.py
@@ -17,12 +17,15 @@ def run_virsh_freecell(test, params, env):
"default") )
option = params.get("virsh_freecell_options")
- # Prepare libvirtd service
- check_libvirtd = params.has_key("libvirtd")
- if check_libvirtd:
- libvirtd = params.get("libvirtd")
- if libvirtd == "off":
- libvirt_vm.service_libvirtd_control("stop")
+ # Prepare libvirtd service. Check if libvirtd daemon is
+ # running before running the command. There could be
+ # situation that libvirtd is stopped by external factors.
+ # If its stopped, start it when param libvirtd = on
+ libvirtd = params.get("libvirtd")
+ if libvirtd == "off":
+ libvirt_vm.service_libvirtd_control("stop")
+ elif not libvirt_vm.service_libvirtd_control("status"):
+ libvirt_vm.service_libvirtd_control("start")
# Run test case
cmd_result = virsh.freecell(ignore_status=True, extra=option,
--
1.7.10.4
--
-prem
_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel