[Libvirt-cim] [PATCH] [TEST] Fix potiential false positive with HostSystem 01

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Jul 14 15:14:05 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1216048393 25200
# Node ID b5d2f6621f5731e5a6508cdd6e7b82bfba0ff9df
# Parent  463274d67d8f35ac562c5665e561ab970ddc55c1
[TEST] Fix potiential false positive with HostSystem 01.

This test doesn't verify that exactly one instances was returned from the EnumerateInstances() call.

Also, if the EnumerateInstance() call doesn't return any instances, then the test falls through the loop and returns PASS.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 463274d67d8f -r b5d2f6621f57 suites/libvirt-cim/cimtest/HostSystem/01_enum.py
--- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py	Fri Jul 11 13:04:59 2008 -0700
+++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py	Mon Jul 14 08:13:13 2008 -0700
@@ -26,13 +26,11 @@
 # and verifies the hostname returned by the provider
 
 import sys
-from CimTest.Globals import do_main
 from XenKvmLib import hostsystem
 from XenKvmLib.classes import get_typed_class
 from VirtLib import live
 from VirtLib import utils
-from CimTest import Globals
-from CimTest.Globals import logger
+from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, do_main
 from CimTest.ReturnCodes import PASS, FAIL
 
 SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC']
@@ -40,22 +38,29 @@
 @do_main(SUPPORTED_TYPES)
 def main():
     options = main.options
-    status = PASS
     host = live.hostname(options.ip) 
    
+    status = FAIL
     try:
         hs = hostsystem.enumerate(options.ip, options.virt)
         name = get_typed_class(options.virt, 'HostSystem')
         
-        for system in hs:
-            if system.CreationClassName != name and system.Name != host:
-                logger.error("%s Enumerate Instance error" % name)
-                status = FAIL
-            else:
-                logger.info("%s is %s" % (name, host))
+        if len(hs) != 1:
+            logger.error("Expected 1 %s instance returned" % name)
+            return FAIL
+   
+        system = hs[0]
 
-    except BaseException:
-        logger.error(Globals.CIM_ERROR_ENUMERATE % hostsystem.CIM_System)
+        if system.CreationClassName != name and system.Name != host:
+            logger.error("Exp %s, got %s" % (name, system.CreationClassName))
+            logger.error("Exp %s, got %s" % (host, system.Name))
+            status = FAIL
+        else:
+            logger.info("%s is %s" % (name, host))
+            status = PASS
+
+    except Exception, details:
+        logger.error("%s %s: %s" % (CIM_ERROR_ENUMERATE, name, details))
         status = FAIL
 
     return status




More information about the Libvirt-cim mailing list