[PATCH 2/2] KVM test: Introduce qemu_iotests for the KVM test

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

 



In order to run always the latest up to date qemu iotests
on all KVM branches, insert qemu-iotests execution inside
KVM autotest. It'll attempt to git fetch the latest contents
of the qemu-iotests test suite, then carry on with tests,
reporting errors to autotest.

Besides having the latest test, with this approach it is
easier to specify to the test suite which paths we want
to get tested, which are under kvm autotest's control.
This patch actually depends on a couple of patches sent
to the qemu_iotest upstream maintainers.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/subtests.cfg.sample   |   13 +++++++
 client/tests/kvm/tests/qemu_iotests.py |   62 ++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/qemu_iotests.py

diff --git a/client/tests/kvm/subtests.cfg.sample b/client/tests/kvm/subtests.cfg.sample
index 55f1b21..9b997dd 100644
--- a/client/tests/kvm/subtests.cfg.sample
+++ b/client/tests/kvm/subtests.cfg.sample
@@ -80,6 +80,19 @@ variants:
                 extra_params = " --append ks=REPLACE_THIS_WITH_URL_OF_KS"
                 url = REPLACE_THIS_WITH_TREE_URL
 
+    - qemu_iotests:
+        type = qemu_iotests
+        vms = ''
+        profilers = ''
+        take_regular_screendumps = no
+        qemu_io_uri = git://git.kernel.org/pub/scm/linux/kernel/git/hch/qemu-iotests.git
+        qemu_io_branch = master
+        qemu_io_lbranch = master
+        qemu_io_formats = "raw qcow qcow2 qed vdi vpc vmdk rdb sheepdog"
+        #qemu_io_commit =
+        #qemu_io_base_uri =
+        #qemu_io_extra_options =
+
     - qemu_img:
         type = qemu_img
         vms = ''
diff --git a/client/tests/kvm/tests/qemu_iotests.py b/client/tests/kvm/tests/qemu_iotests.py
new file mode 100644
index 0000000..2b44a42
--- /dev/null
+++ b/client/tests/kvm/tests/qemu_iotests.py
@@ -0,0 +1,62 @@
+import os
+from autotest_lib.client.common_lib import git, error
+from autotest_lib.client.bin import utils
+from autotest_lib.client.virt import virt_utils
+
+
+def run_qemu_iotests(test, params, env):
+    """
+    Fetch from git and run qemu-iotests using the qemu binaries under test.
+
+    1) Fetch qemu-io from git
+    2) Parse help output to figure out supported file formats
+    3) Run test for each file format detected
+    4) Report any errors found to autotest
+
+    @param test:   KVM test object.
+    @param params: Dictionary with the test parameters.
+    @param env:    Dictionary with test environment.
+    """
+    # First, let's get qemu-io
+    std = "git://git.kernel.org/pub/scm/linux/kernel/git/hch/qemu-iotests.git"
+    uri = params.get("qemu_io_uri", std)
+    branch = params.get("qemu_io_branch", 'master')
+    lbranch = params.get("qemu_io_lbranch", 'master')
+    commit = params.get("qemu_io_commit", None)
+    base_uri = params.get("qemu_io_base_uri", None)
+    destination_dir = os.path.join(test.srcdir, "qemu_io_tests")
+    git.get_repo(uri=uri, branch=branch, lbranch=lbranch, commit=commit,
+                 destination_dir=destination_dir, base_uri=base_uri)
+
+    # Then, set the qemu paths for the use of the testsuite
+    os.environ["QEMU_PROG"] = virt_utils.get_path(test.bindir,
+                                    params.get("qemu_binary", "qemu"))
+    os.environ["QEMU_IMG_PROG"] = virt_utils.get_path(test.bindir,
+                                    params.get("qemu_img_binary", "qemu-img"))
+    os.environ["QEMU_IO_PROG"] = virt_utils.get_path(test.bindir,
+                                    params.get("qemu_io_binary", "qemu-io"))
+
+    # Parse help output to figure out supported file formats
+    os.chdir(destination_dir)
+    formats = params.get("qemu_io_image_formats",
+                         "raw qcow2 qed qcow vdi vpc vmdk rdb sheepdog")
+    extra_options = params.get("qemu_io_extra_options", "")
+
+    formats = formats.split()
+
+    # Run test for each file format detected
+    err = []
+    cmd = './check'
+    if extra_options:
+        cmd += extra_options
+    for f in formats:
+        try:
+            utils.system("%s -%s" % (cmd, f))
+        except error.CmdError:
+            err.append(format)
+
+    # Report all errors found to autotest
+    if err:
+        err = ", ".join(err)
+        e_msg = "Testsuite qemu-io reported errors for formats: %s" % err
+        raise error.TestFail(e_msg)
-- 
1.7.7.3

--
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