On Fri, Aug 10, 2012 at 12:17 AM, Feng Yang <[email protected]> wrote: > This patch is useful if we want use existing script to combinate new test > case. > We have migrate test script and s4 test script. After this patch it is > easy for us to get s4 after migration or migration after s4 by updating > configure.
This patch looks OK, applied to next, thanks! > Changes from v1: > Fix bug introduced in code merge. Test patch in local. > > Signed-off-by: Feng Yang <[email protected]> > --- > client/virt/virt_test.py | 48 ++++++++++++++++++++++++--------------------- > 1 files changed, 26 insertions(+), 22 deletions(-) > > diff --git a/client/virt/virt_test.py b/client/virt/virt_test.py > index d9e052e..7ccdcb1 100644 > --- a/client/virt/virt_test.py > +++ b/client/virt/virt_test.py > @@ -53,10 +53,6 @@ class virt_test(test.test): > try: > try: > try: > - # Get the test routine corresponding to the specified > - # test type > - t_type = params.get("type") > - > subtest_dirs = [] > tests_dir = self.job.testdir > > @@ -72,31 +68,39 @@ class virt_test(test.test): > subtest_dirs.append(os.path.join(virt_dir, "tests")) > subtest_dirs.append(os.path.join(self.bindir, "tests")) > subtest_dir = None > - for d in subtest_dirs: > - module_path = os.path.join(d, "%s.py" % t_type) > - if os.path.isfile(module_path): > - subtest_dir = d > - break > - if subtest_dir is None: > - raise error.TestError("Could not find test file > %s.py " > - "on tests dirs %s" % > - (t_type, subtest_dirs)) > - # Load the test module > - f, p, d = imp.find_module(t_type, [subtest_dir]) > - test_module = imp.load_module(t_type, f, p, d) > - f.close() > > + # Get the test routine corresponding to the specified > + # test type > + t_types = params.get("type").split() > + test_modules = {} > + for t_type in t_types: > + for d in subtest_dirs: > + module_path = os.path.join(d, "%s.py" % t_type) > + if os.path.isfile(module_path): > + subtest_dir = d > + break > + if subtest_dir is None: > + msg = "Could not find test file %s.py on tests"\ > + "dirs %s" % (t_type, subtest_dirs) > + raise error.TestError(msg) > + # Load the test module > + f, p, d = imp.find_module(t_type, [subtest_dir]) > + test_modules[t_type] = imp.load_module(t_type, f, p, > d) > + f.close() > # Preprocess > try: > virt_env_process.preprocess(self, params, env) > finally: > env.save() > # Run the test function > - run_func = getattr(test_module, "run_%s" % t_type) > - try: > - run_func(self, params, env) > - finally: > - env.save() > + for t_type, test_module in test_modules.items(): > + msg = "Running function: %s.run_%s()" % (t_type, > t_type) > + logging.info(msg) > + run_func = getattr(test_module, "run_%s" % t_type) > + try: > + run_func(self, params, env) > + finally: > + env.save() > test_passed = True > > except Exception, e: > -- > 1.7.7.6 > > _______________________________________________ > Autotest-kernel mailing list > [email protected] > https://www.redhat.com/mailman/listinfo/autotest-kernel -- Lucas _______________________________________________ Autotest-kernel mailing list [email protected] https://www.redhat.com/mailman/listinfo/autotest-kernel
