On 02/14/2012 11:42 PM, guyanhua wrote:
>
>>> +def run_virsh_version(test, params, env):
>>> + """
>>> + Test command: virsh version.
>>> + """
>>> +
>>> + 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
>>
>> ^ Rather than the commands API, I'd like to see here a call to
>> utils.run, since it already is supposed to throw an exception if the
>> command returns exit code != 0, so that you don't have to explicitly
>> check for status and throw TestFail exceptions.
>>
> Hi, I have read the utils.run function and have some problems about this.
> This patch's aim is to test whether the "virsh version"command can be
> used effectively. When we test using a wrong option , it will cause an
> exception but it is right ,we should not throw the exception and stop
> the process. So we return status to judge. if exit code != 0, it is
> ringt,
> otherwise it is wrong.
>
I think both can be correct (using utils.run() and checking exit code in
test). Maybe check the exit code (CmdResult class defined in
client/base_utils.py) w/in an except clause, re-raising the exception*
when it makes sense?
*note: We need to support python 2.4 still, so you can't re-raise with
just 'raise' like in 2.5 :(
--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest