Testing/QemuIoTests

From QEMU
Revision as of 08:46, 1 July 2013 by Stefanha (talk | contribs) (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…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

cd tests/qemu-iotests
QEMU_PROG=path/to/qemu-system-x86_64 PATH=path/to/qemu-dir:$PATH ./check -qcow2 [<test-case>]

You can simplify this by putting 'qemu', 'qemu-img', and 'qemu-io' into your PATH. You may wish to symlink 'qemu' to your qemu-system-x86_64 binary. That saves you from typing out the environment variables every time. 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.