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: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PULL 9/9] tests: add a qmp success-response test
Date: Fri, 31 Aug 2018 10:38:58 +0200	[thread overview]
Message-ID: <1535704738-8986-10-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1535704738-8986-1-git-send-email-thuth@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Verify the usage of this schema feature and the API behaviour.  This
should be the only case where qmp_dispatch() returns NULL.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qapi-schema/qapi-schema-test.json |  2 ++
 tests/qapi-schema/qapi-schema-test.out  |  2 ++
 tests/test-qmp-cmds.c                   | 17 +++++++++++++++++
 3 files changed, 21 insertions(+)

diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index 11aa4c8..fb03163 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -137,6 +137,8 @@
   'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'},
   'returns': 'UserDefTwo' }
 
+{ 'command': 'cmd-success-response', 'data': {}, 'success-response': false }
+
 # Returning a non-dictionary requires a name from the whitelist
 { 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' },
   'returns': 'int' }
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 0da9245..218ac7d 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -156,6 +156,8 @@ object q_obj_user_def_cmd2-arg
     member ud1b: UserDefOne optional=True
 command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo
    gen=True success_response=True boxed=False oob=False preconfig=False
+command cmd-success-response None -> None
+   gen=True success_response=False boxed=False oob=False preconfig=False
 object q_obj_guest-get-time-arg
     member a: int optional=False
     member b: int optional=True
diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c
index ab414fa..4ab2b6e 100644
--- a/tests/test-qmp-cmds.c
+++ b/tests/test-qmp-cmds.c
@@ -32,6 +32,10 @@ void qmp_test_flags_command(Error **errp)
 {
 }
 
+void qmp_cmd_success_response(Error **errp)
+{
+}
+
 Empty2 *qmp_user_def_cmd0(Error **errp)
 {
     return g_new0(Empty2, 1);
@@ -153,6 +157,17 @@ static void test_dispatch_cmd_failure(void)
     qobject_unref(req);
 }
 
+static void test_dispatch_cmd_success_response(void)
+{
+    QDict *req = qdict_new();
+    QDict *resp;
+
+    qdict_put_str(req, "execute", "cmd-success-response");
+    resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
+    g_assert_null(resp);
+    qobject_unref(req);
+}
+
 static QObject *test_qmp_dispatch(QDict *req)
 {
     QDict *resp;
@@ -289,6 +304,8 @@ int main(int argc, char **argv)
     g_test_add_func("/qmp/dispatch_cmd", test_dispatch_cmd);
     g_test_add_func("/qmp/dispatch_cmd_failure", test_dispatch_cmd_failure);
     g_test_add_func("/qmp/dispatch_cmd_io", test_dispatch_cmd_io);
+    g_test_add_func("/qmp/dispatch_cmd_success_response",
+                    test_dispatch_cmd_success_response);
     g_test_add_func("/qmp/dealloc_types", test_dealloc_types);
     g_test_add_func("/qmp/dealloc_partial", test_dealloc_partial);
 
-- 
1.8.3.1

      parent reply	other threads:[~2018-08-31  8:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-31  8:38 [Qemu-devel] [PULL 0/9] Removal of deprecated options and improvements for qtests Thomas Huth
2018-08-31  8:38 ` [Qemu-devel] [PULL 1/9] Remove the deprecated -balloon option Thomas Huth
2018-08-31  8:38 ` [Qemu-devel] [PULL 2/9] Remove the deprecated -nodefconfig option Thomas Huth
2018-08-31  8:38 ` [Qemu-devel] [PULL 3/9] Remove the deprecated options -startdate, -localtime and -rtc-td-hack Thomas Huth
2018-08-31  8:38 ` [Qemu-devel] [PULL 4/9] net: Remove the deprecated -tftp, -bootp, -redir and -smb options Thomas Huth
2018-08-31  8:38 ` [Qemu-devel] [PULL 5/9] tests/libqos: Utilize newer glib spawn check Thomas Huth
2018-08-31  8:38 ` [Qemu-devel] [PULL 6/9] tests: add qmp_assert_error_class() Thomas Huth
2018-08-31  8:38 ` [Qemu-devel] [PULL 7/9] tests: add qmp/object-add-without-props test Thomas Huth
2018-08-31  8:38 ` [Qemu-devel] [PULL 8/9] tests: add qmp/qom-set-without-value test Thomas Huth
2018-08-31 12:04   ` Markus Armbruster
2018-08-31 13:18     ` Thomas Huth
2018-08-31 13:24       ` Marc-André Lureau
2018-08-31 13:40         ` Thomas Huth
2018-08-31 14:35           ` Markus Armbruster
2018-09-03  4:45             ` Thomas Huth
2018-10-09 16:41             ` Markus Armbruster
2018-10-29  6:49               ` Marc-André Lureau
2018-10-29  8:38                 ` Markus Armbruster
2018-08-31  8:38 ` Thomas Huth [this message]

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=1535704738-8986-10-git-send-email-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=eblake@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@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).