On 23/10/2023 22.35, Fabiano Rosas wrote:
From: Steve Sistare <steven.sist...@oracle.com>

Define a state object to capture events seen by migration tests, to allow
more events to be captured in a subsequent patch, and simplify event
checking in wait_for_migration_pass.  No functional change.

Signed-off-by: Steve Sistare <steven.sist...@oracle.com>
---
  tests/qtest/migration-helpers.c | 24 ++++-------
  tests/qtest/migration-helpers.h |  8 ++--
  tests/qtest/migration-test.c    | 74 +++++++++++++++------------------
  3 files changed, 46 insertions(+), 60 deletions(-)

diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
index 24fb7b3525..fd3b94efa2 100644
--- a/tests/qtest/migration-helpers.c
+++ b/tests/qtest/migration-helpers.c
@@ -24,26 +24,16 @@
   */
  #define MIGRATION_STATUS_WAIT_TIMEOUT 120
-bool migrate_watch_for_stop(QTestState *who, const char *name,
-                            QDict *event, void *opaque)
-{
-    bool *seen = opaque;
-
-    if (g_str_equal(name, "STOP")) {
-        *seen = true;
-        return true;
-    }
-
-    return false;
-}
-
-bool migrate_watch_for_resume(QTestState *who, const char *name,
+bool migrate_watch_for_events(QTestState *who, const char *name,
                                QDict *event, void *opaque)
  {
-    bool *seen = opaque;
+    QTestMigrationState *state = opaque;
- if (g_str_equal(name, "RESUME")) {
-        *seen = true;
+    if (g_str_equal(name, "STOP")) {
+        state->stop_seen = true;
+        return true;
+    } else if (g_str_equal(name, "RESUME")) {
+        state->resume_seen = true;
          return true;
      }
diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h
index e31dc85cc7..c1d4c84995 100644
--- a/tests/qtest/migration-helpers.h
+++ b/tests/qtest/migration-helpers.h
@@ -15,9 +15,11 @@
#include "libqtest.h" -bool migrate_watch_for_stop(QTestState *who, const char *name,
-                            QDict *event, void *opaque);
-bool migrate_watch_for_resume(QTestState *who, const char *name,
+typedef struct QTestMigrationState {
+    bool stop_seen, resume_seen;

Just a matter of taste, but for struct definitions, I'd prefer to put the entries on a single line each instead.

+} QTestMigrationState;
+
+bool migrate_watch_for_events(QTestState *who, const char *name,
                                QDict *event, void *opaque);

 Thomas



Reply via email to