From patchwork Wed Dec 2 03:26:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 64090 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB23QRV9012905 for ; Wed, 2 Dec 2009 03:26:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754457AbZLBD0T (ORCPT ); Tue, 1 Dec 2009 22:26:19 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755207AbZLBD0S (ORCPT ); Tue, 1 Dec 2009 22:26:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29272 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754283AbZLBD0S (ORCPT ); Tue, 1 Dec 2009 22:26:18 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB23QOjX003913 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Dec 2009 22:26:24 -0500 Received: from localhost.localdomain (vpn-8-59.rdu.redhat.com [10.11.8.59]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB23QL9W028072; Tue, 1 Dec 2009 22:26:22 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, mgoldish@redhat.com, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: Fix subtest imports Date: Wed, 2 Dec 2009 01:26:19 -0200 Message-Id: <1259724379-6883-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py index 06ef9f5..332fa86 100644 --- a/client/tests/kvm/kvm.py +++ b/client/tests/kvm/kvm.py @@ -22,9 +22,7 @@ class kvm(test.test): """ version = 1 def initialize(self): - # 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): @@ -44,23 +42,20 @@ class kvm(test.test): try: try: # Get the test routine corresponding to the specified test type - type = params.get("type") + t_type = params.get("type") # Verify if we have the correspondent source file for it - module_path = os.path.join(self.subtest_dir, '%s.py' % type) + module_path = os.path.join(self.subtest_dir, '%s.py' % t_type) if not os.path.isfile(module_path): - 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__(type) - except ImportError, e: - raise error.TestError("Failed to import test %s: %s" % - (type, e)) - + raise error.TestError("No %s.py test file found" % t_type) + # Load the test module + # (KVM test dir was appended to sys.path in the control file) + __import__("tests.%s" % t_type) + test_module = sys.modules["tests.%s" % t_type] # Preprocess kvm_preprocessing.preprocess(self, params, env) kvm_utils.dump_env(env, env_filename) # Run the test function - run_func = getattr(test_module, "run_%s" % type) + run_func = getattr(test_module, "run_%s" % t_type) run_func(self, params, env) kvm_utils.dump_env(env, env_filename) @@ -76,3 +71,4 @@ class kvm(test.test): kvm_preprocessing.postprocess(self, params, env) logging.debug("Contents of environment: %s", str(env)) kvm_utils.dump_env(env, env_filename) +