[Libvirt-cim] [PATCH] [TEST] Initalise status=FAIL in the exception block otherwise it returns a PASS even when there is an exception in the tc

Deepti B Kalakeri deeptik at linux.vnet.ibm.com
Thu Sep 4 09:32:19 UTC 2008


yunguol at cn.ibm.com wrote:
> # HG changeset patch
> # User Guolian Yun <yunguol at cn.ibm.com>
> # Date 1220496411 25200
> # Node ID 2d36d729130e1e0a796a3c25b9ee200cad29a9d4
> # Parent  3c04faaa67e001ecaf578a13da75f88235257576
> [TEST] Initalise status=FAIL in the exception block otherwise it returns a PASS even when there is an exception in the tc
>
> Signed-off-by: Guolian Yun <yunguol at cn.ibm.com>
>
> diff -r 3c04faaa67e0 -r 2d36d729130e suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py
> --- a/suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py	Tue Sep 02 23:10:52 2008 -0700
> +++ b/suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py	Wed Sep 03 19:46:51 2008 -0700
> @@ -27,7 +27,7 @@ from XenKvmLib import enumclass
>  from XenKvmLib import enumclass
>  from VirtLib import live
>  from VirtLib import utils
> -from CimTest import Globals
> +from CimTest.Globals import logger
>  from CimTest.ReturnCodes import PASS, FAIL
>
>  SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC']
> @@ -47,20 +47,22 @@ def main():
>                  idx = live_cs.index(name)
>                  del live_cs[idx]
>              except ValueError, detail:
> -                Globals.logger.error("Provider reports system `%s', \
> +                logger.error("Provider reports system `%s', \
>  but virsh does not" % name)
>   
The above message can be indented as follows.

        logger.error("Provider reports system `%s`',"
                     "but virsh does not", name)



>                  status = FAIL
>
>          for system in live_cs:
> -            Globals.logger.error("Provider does not report system `%s', \
> +            logger.error("Provider does not report system `%s', \
>  but virsh does" % system)
>   
same as above.
>              status = FAIL
>
>      except IndexError, detail:
> -        Globals.logger.error("Exception: %s", detail)
> +        logger.error("Exception: %s", detail)
> +        status = FAIL
>      except Exception, detail:
> -        Globals.logger.error(Globals.CIM_ERROR_ENUMERATE, 'ComputerSystem')
> -        Globals.logger.error("Exception: %s", detail)
> +        logger.error(Globals.CIM_ERROR_ENUMERATE, 'ComputerSystem')
>   
You need to import CIM_ERROR_ENUMERATE or Globals otherwise this will 
fail with python error.
> +        logger.error("Exception: %s", detail)
> +        status = FAIL
>
>      return status
>
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>   




More information about the Libvirt-cim mailing list