Testing/QemuIoTests: Difference between revisions

From QEMU
(Created page with 'The qemu-iotests test suite is located in tests/qemu-iotests/. It contains test for disk image formats and block layer features. ==Running test cases== tests/qemu-iotests/check…')
 
(The check script should now be run from the build tree)
Line 2: Line 2:


==Running test cases==
==Running test cases==
tests/qemu-iotests/check is the script to run tests.  Tests exercise block I/O operations using qemu-img(1), qemu-io(1), and sometimes by running QEMU.
tests/qemu-iotests/check (relative to the build directory) is the script to run tests.  Tests exercise block I/O operations using qemu-img(1), qemu-io(1), and sometimes by running QEMU.


You can launch it like this:
You can launch it like this (being in the directory where you have built qemu):
  cd tests/qemu-iotests
  cd tests/qemu-iotests
  QEMU_PROG=path/to/qemu-system-x86_64 PATH=path/to/qemu-dir:$PATH ./check -qcow2 [<test-case>]
  ./check -qcow2 [<test-case>]


You can simplify this by putting 'qemu', 'qemu-img', and 'qemu-io'
If instead of the binaries present in the build tree you want to use
into your PATH.  You may wish to symlink 'qemu' to your
other ones for qemu, qemu-img etc., you can specify these through
qemu-system-x86_64 binary.  That saves you from typing out the
environment variables ($QEMU, $QEMU_IMG, $QEMU_IO, $QEMU_NBD) or by
environment variables every time.  See the qemu-iotests code for
creating symlinks in tests/qemu-iotests named 'qemu', 'qemu-img',
details on how paths are detected.
'qemu-io', and 'qemu-nbd', respectively.  See the qemu-iotests code
for details on how paths are detected.


==Test suite overview==
==Test suite overview==

Revision as of 20:04, 29 August 2014

The qemu-iotests test suite is located in tests/qemu-iotests/. It contains test for disk image formats and block layer features.

Running test cases

tests/qemu-iotests/check (relative to the build directory) is the script to run tests. Tests exercise block I/O operations using qemu-img(1), qemu-io(1), and sometimes by running QEMU.

You can launch it like this (being in the directory where you have built qemu):

cd tests/qemu-iotests
./check -qcow2 [<test-case>]

If instead of the binaries present in the build tree you want to use other ones for qemu, qemu-img etc., you can specify these through environment variables ($QEMU, $QEMU_IMG, $QEMU_IO, $QEMU_NBD) or by creating symlinks in tests/qemu-iotests named 'qemu', 'qemu-img', 'qemu-io', and 'qemu-nbd', respectively. See the qemu-iotests code for details on how paths are detected.

Test suite overview

Tests are grouped by specific areas (read-only, read-write, backing file, etc) in tests/qemu-iotests/group. New tests must be added to this file before they become available in check.

Tests themselves can restrict themselves to certain formats or host operating systems. This is useful for ensuring that a test is only run against, say qcow2, vmdk, and qed. See the actual test code.

Most tests are written in bash. The qemu-iotests framework is also written in bash. The framework is pretty simple: it runs a test and compares the output against a "golden master" output file. If the output matches then the test passes (this requires filtering output in some cases to eliminate parts that differ between runs, from system to system, etc).

Some tests are written in Python and use iotests.py, which provides the necessary environment and useful functions. These tests mainly launch QEMU and interact with the QMP monitor (JSON), which is hard to do easily in bash.