qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL 9/9] tests/libqtest: Make qmp_assert_success() independent from global_qtest
Date: Thu, 15 Aug 2019 19:59:22 +0200	[thread overview]
Message-ID: <20190815175922.3475-10-thuth@redhat.com> (raw)
In-Reply-To: <20190815175922.3475-1-thuth@redhat.com>

The normal libqtest library functions should never depend on global_qtest.
Pass in the test state via parameter instead. And while we're at it,
also rename this function to qtest_qmp_assert_success() to make it clear
that it is part of libqtest.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190813093047.27948-7-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/libqtest.c         |  4 ++--
 tests/libqtest.h         |  6 ++++--
 tests/virtio-scsi-test.c | 10 ++++++----
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 19c1fc2e97..eb971d0d11 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -1111,13 +1111,13 @@ QDict *qmp(const char *fmt, ...)
     return response;
 }
 
-void qmp_assert_success(const char *fmt, ...)
+void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
 {
     va_list ap;
     QDict *response;
 
     va_start(ap, fmt);
-    response = qtest_vqmp(global_qtest, fmt, ap);
+    response = qtest_vqmp(qts, fmt, ap);
     va_end(ap);
 
     g_assert(response);
diff --git a/tests/libqtest.h b/tests/libqtest.h
index d93144fb74..7833148358 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -666,7 +666,8 @@ static inline void qtest_end(void)
 QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
 
 /**
- * qmp_assert_success:
+ * qtest_qmp_assert_success:
+ * @qts: QTestState instance to operate on
  * @fmt...: QMP message to send to qemu, formatted like
  * qobject_from_jsonf_nofail().  See parse_escape() for what's
  * supported after '%'.
@@ -674,7 +675,8 @@ QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
  * Sends a QMP message to QEMU and asserts that a 'return' key is present in
  * the response.
  */
-void qmp_assert_success(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
+    GCC_FMT_ATTR(2, 3);
 
 /*
  * qmp_eventwait:
diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c
index 16481491e3..09348765d7 100644
--- a/tests/virtio-scsi-test.c
+++ b/tests/virtio-scsi-test.c
@@ -225,10 +225,12 @@ static void test_iothread_attach_node(void *obj, void *data,
     mkqcow2(tmp_path, 64);
 
     /* Attach the overlay to the null0 node */
-    qmp_assert_success("{'execute': 'blockdev-add', 'arguments': {"
-                       "   'driver': 'qcow2', 'node-name': 'overlay',"
-                       "   'backing': 'null0', 'file': {"
-                       "     'driver': 'file', 'filename': %s}}}", tmp_path);
+    qtest_qmp_assert_success(scsi_pci->pci_vdev.pdev->bus->qts,
+                             "{'execute': 'blockdev-add', 'arguments': {"
+                             "   'driver': 'qcow2', 'node-name': 'overlay',"
+                             "   'backing': 'null0', 'file': {"
+                             "     'driver': 'file', 'filename': %s}}}",
+                             tmp_path);
 
     /* Send a request to see if the AioContext is still right */
     ret = virtio_scsi_do_command(vs, write_cdb, NULL, 0, buf, 512, NULL);
-- 
2.18.1



  parent reply	other threads:[~2019-08-15 18:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15 17:59 [Qemu-devel] [PULL 0/9] qtest patches Thomas Huth
2019-08-15 17:59 ` [Qemu-devel] [PULL 1/9] qtest: Rename qtest.c:qtest_init() Thomas Huth
2019-08-15 17:59 ` [Qemu-devel] [PULL 2/9] libqos: Account for the ctrl queue in virtio-net Thomas Huth
2019-08-15 17:59 ` [Qemu-devel] [PULL 3/9] tests: Set read-zeroes on for null-co driver Thomas Huth
2019-08-15 17:59 ` [Qemu-devel] [PULL 4/9] tests/libqos: Make generic virtio code independent from global_qtest Thomas Huth
2019-08-15 17:59 ` [Qemu-devel] [PULL 5/9] tests/libqos: Make virtio-pci " Thomas Huth
2019-08-15 17:59 ` [Qemu-devel] [PULL 6/9] tests/libqtest: Remove unused function hmp() Thomas Huth
2019-08-15 17:59 ` [Qemu-devel] [PULL 7/9] tests/libqtest: Clean up qtest_cb_for_every_machine() wrt global_qtest Thomas Huth
2019-08-15 17:59 ` [Qemu-devel] [PULL 8/9] tests/libqtest: Make qtest_qmp_device_add/del independent from global_qtest Thomas Huth
2019-08-15 17:59 ` Thomas Huth [this message]
2019-08-15 18:17 ` [Qemu-devel] [PULL 0/9] qtest patches no-reply
2019-08-15 18:34   ` Thomas Huth
2019-08-16 13:53 ` Peter Maydell

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=20190815175922.3475-10-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.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).