Patchworkβ KVM test: Change the way subtests are loaded

login
register
about
Submitter Lucas Meneghel Rodrigues
Date 2009-10-30 22:07:45
Message ID <1256940465-5650-1-git-send-email-lmr@redhat.com>
Download mbox | patch
Permalink /patch/56722/
State New
Headers show

Comments

Lucas Meneghel Rodrigues - 2009-10-30 22:07:45
Recently autoserv changed its default behavior of rsyncing
the whole client directory to the test machine, now it
will copy only the needed tests to the client machine.

Also, the way the tests are loaded when running from the
server has changed, breaking the KVM test when ran from
autoserv.

So change the mechanism to load KVM subtests, in order to
cope with the recent autoserv changes.

Thanks to Ryan Harper for having noticed this issue.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/kvm.py |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
Ryan Harper - 2009-10-31 01:18:28
* Lucas Meneghel Rodrigues <lmr@redhat.com> [2009-10-30 17:08]:
> Recently autoserv changed its default behavior of rsyncing
> the whole client directory to the test machine, now it
> will copy only the needed tests to the client machine.
> 
> Also, the way the tests are loaded when running from the
> server has changed, breaking the KVM test when ran from
> autoserv.
> 
> So change the mechanism to load KVM subtests, in order to
> cope with the recent autoserv changes.
> 
> Thanks to Ryan Harper for having noticed this issue.
> 
> Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>

Acked-by: Ryan Harper <ryanh@us.ibm.com>

This fixed the issue for me.  

Thanks Lucas!

Patch

diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index 204164d..06ef9f5 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -22,9 +22,9 @@  class kvm(test.test):
     """
     version = 1
     def initialize(self):
-        # Make it possible to import modules from the test's bindir
-        sys.path.append(self.bindir)
+        # Make it possible to import modules from the subtest dir
         self.subtest_dir = os.path.join(self.bindir, 'tests')
+        sys.path.append(self.subtest_dir)
 
 
     def run_once(self, params):
@@ -51,7 +51,7 @@  class kvm(test.test):
                     raise error.TestError("No %s.py test file found" % type)
                 # Load the tests directory (which was turned into a py module)
                 try:
-                    test_module = __import__("tests.%s" % type)
+                    test_module = __import__(type)
                 except ImportError, e:
                     raise error.TestError("Failed to import test %s: %s" %
                                           (type, e))
@@ -60,7 +60,8 @@  class kvm(test.test):
                 kvm_preprocessing.preprocess(self, params, env)
                 kvm_utils.dump_env(env, env_filename)
                 # Run the test function
-                eval("test_module.%s.run_%s(self, params, env)" % (type, type))
+                run_func = getattr(test_module, "run_%s" % type)
+                run_func(self, params, env)
                 kvm_utils.dump_env(env, env_filename)
 
             except Exception, e: