<br><font size=2 face="sans-serif">+1) for me</font>
<br>
<br><tt><font size=2>libvirt-cim-bounces@redhat.com wrote on 2008-07-16
00:17:20:<br>
<br>
> # HG changeset patch<br>
> # User Kaitlin Rupert <karupert@us.ibm.com><br>
> # Date 1216138460 25200<br>
> # Node ID aee2bda69644fbf01ec3fbe038ecf6c52d63555a<br>
> # Parent  7e91a4012131a1200f9d25711061a61f009bb4bc<br>
> [TEST] #2 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>
> Updates from 1 to 2:<br>
>   -If either the CreationClassName or Name properties don't match,
<br>
> return a failure.<br>
> <br>
> Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com><br>
> <br>
> diff -r 7e91a4012131 -r aee2bda69644 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   Tue
Jul 15 <br>
> 09:14:20 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 or
system.Name != host:<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>