Hi Steve,

On 26/7/22 18:10, Steve Sistare wrote:
Signed-off-by: Steve Sistare <steven.sist...@oracle.com>
---
  MAINTAINERS          |   1 +
  tests/avocado/cpr.py | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 177 insertions(+)
  create mode 100644 tests/avocado/cpr.py

diff --git a/MAINTAINERS b/MAINTAINERS
index b93b0bb..adc1218 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3172,6 +3172,7 @@ F: stubs/cpr-state.c
  F: include/migration/cpr.h
  F: migration/cpr.c
  F: hw/vfio/cpr.c
+F: tests/avocado/cpr.py

Maybe rename migration_cpr.py.

Record/replay
  M: Pavel Dovgalyuk <pavel.dovga...@ispras.ru>
diff --git a/tests/avocado/cpr.py b/tests/avocado/cpr.py
new file mode 100644
index 0000000..11e1376
--- /dev/null
+++ b/tests/avocado/cpr.py
@@ -0,0 +1,176 @@
+# cpr test

"migration CPR test"

+
+# Copyright (c) 2021, 2022 Oracle and/or its affiliates.
+#
+# This work is licensed under the terms of the GNU GPL, version 2.
+# See the COPYING file in the top-level directory.

Preferably replace/complement with SPDX tag.

+
+import tempfile
+from avocado_qemu import QemuSystemTest
+from avocado.utils import wait
+
+class Cpr(QemuSystemTest):

MigrationCpr

+    """
+    :avocado: tags=cpr

Also:
       :avocado: tags=migration

or even:

       :avocado: tags=migration
       :avocado: tags=migration:cpr

+    """
+
+    timeout = 5
+    fast_timeout = 1

These methods ...

+    @staticmethod
+    def has_status(vm, status, command):
+        return vm.command(command)['status'] in status

           s/status/status_set/
+
+    def wait_for_status(self, vm, status, command):
+        wait.wait_for(self.has_status,
+                      timeout=self.timeout,
+                      step=0.1,
+                      args=(vm,status,command,))

           s/status/status_set/

+
+    def wait_for_runstate(self, vm, status):
+        self.wait_for_status(vm, status, 'query-status')

           s/status/status_set/

+
+    def wait_for_migration(self, vm, status):
+        self.wait_for_status(vm, status, 'query-migrate')

           s/status/status_set/

+
+    def run_and_fail(self, vm, msg):
+        # Qemu will fail fast, so disable monitor to avoid timeout in accept
+        vm.set_qmp_monitor(False)
+        vm.launch()
+        vm.wait(self.timeout)
+        self.assertRegex(vm.get_log(), msg)

... are generic so could go to QemuSystemTest.

The rest LGTM!

Regards,

Phil.

Reply via email to