tests: introduce wait_for_migration_status()

It's generalized from wait_for_migration_complete() to allow us to wait
for any migration status besides failure.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Balamuruhan S <bala24@linux.vnet.ibm.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20180710091902.28780-9-peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
Peter Xu 2018-07-10 17:19:00 +08:00 committed by Dr. David Alan Gilbert
parent 2f7074c6fd
commit 2f6d313836

View File

@ -231,14 +231,15 @@ static void read_blocktime(QTestState *who)
qobject_unref(rsp_return);
}
static void wait_for_migration_complete(QTestState *who)
static void wait_for_migration_status(QTestState *who,
const char *goal)
{
while (true) {
bool completed;
char *status;
status = migrate_query_status(who);
completed = strcmp(status, "completed") == 0;
completed = strcmp(status, goal) == 0;
g_assert_cmpstr(status, !=, "failed");
g_free(status);
if (completed) {
@ -248,6 +249,11 @@ static void wait_for_migration_complete(QTestState *who)
}
}
static void wait_for_migration_complete(QTestState *who)
{
wait_for_migration_status(who, "completed");
}
static void wait_for_migration_pass(QTestState *who)
{
uint64_t initial_pass = get_migration_pass(who);