Test harness for writing QEMU tests in Rust.
make buildRun tests in parallel with 2 jobs (default is sequential):
make run TEST_JOBS=2Run test with debug output:
make run RUST_LOG=qemu_test::tests::migration=debugSet KEEP_LOGS=./path/to/logs to keep logs of all tests in the specified directory for debugging failed runs.
The test setup can be configured via environment variables:
QEMU_BIN- path to the QEMU binary to use (default:qemu-system-x86_64)TEST_JOBS- number of parallel test jobs (default: 1)ACCEL- accelerator to use (default:kvm)TEST_FILTER- filter to select tests to run (default: all tests)KEEP_LOGS- directory to keep logs of all tests (default: none)
This will run only tests with "migration", "simple" or "smp=1" in their label (parameters are expanded into labels):
make run TEST_JOBS=2 TEST_FILTER=migration,simple,smp=1Prefix a token with - to exclude matching tests:
make run TEST_FILTER=-migration,smp=2This runs tests matching smp=2, excluding tests whose label contains migration.
If a test matches both positive and negative tokens, the negative token wins and the test is excluded.
Tests can be annotated with #[test_fn(skip = "reason")] to skip them with a reason. Note that tests that are selected by the filter explicitly will be run even if they are annotated with skip.
There is a proc macro to define tests. It can be used to stack test configurations or build a cartesian product of configurations.
This will expand to 1 + 2 = 3 tests:
#[test_fn(machine = Machine::Pc, smp = 1)]
#[test_fn(machine = Machine::Q35, smp = {2, 4})]
pub(crate) fn test_kernel_boot(machine: Machine, smp: u8) -> Result<()> { ... }Those tests are skipped by default, because they need a bridge and tap devices to be set up on the host and they require superuser privileges to run.
Note that TEST_JOBS=n needs at least n*2 tap devices to be available.
Create a bridge and 4 tap devices for a test that can run 2 tests in parallel:
sudo make setup-bridge NUM_TAPS=4With 4 tap devices, 2 tests can run in parallel:
sudo -E PATH=$PATH make run TEST_JOBS=2 TEST_FILTER=migration_ossudo make teardown-bridge