[PATCH 6/7] KVM test: Try to load subtests from a shared tests location

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As we have several subtests that can be shared among different
virtualization tests (kvm, xen), manipulate kvm.py to try loading
subtests from the kvm area (client/tests/kvm/tests) first,
then falling back to the specific test area (planned to be
client/virt/tests).

Changes from v1:
 * Martin Jenner has suggested inverting the lookup order.
Looking first on the specific kvm subtest area *then* common
allows people to override the commom implementation of a test
that might be better for that particular virt technology.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
Signed-off-by: Martin Jenner <mjenner@xxxxxxxxxx>
---
 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 2006880..bb17f28 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -59,11 +59,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_kvm, subtest_dir_virt]:
+                        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_kvm, subtest_dir_virt)
                     # 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.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux