On 02/17/2012 01:42 PM, guyanhua wrote:
> 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 | 46
> +++++++++++++++++++++++++++
> 1 files changed, 46 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..759026e
> --- /dev/null
> +++ b/client/tests/libvirt/tests/virsh_version.py
> @@ -0,0 +1,46 @@
> +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):
> + cmd = "virsh version %s" % option
> + cmd_result = utils.run(cmd, ignore_status=True)
> + logging.info("Output: %s", cmd_result.stdout.strip())
> + logging.info("Error: %s", cmd_result.stderr.strip())
> + logging.info("Status: %d", cmd_result.exit_status)
> + return cmd_result.exit_status
If the actual result is incorrect, but 'virsh version' cmd return 0,
the codes haven't actually checked libvirt and qemu version,
how to make sure the version info are exact?
Regards,
Alex
> +
> + #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
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest