All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Subject: [PULL 04/12] tests/functional: Test whether the vmstate-static-checker script works fine
Date: Wed, 24 Sep 2025 08:39:48 +0200	[thread overview]
Message-ID: <20250924063956.519792-5-thuth@redhat.com> (raw)
In-Reply-To: <20250924063956.519792-1-thuth@redhat.com>

From: Thomas Huth <thuth@redhat.com>

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>
---
 MAINTAINERS                                 |  1 +
 tests/functional/x86_64/meson.build         |  1 +
 tests/functional/x86_64/test_bad_vmstate.py | 58 +++++++++++++++++++++
 3 files changed, 60 insertions(+)
 create mode 100755 tests/functional/x86_64/test_bad_vmstate.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 79abe5f6c9a..24c061aff35 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 d0b4667bb8a..ef12ac43b37 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 00000000000..40098a8490b
--- /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()
-- 
2.51.0



  parent reply	other threads:[~2025-09-24  6:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24  6:39 [PULL 00/12] Functional test patches Thomas Huth
2025-09-24  6:39 ` [PULL 01/12] tests/functional/m68k: Use proper polling in the next-cube test Thomas Huth
2025-09-24  6:39 ` [PULL 02/12] tests/functional/s390x/test_pxelinux: Fix warnings from pylint Thomas Huth
2025-09-24  6:39 ` [PULL 03/12] tests: Move the old vmstate-static-checker files to tests/data/ Thomas Huth
2025-09-24  6:39 ` Thomas Huth [this message]
2025-10-29 11:58   ` [PULL 04/12] tests/functional: Test whether the vmstate-static-checker script works fine Daniel P. Berrangé
2025-10-30  9:07     ` Thomas Huth
2025-09-24  6:39 ` [PULL 05/12] tests/data/vmstate-static-checker: Add dump files from QEMU 7.2.17 Thomas Huth
2025-09-24  6:39 ` [PULL 06/12] tests/functional: Use vmstate-static-checker.py to test data from v7.2 Thomas Huth
2025-09-24  6:39 ` [PULL 07/12] tests/functional: use self.log for all logging Thomas Huth
2025-09-24  6:39 ` [PULL 08/12] .gitlab-ci.d/buildtest.yml: Unset CI_COMMIT_DESCRIPTION for htags Thomas Huth
2025-09-24  6:39 ` [PULL 09/12] tests/functional/hppa: Add a CD-ROM boot test for qemu-system-hppa Thomas Huth
2025-09-24  6:39 ` [PULL 10/12] tests: Fix "make check-functional" for targets without thorough tests Thomas Huth
2025-09-24  6:39 ` [PULL 11/12] tests/functional: retry when seeing ConnectionError exception Thomas Huth
2025-09-24  6:39 ` [PULL 12/12] tests/functional: treat unknown exceptions as transient faults Thomas Huth
2025-09-24 21:15 ` [PULL 00/12] Functional test patches Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250924063956.519792-5-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.