<br><tt><font size=2>libvirt-cim-bounces@redhat.com wrote on 2008-07-14
23:14:05:<br>
<br>
> # HG changeset patch<br>
> # User Kaitlin Rupert <karupert@us.ibm.com><br>
> # Date 1216048393 25200<br>
> # Node ID b5d2f6621f5731e5a6508cdd6e7b82bfba0ff9df<br>
> # Parent 463274d67d8f35ac562c5665e561ab970ddc55c1<br>
> [TEST] Fix potiential false positive with HostSystem 01.<br>
> <br>
> This test doesn't verify that exactly one instances was returned <br>
> from the EnumerateInstances() call.<br>
> <br>
> Also, if the EnumerateInstance() call doesn't return any instances,
<br>
> then the test falls through the loop and returns PASS.<br>
> <br>
> Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com><br>
> <br>
> diff -r 463274d67d8f -r b5d2f6621f57 suites/libvirt-<br>
> cim/cimtest/HostSystem/01_enum.py<br>
> --- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Fri
Jul 11 <br>
> 13:04:59 2008 -0700<br>
> +++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Mon
Jul 14 <br>
> 08:13:13 2008 -0700<br>
> @@ -26,13 +26,11 @@<br>
> # and verifies the hostname returned by the provider<br>
> <br>
> import sys<br>
> -from CimTest.Globals import do_main<br>
> from XenKvmLib import hostsystem<br>
> from XenKvmLib.classes import get_typed_class<br>
> from VirtLib import live<br>
> from VirtLib import utils<br>
> -from CimTest import Globals<br>
> -from CimTest.Globals import logger<br>
> +from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, do_main<br>
> from CimTest.ReturnCodes import PASS, FAIL<br>
> <br>
> SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC']<br>
> @@ -40,22 +38,29 @@<br>
> @do_main(SUPPORTED_TYPES)<br>
> def main():<br>
> options = main.options<br>
> - status = PASS<br>
> host = live.hostname(options.ip) <br>
> <br>
> + status = FAIL<br>
> try:<br>
> hs = hostsystem.enumerate(options.ip,
options.virt)<br>
> name = get_typed_class(options.virt,
'HostSystem')<br>
> <br>
> - for system in hs:<br>
> - if system.CreationClassName
!= name and system.Name != host:<br>
> - logger.error("%s
Enumerate Instance error" % name)<br>
> - status =
FAIL<br>
> - else:<br>
> - logger.info("%s
is %s" % (name, host))<br>
> + if len(hs) != 1:<br>
> + logger.error("Expected
1 %s instance returned" % name)<br>
> + return FAIL<br>
> + <br>
> + system = hs[0]<br>
> <br>
> - except BaseException:<br>
> - logger.error(Globals.CIM_ERROR_ENUMERATE
% hostsystem.CIM_System)<br>
> + if system.CreationClassName != name and
system.Name != host:</font></tt>
<br><tt><font size=2> </font></tt>
<br><tt><font size=2> I think either
one fails, we should report error. Maybe we can change it to below:</font></tt>
<br><tt><font size=2> </font></tt>
<br><tt><font size=2> if system.CreationClassName
!= name or system.Name != host:</font></tt>
<br><tt><font size=2> <br>
> + logger.error("Exp
%s, got %s" % (name, system.CreationClassName))<br>
> + logger.error("Exp
%s, got %s" % (host, system.Name))<br>
> + status = FAIL<br>
> + else:<br>
> + logger.info("%s is
%s" % (name, host))<br>
> + status = PASS<br>
> +<br>
> + except Exception, details:<br>
> + logger.error("%s %s: %s" %
(CIM_ERROR_ENUMERATE, name, details))<br>
> status = FAIL<br>
> <br>
> return status<br>
> <br>
> _______________________________________________<br>
> Libvirt-cim mailing list<br>
> Libvirt-cim@redhat.com<br>
> https://www.redhat.com/mailman/listinfo/libvirt-cim<br>
</font></tt>