提交 6a7724e9 编写于 作者: J Juan Quintela 提交者: Dr. David Alan Gilbert

tests: Adjust sleeps for migration test

Also reorder code to not sleep when event already happened.
Signed-off-by: NJuan Quintela <quintela@redhat.com>
Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: NPeter Xu <peterx@redhat.com>
Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
上级 eb665d7d
...@@ -268,10 +268,9 @@ static uint64_t get_migration_pass(QTestState *who) ...@@ -268,10 +268,9 @@ static uint64_t get_migration_pass(QTestState *who)
static void wait_for_migration_complete(QTestState *who) static void wait_for_migration_complete(QTestState *who)
{ {
QDict *rsp, *rsp_return; while (true) {
bool completed; QDict *rsp, *rsp_return;
bool completed;
do {
const char *status; const char *status;
rsp = wait_command(who, "{ 'execute': 'query-migrate' }"); rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
...@@ -280,8 +279,11 @@ static void wait_for_migration_complete(QTestState *who) ...@@ -280,8 +279,11 @@ static void wait_for_migration_complete(QTestState *who)
completed = strcmp(status, "completed") == 0; completed = strcmp(status, "completed") == 0;
g_assert_cmpstr(status, !=, "failed"); g_assert_cmpstr(status, !=, "failed");
QDECREF(rsp); QDECREF(rsp);
usleep(1000 * 100); if (completed) {
} while (!completed); return;
}
usleep(1000);
}
} }
static void wait_for_migration_pass(QTestState *who) static void wait_for_migration_pass(QTestState *who)
...@@ -290,16 +292,13 @@ static void wait_for_migration_pass(QTestState *who) ...@@ -290,16 +292,13 @@ static void wait_for_migration_pass(QTestState *who)
uint64_t pass; uint64_t pass;
/* Wait for the 1st sync */ /* Wait for the 1st sync */
do { while (!got_stop && !initial_pass) {
usleep(1000);
initial_pass = get_migration_pass(who); initial_pass = get_migration_pass(who);
if (got_stop || initial_pass) { }
break;
}
usleep(1000 * 100);
} while (true);
do { do {
usleep(1000 * 100); usleep(1000);
pass = get_migration_pass(who); pass = get_migration_pass(who);
} while (pass == initial_pass && !got_stop); } while (pass == initial_pass && !got_stop);
} }
...@@ -489,13 +488,13 @@ static void test_migrate_end(QTestState *from, QTestState *to) ...@@ -489,13 +488,13 @@ static void test_migrate_end(QTestState *from, QTestState *to)
/* Destination still running, wait for a byte to change */ /* Destination still running, wait for a byte to change */
do { do {
qtest_memread(to, start_address, &dest_byte_b, 1); qtest_memread(to, start_address, &dest_byte_b, 1);
usleep(10 * 1000); usleep(1000 * 10);
} while (dest_byte_a == dest_byte_b); } while (dest_byte_a == dest_byte_b);
qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}"); qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}");
/* With it stopped, check nothing changes */ /* With it stopped, check nothing changes */
qtest_memread(to, start_address, &dest_byte_c, 1); qtest_memread(to, start_address, &dest_byte_c, 1);
sleep(1); usleep(1000 * 200);
qtest_memread(to, start_address, &dest_byte_d, 1); qtest_memread(to, start_address, &dest_byte_d, 1);
g_assert_cmpint(dest_byte_c, ==, dest_byte_d); g_assert_cmpint(dest_byte_c, ==, dest_byte_d);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册