On 04/16/2012 02:34 PM, Osier Yang wrote:
s/cleanup:make/cleanup: Make/
On 2012年04月16日 14:11, Guannan Ren wrote:
The patch make the writing of clean function optional
If a testcase makes testing environment dirty after running, it
If a case dirties the testing environment,
must write a CASENAME_clean function to restore back the
Could the $CASENAME_ be omitted? IIRC, the scripts under repos
are imported by framework when executing. And thus we can invoke
the cleanup functions by $script_name.cleanup.
If we add clean flag after testcase in config file like this, the
framework
will invoke the testa_clean() after running the testa() in testa.py
Note: we only add the clean for testcase which has _clean
function in it.
...
test:testa
options
value1
clean
...
testing environment, otherwise, the clean function could be omitted
---
env_clear.py | 9 ++++-----
proxy.py | 7 ++++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/env_clear.py b/env_clear.py
index 3efc9be..2e5bcf5 100644
--- a/env_clear.py
+++ b/env_clear.py
@@ -30,7 +30,7 @@ class EnvClear(object):
self.loglevel = loglevel
mapper_obj = mapper.Mapper(activity)
- clean_pkg_casename_func =
mapper_obj.clean_package_casename_func_map()
+ clean_pkg_casename_func =
mapper_obj.module_casename_cleanfunc_map()
self.cases_ref_names = []
for case in clean_pkg_casename_func:
@@ -47,7 +47,7 @@ class EnvClear(object):
return retflag
def env_clear(self):
- """ Run each clearing function with the corresponding
arguments """
+ """ Run each clean function with the corresponding arguments
"""
envlog = log.EnvLog(self.logfile, self.loglevel)
logger = envlog.env_log()
@@ -60,8 +60,7 @@ class EnvClear(object):
case_params = self.cases_params_list[i]
case_params['logger'] = logger
- self.cases_clearfunc_ref_dict[case_ref_name](case_params)
-
- del envlog
+ if self.cases_clearfunc_ref_dict.has_key(case_ref_name):
To be consistent, "clear" should be "clean".
+
self.cases_clearfunc_ref_dict[case_ref_name](case_params)
return 0
diff --git a/proxy.py b/proxy.py
index 3c4cd63..fdbffd9 100644
--- a/proxy.py
+++ b/proxy.py
@@ -85,12 +85,13 @@ class Proxy(object):
var_func_names = dir(casemod_ref)
key = module + ':' + casename + ':' + func
+
+ # the clean function is optional, we get its reference
+ # only if it exists in testcases
s/testcases/test cases/, or "cases" is enough, we should have
a consistent term across the project, but not different from
here and there.
if func in var_func_names:
func_ref = getattr(casemod_ref, func)
func_dict[key] = func_ref
- else:
- raise exception.TestCaseError("clean function not
found in %s" % \
- (func, testcase_name))
+
return func_dict
def get_params_variables(self):
Thanks for the review.
I will push it after these problems fixed.
Guannan Ren
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list