[Libvirt-cim] [PATCH] #2 Cimtest: Check for None return value

Chip Vincent cvincent at linux.vnet.ibm.com
Thu Jun 9 15:12:32 UTC 2011


--------------------------------------------------------------------
NetworkPort - 01_netport.py: PASS
--------------------------------------------------------------------

+1 & pushed.

On 06/08/2011 01:34 PM, Eduardo Lima (Etrunko) wrote:
> # HG changeset patch
> # User Eduardo Lima (Etrunko)<eblima at br.ibm.com>
> # Date 1306960999 10800
> # Node ID df7d1969cedff2ba8cbb6bdd8a465939d815e2bc
> # Parent  f303bd9615f23b8b79c5532dd5489899a13a0f8e
> Cimtest: Check for None return value
>
> Some tests were raising Attribute Exception due to None value returned.
>
> Changes from #1:
>      - Explicitly check for None if value returned from GetInstance()
>
> Signed-off-by: Eduardo Lima (Etrunko)<eblima at br.ibm.com>
>
> diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py
> --- a/suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py	Wed Jun 01 16:44:39 2011 -0300
> +++ b/suites/libvirt-cim/cimtest/LogicalDisk/01_disk.py	Wed Jun 01 17:43:19 2011 -0300
> @@ -57,7 +57,10 @@
>       dev = GetInstance(options.ip, disk, key_list)
>       status = 0
>
> -    if dev.Name != test_dev:
> +    if dev is None:
> +        logger.error("GetInstance() returned None")
> +        status = 1
> +    else if dev.Name != test_dev:
>           logger.error("Name should be `%s' instead of `%s'", test_dev, dev.Name)
>           status = 1
>
> diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/Memory/01_memory.py
> --- a/suites/libvirt-cim/cimtest/Memory/01_memory.py	Wed Jun 01 16:44:39 2011 -0300
> +++ b/suites/libvirt-cim/cimtest/Memory/01_memory.py	Wed Jun 01 17:43:19 2011 -0300
> @@ -56,7 +56,10 @@
>
>       status = 0
>
> -    if dev.ConsumableBlocks>  dev.NumberOfBlocks:
> +    if dev is None:
> +        logger.error("GetInstance() returned None")
> +        status = 1
> +    else if dev.ConsumableBlocks>  dev.NumberOfBlocks:
>           logger.error("ConsumableBlocks should not be larger than NumberOfBlocks")
>           status = 1
>
> diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/NetworkPort/01_netport.py
> --- a/suites/libvirt-cim/cimtest/NetworkPort/01_netport.py	Wed Jun 01 16:44:39 2011 -0300
> +++ b/suites/libvirt-cim/cimtest/NetworkPort/01_netport.py	Wed Jun 01 17:43:19 2011 -0300
> @@ -83,6 +83,11 @@
>           vsxml.undefine(options.ip)
>           return FAIL
>
> +    if dev is None:
> +        logger.error("GetInstance() returned None")
> +        vsxml.undefine(options.ip)
> +        return FAIL
> +
>       if dev.DeviceID == None:
>           logger.error("Error retrieving instance for devid %s", devid)
>           vsxml.undefine(options.ip)
> diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py
> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py	Wed Jun 01 16:44:39 2011 -0300
> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py	Wed Jun 01 17:43:19 2011 -0300
> @@ -47,6 +47,10 @@
>
>       rasds = get_default_rasds(options.ip, options.virt)
>
> +    if not rasds:
> +        logger.error("get_default_rasds() returned None")
> +        return FAIL
> +
>       rasd_list = {}
>
>       for rasd in rasds:
> @@ -56,6 +60,10 @@
>               rasd['AllocationUnits'] = units
>               rasd_list[mrasd_cn] = inst_to_mof(rasd)
>
> +    if mrasd_cn not in rasd_list.keys():
> +        logger.error("Key '%s' not found in dictionary '%s'" % (mrasd_cn, rasd_list))
> +        return FAIL
> +
>       if rasd_list[mrasd_cn] is None:
>           logger.error("Unable to get template MemRASD")
>           return FAIL
> diff -r f303bd9615f2 -r df7d1969cedf suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py
> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py	Wed Jun 01 16:44:39 2011 -0300
> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py	Wed Jun 01 17:43:19 2011 -0300
> @@ -154,7 +154,7 @@
>           logger.error(details)
>           status = FAIL
>
> -    if os.path.exists(addr):
> +    if addr and os.path.exists(addr):
>           os.remove(addr)
>
>       if guest_defined == True:
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim

-- 
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list