On 03/08/2012 11:52 AM, guyanhua wrote:
>
> This patch adds three test cases for "virsh capabilities" command.
>
> Use three cases:(1) Call virsh capabilities
>                  (2) Call virsh capabilities with an unexpected option
>                  (3) Call virsh capabilities with libvirtd service stop
>
> Signed-off-by: Gu Yanhua<[email protected]>
> ---
>   client/tests/libvirt/tests/virsh_capabilities.py |   51 
> ++++++++++++++++++++++
>   1 files changed, 51 insertions(+), 0 deletions(-)
>   create mode 100644 client/tests/libvirt/tests/virsh_capabilities.py
How to make sure output information of virsh capabilities are correct? 
for example, <cpu>, <power management>, <topology>, <guest> XML block 
information etc.


Thanks,
Alex
> diff --git a/client/tests/libvirt/tests/virsh_capabilities.py 
> b/client/tests/libvirt/tests/virsh_capabilities.py
> new file mode 100644
> index 0000000..ca42b89
> --- /dev/null
> +++ b/client/tests/libvirt/tests/virsh_capabilities.py
> @@ -0,0 +1,51 @@
> +import logging
> +from autotest_lib.client.common_lib import utils, error
> +from autotest_lib.client.virt import libvirt_vm
> +
> +def run_virsh_capabilities(test, params, env):
> +    """
> +    Test the command virsh capabilities
> +
> +    (1) Call virsh capabilities
> +    (2) Call virsh capabilities with an unexpected option
> +    (3) Call virsh capabilities with libvirtd service stop
> +    """
> +    def virsh_capabilities(option):
> +        cmd = "virsh capabilities  %s" % option
> +        cmd_result = utils.run(cmd, ignore_status=True)
> +        logging.info("Output: %s", cmd_result.stdout.strip())
> +        logging.error("Error: %s", cmd_result.stderr.strip())
> +        logging.info("Status: %d", cmd_result.exit_status)
> +        return cmd_result.exit_status, cmd_result.stdout.strip()
> +
> +    # 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")
> +
> +    # Run test case
> +    option = params.get("options")
> +    status, output = virsh_capabilities(option)
> +
> +    # Recover libvirtd service start
> +    if libvirtd == "off":
> +        libvirt_vm.service_libvirtd_control("start")
> +
> +    # Check status_error
> +    status_error = params.get("status_error")
> +    if status_error == "yes":
> +        if status == 0:
> +            if libvirtd == "off":
> +                raise error.TestFail("Command 'virsh capabilities' succeeded\
> +                                      with libvirtd service stopped, 
> incorrect")
> +            else:
> +                raise error.TestFail("Command 'virsh capabilities %s' 
> succeeded"
> +                                 "(incorrect command)" % option)
> +    elif status_error == "no":
> +        if output == "":
> +            raise error.TestFail("virsh capabilities output invalid")
> +        if status != 0:
> +            raise error.TestFail("Command 'virsh capabilities %s' failed "
> +                                 "(correct command)" % option)
> --
> 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

Reply via email to