qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: lvivier@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
	John Snow <jsnow@redhat.com>,
	qemu-block@nongnu.org, armbru@redhat.com,
	Thomas Huth <thuth@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	eblake@redhat.com, Hannes Reinecke <hare@suse.com>
Subject: [Qemu-devel] [PATCH for-4.1 3/5] tests/qmp-cmd-test: Use qtest_init() instead of qtest_start()
Date: Tue,  9 Apr 2019 10:52:43 +0200	[thread overview]
Message-ID: <20190409085245.31548-4-thuth@redhat.com> (raw)
In-Reply-To: <20190409085245.31548-1-thuth@redhat.com>

qtest_start() + qtest_end() should be avoided, since they use the
global_qtest variable that we want to get rid of in the long run
(since global_qtest can not be used in tests that have to track
multiple QEMU states, like migration tests). Use qtest_init() and
qtest_quit() instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qmp-cmd-test.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tests/qmp-cmd-test.c b/tests/qmp-cmd-test.c
index d12cac539c..9f5228cd99 100644
--- a/tests/qmp-cmd-test.c
+++ b/tests/qmp-cmd-test.c
@@ -61,10 +61,11 @@ static void test_query(const void *data)
     int expected_error_class = query_error_class(cmd);
     QDict *resp, *error;
     const char *error_class;
+    QTestState *qts;
 
-    qtest_start(common_args);
+    qts = qtest_init(common_args);
 
-    resp = qmp("{ 'execute': %s }", cmd);
+    resp = qtest_qmp(qts, "{ 'execute': %s }", cmd);
     error = qdict_get_qdict(resp, "error");
     error_class = error ? qdict_get_str(error, "class") : NULL;
 
@@ -78,7 +79,7 @@ static void test_query(const void *data)
     }
     qobject_unref(resp);
 
-    qtest_end();
+    qtest_quit(qts);
 }
 
 static bool query_is_blacklisted(const char *cmd)
@@ -118,16 +119,18 @@ static void qmp_schema_init(QmpSchema *schema)
     QDict *resp;
     Visitor *qiv;
     SchemaInfoList *tail;
+    QTestState *qts;
 
-    qtest_start(common_args);
-    resp = qmp("{ 'execute': 'query-qmp-schema' }");
+    qts = qtest_init(common_args);
+
+    resp = qtest_qmp(qts, "{ 'execute': 'query-qmp-schema' }");
 
     qiv = qobject_input_visitor_new(qdict_get(resp, "return"));
     visit_type_SchemaInfoList(qiv, NULL, &schema->list, &error_abort);
     visit_free(qiv);
 
     qobject_unref(resp);
-    qtest_end();
+    qtest_quit(qts);
 
     schema->hash = g_hash_table_new(g_str_hash, g_str_equal);
 
-- 
2.21.0

WARNING: multiple messages have this Message-ID (diff)
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: lvivier@redhat.com, Thomas Huth <thuth@redhat.com>,
	qemu-block@nongnu.org, armbru@redhat.com,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Hannes Reinecke <hare@suse.com>,
	Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>
Subject: [Qemu-devel] [PATCH for-4.1 3/5] tests/qmp-cmd-test: Use qtest_init() instead of qtest_start()
Date: Tue,  9 Apr 2019 10:52:43 +0200	[thread overview]
Message-ID: <20190409085245.31548-4-thuth@redhat.com> (raw)
Message-ID: <20190409085243.ZHLh167SzBg2ExK2_HeI1h2IfUMvKuI9yRbQ5lW0e8A@z> (raw)
In-Reply-To: <20190409085245.31548-1-thuth@redhat.com>

qtest_start() + qtest_end() should be avoided, since they use the
global_qtest variable that we want to get rid of in the long run
(since global_qtest can not be used in tests that have to track
multiple QEMU states, like migration tests). Use qtest_init() and
qtest_quit() instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qmp-cmd-test.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tests/qmp-cmd-test.c b/tests/qmp-cmd-test.c
index d12cac539c..9f5228cd99 100644
--- a/tests/qmp-cmd-test.c
+++ b/tests/qmp-cmd-test.c
@@ -61,10 +61,11 @@ static void test_query(const void *data)
     int expected_error_class = query_error_class(cmd);
     QDict *resp, *error;
     const char *error_class;
+    QTestState *qts;
 
-    qtest_start(common_args);
+    qts = qtest_init(common_args);
 
-    resp = qmp("{ 'execute': %s }", cmd);
+    resp = qtest_qmp(qts, "{ 'execute': %s }", cmd);
     error = qdict_get_qdict(resp, "error");
     error_class = error ? qdict_get_str(error, "class") : NULL;
 
@@ -78,7 +79,7 @@ static void test_query(const void *data)
     }
     qobject_unref(resp);
 
-    qtest_end();
+    qtest_quit(qts);
 }
 
 static bool query_is_blacklisted(const char *cmd)
@@ -118,16 +119,18 @@ static void qmp_schema_init(QmpSchema *schema)
     QDict *resp;
     Visitor *qiv;
     SchemaInfoList *tail;
+    QTestState *qts;
 
-    qtest_start(common_args);
-    resp = qmp("{ 'execute': 'query-qmp-schema' }");
+    qts = qtest_init(common_args);
+
+    resp = qtest_qmp(qts, "{ 'execute': 'query-qmp-schema' }");
 
     qiv = qobject_input_visitor_new(qdict_get(resp, "return"));
     visit_type_SchemaInfoList(qiv, NULL, &schema->list, &error_abort);
     visit_free(qiv);
 
     qobject_unref(resp);
-    qtest_end();
+    qtest_quit(qts);
 
     schema->hash = g_hash_table_new(g_str_hash, g_str_equal);
 
-- 
2.21.0



  parent reply	other threads:[~2019-04-09  8:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09  8:52 [Qemu-devel] [PATCH for-4.1 0/5] First batch of global_qtest-removement patches for QEMU 4.1 Thomas Huth
2019-04-09  8:52 ` Thomas Huth
2019-04-09  8:52 ` [Qemu-devel] [PATCH for-4.1 1/5] tests/tco: Make test independent of global_qtest Thomas Huth
2019-04-09  8:52   ` Thomas Huth
2019-04-09  8:52 ` [Qemu-devel] [PATCH for-4.1 2/5] tests/megasas: " Thomas Huth
2019-04-09  8:52   ` Thomas Huth
2019-04-09  8:52 ` Thomas Huth [this message]
2019-04-09  8:52   ` [Qemu-devel] [PATCH for-4.1 3/5] tests/qmp-cmd-test: Use qtest_init() instead of qtest_start() Thomas Huth
2019-04-09  8:52 ` [Qemu-devel] [PATCH for-4.1 4/5] tests/test-hmp: " Thomas Huth
2019-04-09  8:52   ` Thomas Huth
2019-04-09  9:09   ` Dr. David Alan Gilbert
2019-04-09  9:09     ` Dr. David Alan Gilbert
2019-04-09  8:52 ` [Qemu-devel] [PATCH for-4.1 5/5] tests/ide-test: Make test independent of global_qtest Thomas Huth
2019-04-09  8:52   ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190409085245.31548-4-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=hare@suse.com \
    --cc=jsnow@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).