mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
tests/qtest: migration: Add support for negative testing of qmp_migrate
There is currently no way to write a test for errors that happened in qmp_migrate before the migration has started. Add a version of qmp_migrate that ensures an error happens. To make use of it a test needs to set MigrateCommon.result as MIG_TEST_QMP_ERROR. Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Juan Quintela <quintela@redhat.com> Message-ID: <20230712190742.22294-6-farosas@suse.de>
This commit is contained in:
parent
4111a732e8
commit
5274274c26
5 changed files with 96 additions and 4 deletions
|
@ -697,6 +697,8 @@ typedef struct {
|
|||
MIG_TEST_FAIL,
|
||||
/* This test should fail, dest qemu should fail with abnormal status */
|
||||
MIG_TEST_FAIL_DEST_QUIT_ERR,
|
||||
/* The QMP command for this migration should fail with an error */
|
||||
MIG_TEST_QMP_ERROR,
|
||||
} result;
|
||||
|
||||
/*
|
||||
|
@ -1503,6 +1505,7 @@ static void test_precopy_common(MigrateCommon *args)
|
|||
{
|
||||
QTestState *from, *to;
|
||||
void *data_hook = NULL;
|
||||
g_autofree char *connect_uri = NULL;
|
||||
|
||||
if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) {
|
||||
return;
|
||||
|
@ -1537,13 +1540,17 @@ static void test_precopy_common(MigrateCommon *args)
|
|||
}
|
||||
|
||||
if (!args->connect_uri) {
|
||||
g_autofree char *local_connect_uri =
|
||||
migrate_get_socket_address(to, "socket-address");
|
||||
migrate_qmp(from, local_connect_uri, "{}");
|
||||
connect_uri = migrate_get_socket_address(to, "socket-address");
|
||||
} else {
|
||||
migrate_qmp(from, args->connect_uri, "{}");
|
||||
connect_uri = g_strdup(args->connect_uri);
|
||||
}
|
||||
|
||||
if (args->result == MIG_TEST_QMP_ERROR) {
|
||||
migrate_qmp_fail(from, connect_uri, "{}");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
migrate_qmp(from, connect_uri, "{}");
|
||||
|
||||
if (args->result != MIG_TEST_SUCCEED) {
|
||||
bool allow_active = args->result == MIG_TEST_FAIL;
|
||||
|
@ -1595,6 +1602,7 @@ static void test_precopy_common(MigrateCommon *args)
|
|||
wait_for_serial("dest_serial");
|
||||
}
|
||||
|
||||
finish:
|
||||
if (args->finish_hook) {
|
||||
args->finish_hook(from, to, data_hook);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue