[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [test-API PATCH 2/4] modify framework to support it



    libvirt-test-api: pass proxy_obj to generator, and support dict type
                      of optional_params
    src/generator.py: call xml_file_to_str()
    src/proxy.py: get the optional_params of a testcase
---
 libvirt-test-api |    3 ++-
 src/generator.py |    7 ++++++-
 src/proxy.py     |   17 +++++++++++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/libvirt-test-api b/libvirt-test-api
index 373e5c6..a7c9138 100644
--- a/libvirt-test-api
+++ b/libvirt-test-api
@@ -147,6 +147,7 @@ class Main(object):
                 logfile = os.path.join('log/%s' % testrunid, logname)
             procs.append(generator.FuncGen(cases_func_ref_dict,
                                            cases_checkfunc_ref_dict,
+                                           proxy_obj,
                                            activity,
                                            logfile,
                                            testrunid,
@@ -244,7 +245,7 @@ class Main(object):
                 string += " " * 8 + p.upper() + "\n"
             for p in optional_params:
                 string += " " * 4 + "[" + p + "]\n"
-                string += " " * 8 + p.upper() + "\n"
+                string += " " * 8 + optional_params[p] + "\n"
 
             if proxy_obj.has_clean_function(key):
                 string += "clean\n"
diff --git a/src/generator.py b/src/generator.py
index e3bc344..5d7bc96 100644
--- a/src/generator.py
+++ b/src/generator.py
@@ -25,6 +25,7 @@ import os
 import traceback
 
 from src import mapper
+from src.testcasexml import xml_file_to_str
 from utils import log
 from utils import format
 from utils import env_parser
@@ -41,12 +42,14 @@ class FuncGen(object):
     """ To generate a callable testcase"""
     def __init__(self, cases_func_ref_dict,
                  cases_checkfunc_ref_dict,
+                 proxy_obj,
                  activity, logfile,
                  testrunid, testid,
                  log_xml_parser, lockfile,
                  loglevel):
         self.cases_func_ref_dict = cases_func_ref_dict
         self.cases_checkfunc_ref_dict = cases_checkfunc_ref_dict
+        self.proxy_obj = proxy_obj
         self.logfile = logfile
         self.testrunid = testrunid
         self.testid = testid
@@ -131,7 +134,7 @@ class FuncGen(object):
 
             case_start_time = time.strftime("%Y-%m-%d %H:%M:%S")
 
-            ret = 0
+            ret = 1
             try:
                 try:
                     if mod_case_func == 'sleep':
@@ -140,6 +143,8 @@ class FuncGen(object):
                         time.sleep(int(sleepsecs))
                         ret = 0
                     else:
+                        xml_file_to_str(self.proxy_obj, mod_case, case_params)
+
                         ret = self.cases_func_ref_dict[mod_case_func](case_params)
                         # In the case where testcase return -1 on error
                         if ret < 0: ret = 1
diff --git a/src/proxy.py b/src/proxy.py
index 623fa43..fe50fff 100644
--- a/src/proxy.py
+++ b/src/proxy.py
@@ -130,6 +130,23 @@ class Proxy(object):
                       ("required_params or optional_params not found in %s" % modcase)
         return case_params
 
+    def get_testcase_params(self, modcase):
+        """ Return a pair of required_params and optional_params
+            for a testcase
+        """
+        if not modcase:
+            return None
+
+        casemod_ref = self.testcase_ref_dict[modcase]
+        var_func_names = dir(casemod_ref)
+
+        if 'required_params' not in var_func_names \
+           or 'optional_params' not in var_func_names:
+            raise exception.TestCaseError\
+                  ("required_params or optional_params not found in %s" % modcase)
+
+        return [casemod_ref.required_params, casemod_ref.optional_params]
+
     def has_clean_function(self, testcase_name):
         """ Return true if the testcase have clean function
         """
-- 
1.7.7.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]