Testing/QemuIoTests

From QEMU
Jump to: navigation, search

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.