From patchwork Wed Dec 2 10:06:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 64215 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 nB2A8FdO002567 for ; Wed, 2 Dec 2009 10:08:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752464AbZLBKIF (ORCPT ); Wed, 2 Dec 2009 05:08:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752640AbZLBKIF (ORCPT ); Wed, 2 Dec 2009 05:08:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3811 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752442AbZLBKIE (ORCPT ); Wed, 2 Dec 2009 05:08:04 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB2A8At1001492 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 Dec 2009 05:08:10 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB2A89bd004737; Wed, 2 Dec 2009 05:08:09 -0500 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id nB2A84rG015926; Wed, 2 Dec 2009 05:08:08 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH] KVM test: use the imp module to import subtest module by filename Date: Wed, 2 Dec 2009 12:06:01 +0200 Message-Id: <1259748361-21909-2-git-send-email-mgoldish@redhat.com> In-Reply-To: <1259748361-21909-1-git-send-email-mgoldish@redhat.com> References: <1259748361-21909-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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 380fbee..4caa03b 100644 --- a/client/tests/kvm/kvm.py +++ b/client/tests/kvm/kvm.py @@ -1,4 +1,4 @@ -import sys, os, time, logging +import sys, os, time, logging, imp from autotest_lib.client.bin import test from autotest_lib.client.common_lib import error import kvm_utils, kvm_preprocessing @@ -21,8 +21,9 @@ class kvm(test.test): (Online doc - Getting started with KVM testing) """ version = 1 + def initialize(self): - self.subtest_dir = os.path.join(self.bindir, 'tests') + pass def run_once(self, params): @@ -44,13 +45,15 @@ class kvm(test.test): # Get the test routine corresponding to the specified test 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' % t_type) + subtest_dir = os.path.join(self.bindir, "tests") + module_path = os.path.join(subtest_dir, "%s.py" % t_type) if not os.path.isfile(module_path): 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] + f, p, d = imp.find_module(t_type, [subtest_dir]) + test_module = imp.load_module(t_type, f, p, d) + f.close() + # Preprocess kvm_preprocessing.preprocess(self, params, env) kvm_utils.dump_env(env, env_filename)