于 2012-2-23 16:32, Alex Jia 写道:
> On 02/23/2012 11:44 AM, guyanhua wrote:
>> This patch adds three test cases for "virsh hostname" command.
>>
>> Use three cases:(1) virsh hostname
>> (2) virsh hostname with an unexpected option
>> (3) virsh hostname with libvirtd service stop
>>
>> Signed-off-by: Gu Yanhua<[email protected]>
>> ---
>> client/tests/libvirt/tests/virsh_hostname.py | 45
>> ++++++++++++++++++++++++++
>> 1 files changed, 45 insertions(+), 0 deletions(-)
>> create mode 100644 client/tests/libvirt/tests/virsh_hostname.py
>>
>> diff --git a/client/tests/libvirt/tests/virsh_hostname.py
>> b/client/tests/libvirt/tests/virsh_hostname.py
>> new file mode 100644
>> index 0000000..f8e59ed
>> --- /dev/null
>> +++ b/client/tests/libvirt/tests/virsh_hostname.py
>> @@ -0,0 +1,45 @@
>> +import logging
>> +from autotest_lib.client.common_lib import utils, error
>> +from autotest_lib.client.virt import libvirt_vm
>> +
>> +def run_virsh_hostname(test, params, env):
>> + """
>> + Test the command virsh hostname
>> +
>> + (1) Call virsh hostname
>> + (2) Call virsh hostname with an unexpected option
>> + (3) Call virsh hostname with libvirtd service stop
>> + """
>> + def virsh_hostname(option):
>> + cmd = "virsh hostname %s" % option
>> + cmd_result = utils.run(cmd, ignore_status=True)
>> + logging.debug("Output: %s", cmd_result.stdout.strip())
>> + logging.debug("Error: %s", cmd_result.stderr.strip())
>> + logging.debug("Status: %d", cmd_result.exit_status)
>> + return cmd_result.exit_status
> I haven't found any actually check on host except virsh cmd return value.

Your comments have been followed. And a patch set v2 has been sent.
Please comment, Thanks.


>
> Regards,
> Alex
>> +
>> + # Prepare libvirtd service
>> + check_libvirtd = params.has_key("libvirtd")
>> + if check_libvirtd:
>> + libvirtd = params.get("libvirtd")
>> + if libvirtd == "off":
>> + libvirt_vm.libvirtd_stop()
>> +
>> + # Run test case
>> + option = params.get("options")
>> + status = virsh_hostname(option)
>> +
>> + # Recover libvirtd service start
>> + if 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("Command 'virsh hostname %s' succeeded "
>> + "(incorrect command)" % option)
>> + elif status_error == "no":
>> + if status != 0:
>> + raise error.TestFail("Command 'virsh hostname %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