[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 10/11] tests: Adjust sleeps for migration tes
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH v4 10/11] tests: Adjust sleeps for migration test |
Date: |
Thu, 11 Jan 2018 10:56:21 +0000 |
User-agent: |
Mutt/1.9.1 (2017-09-22) |
* Juan Quintela (address@hidden) wrote:
> Also reorder code to not sleep when event already happened.
>
> Signed-off-by: Juan Quintela <address@hidden>
> ---
> tests/migration-test.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 70b3c0870b..8914829006 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -280,10 +280,9 @@ static void read_blocktime(QTestState *who)
>
> static void wait_for_migration_complete(QTestState *who)
> {
> - QDict *rsp, *rsp_return;
> - bool completed;
> -
> - do {
> + while (true) {
> + QDict *rsp, *rsp_return;
> + bool completed;
> const char *status;
>
> rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
> @@ -292,8 +291,11 @@ static void wait_for_migration_complete(QTestState *who)
> completed = strcmp(status, "completed") == 0;
> g_assert_cmpstr(status, !=, "failed");
> QDECREF(rsp);
> - usleep(1000 * 100);
> - } while (!completed);
> + if (completed) {
> + return;
> + }
> + usleep(1000);
> + }
OK, so that's mostly about avoiding a sleep in the exit from the normal
path.
> }
>
> static void wait_for_migration_pass(QTestState *who)
> @@ -302,16 +304,13 @@ static void wait_for_migration_pass(QTestState *who)
> uint64_t pass;
>
> /* Wait for the 1st sync */
> - do {
> + while (!got_stop && !initial_pass) {
> + usleep(1000);
> initial_pass = get_migration_pass(who);
> - if (got_stop || initial_pass) {
> - break;
> - }
> - usleep(1000 * 100);
> - } while (true);
> + }
>
> do {
> - usleep(1000 * 100);
> + usleep(1000);
> pass = get_migration_pass(who);
> } while (pass == initial_pass && !got_stop);
> }
OK
> @@ -510,13 +509,13 @@ static void test_migrate_end(QTestState *from,
> QTestState *to)
> /* Destination still running, wait for a byte to change */
> do {
> qtest_memread(to, start_address, &dest_byte_b, 1);
> - usleep(10 * 1000);
> + usleep(1000 * 10);
Profound :-)
> } while (dest_byte_a == dest_byte_b);
>
> qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}");
> /* With it stopped, check nothing changes */
> qtest_memread(to, start_address, &dest_byte_c, 1);
> - sleep(1);
> + usleep(1000 * 200);
OK
> qtest_memread(to, start_address, &dest_byte_d, 1);
> g_assert_cmpint(dest_byte_c, ==, dest_byte_d);
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
> --
> 2.14.3
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- Re: [Qemu-devel] [PATCH v4 04/11] tests: Use consistent names and sizes for migration, (continued)
- [Qemu-devel] [PATCH v4 08/11] tests: Add migration xbzrle test, Juan Quintela, 2018/01/05
- [Qemu-devel] [PATCH v4 10/11] tests: Adjust sleeps for migration test, Juan Quintela, 2018/01/05
- Re: [Qemu-devel] [PATCH v4 10/11] tests: Adjust sleeps for migration test,
Dr. David Alan Gilbert <=
- [Qemu-devel] [PATCH v4 09/11] tests: Create migrate-start-postcopy command, Juan Quintela, 2018/01/05
- [Qemu-devel] [PATCH v4 11/11] [RFH] tests: Add migration compress threads tests, Juan Quintela, 2018/01/05
- Re: [Qemu-devel] [PATCH v4 00/11] Add make check tests for Migration, Peter Xu, 2018/01/10