This patch adds three test cases for "virsh version" command.

Use three cases:(1) virsh version
                (2) virsh version with a unexpected option
                (3) virsh version with libvirtd service stop

Signed-off-by: Gu Yanhua <[email protected]>
---
 client/tests/libvirt/tests/virsh_version.py |   45 +++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/libvirt/tests/virsh_version.py

diff --git a/client/tests/libvirt/tests/virsh_version.py 
b/client/tests/libvirt/tests/virsh_version.py
new file mode 100644
index 0000000..b9cfa0e
--- /dev/null
+++ b/client/tests/libvirt/tests/virsh_version.py
@@ -0,0 +1,45 @@
+import re, os, logging, commands
+from autotest_lib.client.common_lib import utils, error
+from autotest_lib.client.virt import virt_vm, virt_utils, virt_env_process, 
libvirt_vm
+
+def run_virsh_version(test, params, env):
+    """
+    Test command: virsh version.
+    """
+
+    #define virsh_version function
+    def virsh_version(option):
+        command = "virsh version  %s" % option
+        status, output = commands.getstatusoutput(command)
+        logging.info("Output: %s", output)
+        logging.info("Status: %d", status)
+        return status
+
+    #prepare libvirtd service
+    check_libvirtd = params.has_key("libvirtd")
+    if check_libvirtd:
+        libvirtd = params.get("libvirtd")
+        if libvirtd == "on":
+            pass
+        elif libvirtd == "off":
+            libvirt_vm.libvirtd_stop()
+
+    #run test case
+    option = params.get("options")
+    status = virsh_version(option)
+
+    #recover libvirtd service start
+    if libvirtd == "on":
+        pass
+    elif libvirtd == "off":
+        libvirt_vm.libvirtd_start()
+
+    #check status_error
+    status_error = params.get("status_error")
+    if status_error == "yes":
+        if status == 0:
+            raise error.TestFail("Run successfully with wrong command!")
+    elif status_error == "no":
+        if status != 0:
+            raise error.TestFail("Run failed with right command")
+
-- 
1.7.1 

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to