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.

Signed-off-by: Feng Yang <fy...@redhat.com>
---
 client/virt/virt_test.py |   49 +++++++++++++++++++++++++--------------------
 1 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/client/virt/virt_test.py b/client/virt/virt_test.py
index 0e97307..b3e0032 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,19 +68,25 @@ 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_module = imp.load_module(t_type, f, p, d)
+                        f.close()
 
                     # Preprocess
                     try:
@@ -92,11 +94,14 @@ class virt_test(test.test):
                     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():
+                        logging.info("Running function: %s.run_%s" % (t_type,
+                                                                      t_type))
+                        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 mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to