Skip to content

Commit

Permalink
tests/qtest/migration: Add channels parameter in migrate_qmp_fail
Browse files Browse the repository at this point in the history
Alter migrate_qmp_fail() to allow both uri and channels
independently. For channels, convert string to a Dict.
No dealing with migrate_get_socket_address() here because
we will fail before starting the migration anyway.

Signed-off-by: Het Gala <het.gala@nutanix.com>
Suggested-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240312202634.63349-5-het.gala@nutanix.com
Signed-off-by: Peter Xu <peterx@redhat.com>
  • Loading branch information
hetgala99 authored and xzpeter committed Apr 23, 2024
1 parent 4f2f5b6 commit 387dc40
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
13 changes: 11 additions & 2 deletions tests/qtest/migration-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ bool migrate_watch_for_events(QTestState *who, const char *name,
return false;
}

void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...)
void migrate_qmp_fail(QTestState *who, const char *uri,
const char *channels, const char *fmt, ...)
{
va_list ap;
QDict *args, *err;
Expand All @@ -110,7 +111,15 @@ void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...)
va_end(ap);

g_assert(!qdict_haskey(args, "uri"));
qdict_put_str(args, "uri", uri);
if (uri) {
qdict_put_str(args, "uri", uri);
}

g_assert(!qdict_haskey(args, "channels"));
if (channels) {
QObject *channels_obj = qobject_from_json(channels, &error_abort);
qdict_put_obj(args, "channels", channels_obj);
}

err = qtest_qmp_assert_failure_ref(
who, "{ 'execute': 'migrate', 'arguments': %p}", args);
Expand Down
5 changes: 3 additions & 2 deletions tests/qtest/migration-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ G_GNUC_PRINTF(3, 4)
void migrate_incoming_qmp(QTestState *who, const char *uri,
const char *fmt, ...);

G_GNUC_PRINTF(3, 4)
void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...);
G_GNUC_PRINTF(4, 5)
void migrate_qmp_fail(QTestState *who, const char *uri,
const char *channels, const char *fmt, ...);

void migrate_set_capability(QTestState *who, const char *capability,
bool value);
Expand Down
4 changes: 2 additions & 2 deletions tests/qtest/migration-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ static void test_precopy_common(MigrateCommon *args)
}

if (args->result == MIG_TEST_QMP_ERROR) {
migrate_qmp_fail(from, args->connect_uri, "{}");
migrate_qmp_fail(from, args->connect_uri, NULL, "{}");
goto finish;
}

Expand Down Expand Up @@ -1812,7 +1812,7 @@ static void test_file_common(MigrateCommon *args, bool stop_src)
}

if (args->result == MIG_TEST_QMP_ERROR) {
migrate_qmp_fail(from, args->connect_uri, "{}");
migrate_qmp_fail(from, args->connect_uri, NULL, "{}");
goto finish;
}

Expand Down

0 comments on commit 387dc40

Please sign in to comment.