From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucas Meneghel Rodrigues Subject: [PATCH 6/7] KVM test: Try to load subtests on a shared tests location Date: Wed, 9 Mar 2011 06:21:09 -0300 Message-ID: <1299662470-3017-7-git-send-email-lmr@redhat.com> References: <1299662470-3017-1-git-send-email-lmr@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: autotest@test.kernel.org Return-path: In-Reply-To: <1299662470-3017-1-git-send-email-lmr@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org As we have several subtests that can be shared among different virtualization tests (kvm, xen), manipulate kvm.py to try loading subtests from the common area (planned to be client/virt/tests) first, then falling back to the specific test area (client/tests/kvm/tests). Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/kvm.py | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py index 6981b1b..54535ae 100644 --- a/client/tests/kvm/kvm.py +++ b/client/tests/kvm/kvm.py @@ -54,11 +54,19 @@ class kvm(test.test): # test type t_type = params.get("type") # Verify if we have the correspondent source file for it - 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) + virt_dir = os.path.dirname(virt_utils.__file__) + subtest_dir_virt = os.path.join(virt_dir, "tests") + subtest_dir_kvm = os.path.join(self.bindir, "tests") + subtest_dir = None + for d in [subtest_dir_virt, subtest_dir_kvm]: + 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 either %s or %s directory" % + subtest_dir_virt, subtest_dir_kvm) # Load the test module f, p, d = imp.find_module(t_type, [subtest_dir]) test_module = imp.load_module(t_type, f, p, d) -- 1.7.4