# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1207032270 -19800
# Node ID 37958b18d9a91b23b833248f29e5edc6ab74144b
# Parent 5d47437104551b638aa75e2e525e49ec4b41e3ec
[TEST][Addition] : Adding check_len() function to verify the lenght of the association,
list etc.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 5d4743710455 -r 37958b18d9a9 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Mar 31 07:54:19 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Apr 01 12:14:30 2008 +0530
@@ -187,3 +187,21 @@ def try_getinstance(conn, classname, key
'%s' passed.", classname, field_name)
return XFAIL_RC(bug_no)
+def check_len(an, assoc_list_info, qcn, crit='eq', exp_len=0):
+ if crit == 'ne':
+ expr = 'len(assoc_list_info) != exp_len'
+ elif crit == 'eq':
+ expr = 'len(assoc_list_info) == exp_len'
+ elif crit == 'lt':
+ expr = 'len(assoc_list_info) < exp_len'
+ elif crit == 'gt':
+ expr = 'len(assoc_list_info) > exp_len'
+ elif crit == 'le':
+ expr = 'len(assoc_list_info) <= exp_len'
+ else:
+ expr = 'len(assoc_list_info) <= exp_len'
+ if eval(expr) :
+ logger.error("%s returned %i %s objects, as compared with %i" % (an,
len(assoc_list_info), qcn, exp_len))
+ return FAIL
+ return PASS
+
Show replies by date
DK> +def check_len(an, assoc_list_info, qcn, crit='eq', exp_len=0):
DK> + if crit == 'ne':
DK> + expr = 'len(assoc_list_info) != exp_len'
DK> + elif crit == 'eq':
DK> + expr = 'len(assoc_list_info) == exp_len'
DK> + elif crit == 'lt':
DK> + expr = 'len(assoc_list_info) < exp_len'
DK> + elif crit == 'gt':
DK> + expr = 'len(assoc_list_info) > exp_len'
DK> + elif crit == 'le':
DK> + expr = 'len(assoc_list_info) <= exp_len'
DK> + else:
DK> + expr = 'len(assoc_list_info) <= exp_len'
DK> + if eval(expr) :
DK> + logger.error("%s returned %i %s objects, as compared with %i" %
(an, len(assoc_list_info), qcn, exp_len))
DK> + return FAIL
DK> + return PASS
DK> +
Sorry, but this will not go into the tree. Ever.
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com