diff options
| author | Thomas Huth <thuth@redhat.com> | 2025-09-12 12:07:53 +0200 |
|---|---|---|
| committer | Thomas Huth <thuth@redhat.com> | 2025-09-24 08:26:11 +0200 |
| commit | 5fe2b6255fa2794e9d0fa29f94b85766af3a4286 (patch) | |
| tree | 9f8b14ba8cf963ef9959228ca23a48baea236bb9 | |
| parent | 2bfe71aa7e6bce5c0254e679f66a44cadcb3a367 (diff) | |
| download | focaccia-qemu-5fe2b6255fa2794e9d0fa29f94b85766af3a4286.tar.gz focaccia-qemu-5fe2b6255fa2794e9d0fa29f94b85766af3a4286.zip | |
tests/functional: Test whether the vmstate-static-checker script works fine
We've got two vmstate dump files in the repository which are meant for verifying whether the vmstate-static-checker.py works as expected. Since running this manually is a cumbersome job, let's add an automated test for this instead that runs the script with the two dump files and checks for the expected output. Signed-off-by: Thomas Huth <thuth@redhat.com> Message-ID: <20250912100755.316518-3-thuth@redhat.com>
| -rw-r--r-- | MAINTAINERS | 1 | ||||
| -rw-r--r-- | tests/functional/x86_64/meson.build | 1 | ||||
| -rwxr-xr-x | tests/functional/x86_64/test_bad_vmstate.py | 58 |
3 files changed, 60 insertions, 0 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 79abe5f6c9..24c061aff3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3613,6 +3613,7 @@ F: migration/ F: scripts/vmstate-static-checker.py F: tests/functional/migration.py F: tests/functional/*/*migration.py +F: tests/functional/x86_64/test_bad_vmstate.py F: tests/data/vmstate-static-checker/ F: tests/qtest/migration/ F: tests/qtest/migration-* diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/meson.build index d0b4667bb8..ef12ac43b3 100644 --- a/tests/functional/x86_64/meson.build +++ b/tests/functional/x86_64/meson.build @@ -10,6 +10,7 @@ test_x86_64_timeouts = { } tests_x86_64_system_quick = [ + 'bad_vmstate', 'cpu_model_versions', 'cpu_queries', 'mem_addr_space', diff --git a/tests/functional/x86_64/test_bad_vmstate.py b/tests/functional/x86_64/test_bad_vmstate.py new file mode 100755 index 0000000000..40098a8490 --- /dev/null +++ b/tests/functional/x86_64/test_bad_vmstate.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +'''Test whether the vmstate-static-checker script detects problems correctly''' + +import subprocess + +from qemu_test import QemuBaseTest + + +EXPECTED_OUTPUT='''Warning: checking incompatible machine types: "pc-i440fx-2.1", "pc-i440fx-2.2" +Section "fw_cfg" does not exist in dest +Section "fusbh200-ehci-usb" version error: 2 > 1 +Section "fusbh200-ehci-usb", Description "ehci-core": expected field "usbsts", got "usbsts_pending"; skipping rest +Section "pci-serial-4x" Description "pci-serial-multi": Entry "Fields" missing +Section "intel-hda-generic", Description "intel-hda", Field "pci": missing description +Section "cfi.pflash01": Entry "Description" missing +Section "megasas", Description "PCIDevice": expected field "irq_state", while dest has no further fields +Section "PIIX3-xen" Description "PIIX3": minimum version error: 1 < 2 +Section "PIIX3-xen" Description "PIIX3": Entry "Subsections" missing +Section "tpci200": Description "tpci200" missing, got "tpci2002" instead; skipping +Section "sun-fdtwo" Description "fdc": version error: 2 > 1 +Section "sun-fdtwo", Description "fdrive": Subsection "fdrive/media_rate" not found +Section "usb-kbd" Description "usb-kbd" Field "kbd.keycodes" size mismatch: 4 , 2 +''' + +class BadVmStateTest(QemuBaseTest): + '''Test class for testing vmstat-static-checker script with bad input''' + + def test_checker(self): + """ + Test whether the checker script correctly detects the changes + between dump1.json and dump2.json. + """ + src_json = self.data_file('..', 'data', 'vmstate-static-checker', + 'dump1.json') + dst_json = self.data_file('..', 'data', 'vmstate-static-checker', + 'dump2.json') + checkerscript = self.data_file('..', '..', 'scripts', + 'vmstate-static-checker.py') + + self.log.info('Comparing %s with %s', src_json, dst_json) + cp = subprocess.run([checkerscript, '-s', src_json, '-d', dst_json], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, check=False) + if cp.returncode != 13: + self.fail('Unexpected return code of vmstate-static-checker: ' + + cp.returncode) + if cp.stdout != EXPECTED_OUTPUT: + self.log.info('vmstate-static-checker output:\n%s', cp.stdout) + self.log.info('expected output:\n%s', EXPECTED_OUTPUT) + self.fail('Unexpected vmstate-static-checker output!') + + +if __name__ == '__main__': + QemuBaseTest.main() |