diff mbox series

[v2,03/10] migration-test: introduce functions to handle string parameters

Message ID 20191218020119.3776-4-quintela@redhat.com (mailing list archive)
State New, archived
Headers show
Series Multifd Migration Compression | expand

Commit Message

Juan Quintela Dec. 18, 2019, 2:01 a.m. UTC
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

Comments

Dr. David Alan Gilbert Jan. 3, 2020, 4:57 p.m. UTC | #1
* Juan Quintela (quintela@redhat.com) wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

(I'm surprised we don't need to quote the %s's in qtest_qmp, but it
seems that we never do it in any other of the qtest_qmp calls that I can
see when we use %s.

Dave

> ---
>  tests/migration-test.c | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 1c9f2c4e6a..fc221f172a 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -460,6 +460,43 @@ static void migrate_set_parameter_int(QTestState *who, const char *parameter,
>      migrate_check_parameter_int(who, parameter, value);
>  }
>  
> +static char *migrate_get_parameter_str(QTestState *who,
> +                                       const char *parameter)
> +{
> +    QDict *rsp;
> +    char *result;
> +
> +    rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
> +    result = g_strdup(qdict_get_str(rsp, parameter));
> +    qobject_unref(rsp);
> +    return result;
> +}
> +
> +static void migrate_check_parameter_str(QTestState *who, const char *parameter,
> +                                        const char *value)
> +{
> +    char *result;
> +
> +    result = migrate_get_parameter_str(who, parameter);
> +    g_assert_cmpstr(result, ==, value);
> +    g_free(result);
> +}
> +
> +__attribute__((unused))
> +static void migrate_set_parameter_str(QTestState *who, const char *parameter,
> +                                      const char *value)
> +{
> +    QDict *rsp;
> +
> +    rsp = qtest_qmp(who,
> +                    "{ 'execute': 'migrate-set-parameters',"
> +                    "'arguments': { %s: %s } }",
> +                    parameter, value);
> +    g_assert(qdict_haskey(rsp, "return"));
> +    qobject_unref(rsp);
> +    migrate_check_parameter_str(who, parameter, value);
> +}
> +
>  static void migrate_pause(QTestState *who)
>  {
>      QDict *rsp;
> -- 
> 2.23.0
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff mbox series

Patch

diff --git a/tests/migration-test.c b/tests/migration-test.c
index 1c9f2c4e6a..fc221f172a 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -460,6 +460,43 @@  static void migrate_set_parameter_int(QTestState *who, const char *parameter,
     migrate_check_parameter_int(who, parameter, value);
 }
 
+static char *migrate_get_parameter_str(QTestState *who,
+                                       const char *parameter)
+{
+    QDict *rsp;
+    char *result;
+
+    rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
+    result = g_strdup(qdict_get_str(rsp, parameter));
+    qobject_unref(rsp);
+    return result;
+}
+
+static void migrate_check_parameter_str(QTestState *who, const char *parameter,
+                                        const char *value)
+{
+    char *result;
+
+    result = migrate_get_parameter_str(who, parameter);
+    g_assert_cmpstr(result, ==, value);
+    g_free(result);
+}
+
+__attribute__((unused))
+static void migrate_set_parameter_str(QTestState *who, const char *parameter,
+                                      const char *value)
+{
+    QDict *rsp;
+
+    rsp = qtest_qmp(who,
+                    "{ 'execute': 'migrate-set-parameters',"
+                    "'arguments': { %s: %s } }",
+                    parameter, value);
+    g_assert(qdict_haskey(rsp, "return"));
+    qobject_unref(rsp);
+    migrate_check_parameter_str(who, parameter, value);
+}
+
 static void migrate_pause(QTestState *who)
 {
     QDict *rsp;