qemu/qemu/c9e8ecf2fb8ffd559c63fff413063c4e18a7c989 tests/qtest/fdc-test: give each test case its own QEMU instance
The test cases share one QEMU instance and, with it, the state of the
floppy controller. Several of them therefore only pass in the order they
happen to be registered in: test_read_no_dma_1, _18 and _19 read the medium
that test_media_insert leaves in the drive, so running any of them on its
own fails. fuzz-registers is worse -- it writes 1000 random values to the
eight I/O ports at FLOPPY_BASE and restores none of them, which is harmless
only because it is the last test case to run in the shared instance; the
two registered after it start one of their own. Moving it anywhere else
leaves an unacknowledged interrupt behind and the next test dies in
send_seek().
Register the test cases from a table instead, through a wrapper that starts
a QEMU instance, runs one test and stops it again. The test functions are
unchanged: they reach the current instance through global_qtest, which
qtest_start() reassigns for every test. The three read_no_dma tests now
insert their own medium, and test_read_id no longer ejects at the end -- it
did that only to leave the drive as the next test expected to find it.
The two CVE test cases keep qtest_add_func(); they already run a QEMU
instance of their own and do not use global_qtest.
The same pattern is used by tests/qtest/boot-serial-test.c.
Every test case now passes on its own, and the suite passes with the
registration order reversed.
Signed-off-by: Christian Quante <christian@quante.one>
Tested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
1 file changed