[Libvirt-cim] [PATCH 2 of 3] [TEST] #2 Add compare_all_prop()

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


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1215806699 25200
# Node ID 30509a2ca9f2c68bf925f0d5fa2a3a65c602073f
# Parent  7ea2f4ed91cd8b69bc0b8c34304cf3ef870a1b05
[TEST] #2 Add compare_all_prop().

This function takes an instance from the list returned bu the Associators() call and an instance from a getInstance() / enumerate_instances() call.  It compares all of the property values to ensure the instances are identical.

This function could probably be added to a fair number of tests as an additional verification check.

Updates from 1 to 2:
  -Added logger import statement
  -Included FAIL in the ReturnCodes import.
  -Tested failure path to be sure error message is logged and FAIL is returned properly.


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

diff -r 7ea2f4ed91cd -r 30509a2ca9f2 suites/libvirt-cim/lib/XenKvmLib/assoc.py
--- a/suites/libvirt-cim/lib/XenKvmLib/assoc.py	Thu Jun 05 19:28:30 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/assoc.py	Fri Jul 11 13:04:59 2008 -0700
@@ -27,6 +27,8 @@
 import pywbem
 from pywbem.cim_obj import CIMInstanceName
 from XenKvmLib.classes import get_typed_class
+from CimTest.ReturnCodes import PASS, FAIL
+from CimTest.Globals import logger
 
 def AssociatorNames(host, basetype, baseobj, virt="Xen", **keys):
     '''Resolve the association specified by @type, given the
@@ -139,3 +141,17 @@
 
     return new_list
 
+def compare_all_prop(inst, exp_inst):
+    prop_vals = inst.items()
+
+    for i in range(0, len(prop_vals)):
+        key = prop_vals[i][0]
+        val = eval('exp_inst.' + key)
+
+        if prop_vals[i][1] != val:
+            logger.error("%s val mismatch: got %s, expected %s" % (key,
+                         prop_vals[i][1], val))
+            return FAIL
+
+    return PASS
+




More information about the Libvirt-cim mailing list