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

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Jul 15 16:17:20 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1216138460 25200
# Node ID aee2bda69644fbf01ec3fbe038ecf6c52d63555a
# Parent  7e91a4012131a1200f9d25711061a61f009bb4bc
[TEST] #2 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.

Updates from 1 to 2:
  -If either the CreationClassName or Name properties don't match, return a failure.

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

diff -r 7e91a4012131 -r aee2bda69644 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	Tue Jul 15 09:14:20 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 or 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