From 56b4a42a2e0ae74cee629abcb82993e79deeb356 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Wed, 25 Oct 2017 17:13:37 +0200 Subject: tests: check that migration parameters are really assigned Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- tests/migration-test.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index c429a13403..be598d3257 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -354,17 +354,37 @@ static void cleanup(const char *filename) g_free(path); } -static void migrate_set_downtime(QTestState *who, const char *value) +static void migrate_check_parameter(QTestState *who, const char *parameter, + const char *value) +{ + QDict *rsp, *rsp_return; + const char *result; + + rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + rsp_return = qdict_get_qdict(rsp, "return"); + result = g_strdup_printf("%" PRId64, + qdict_get_try_int(rsp_return, parameter, -1)); + g_assert_cmpstr(result, ==, value); + QDECREF(rsp); +} + +static void migrate_set_downtime(QTestState *who, const double value) { QDict *rsp; gchar *cmd; + char *expected; + int64_t result_int; cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime'," - "'arguments': { 'value': %s } }", value); + "'arguments': { 'value': %g } }", value); rsp = qtest_qmp(who, cmd); g_free(cmd); g_assert(qdict_haskey(rsp, "return")); QDECREF(rsp); + result_int = value * 1000L; + expected = g_strdup_printf("%" PRId64, result_int); + migrate_check_parameter(who, "downtime-limit", expected); + g_free(expected); } static void migrate_set_speed(QTestState *who, const char *value) @@ -378,6 +398,7 @@ static void migrate_set_speed(QTestState *who, const char *value) g_free(cmd); g_assert(qdict_haskey(rsp, "return")); QDECREF(rsp); + migrate_check_parameter(who, "max-bandwidth", value); } static void migrate_set_capability(QTestState *who, const char *capability, @@ -509,7 +530,7 @@ static void test_migrate(void) * machine, so also set the downtime. */ migrate_set_speed(from, "100000000"); - migrate_set_downtime(from, "0.001"); + migrate_set_downtime(from, 0.001); /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); -- cgit v1.2.3