From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PULL 04/12] tests: start generic qemu-qmp tests
Date: Fri, 7 Oct 2016 14:09:11 +0200 [thread overview]
Message-ID: <1475842159-26039-5-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1475842159-26039-1-git-send-email-armbru@redhat.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
These 2 tests exhibit two qmp bugs fixed by the previous patches.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20160922203927.28241-4-marcandre.lureau@redhat.com>
[Rename tests/test-qemu-qmp.c to tests/qmp-test.c, cover it in
MAINTAINERS, add a file comment]
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
MAINTAINERS | 1 +
tests/Makefile.include | 2 ++
tests/qmp-test.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+)
create mode 100644 tests/qmp-test.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 76a0fdb..7851d0f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1284,6 +1284,7 @@ F: qmp.c
F: monitor.c
F: docs/*qmp-*
F: scripts/qmp/
+F: tests/qmp-test.c
T: git git://repo.or.cz/qemu/armbru.git qapi-next
Register API
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 8162f6f..fcacd06 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -300,6 +300,7 @@ check-qtest-s390x-y = tests/boot-serial-test$(EXESUF)
check-qtest-generic-y += tests/qom-test$(EXESUF)
check-qtest-generic-y += tests/ptimer-test$(EXESUF)
+check-qtest-generic-y += tests/qmp-test$(EXESUF)
qapi-schema += alternate-any.json
qapi-schema += alternate-array.json
@@ -642,6 +643,7 @@ tests/tpci200-test$(EXESUF): tests/tpci200-test.o
tests/display-vga-test$(EXESUF): tests/display-vga-test.o
tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o
tests/qom-test$(EXESUF): tests/qom-test.o
+tests/qmp-test$(EXESUF): tests/qmp-test.o
tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-pc-obj-y)
tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y)
tests/nvme-test$(EXESUF): tests/nvme-test.o
diff --git a/tests/qmp-test.c b/tests/qmp-test.c
new file mode 100644
index 0000000..2b88bff
--- /dev/null
+++ b/tests/qmp-test.c
@@ -0,0 +1,79 @@
+/*
+ * QTest testcase for QMP
+ *
+ * Copyright (c) 2016 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+/*
+ * This program tests QMP commands maintained with the QMP core.
+ * These are defined in qmp.c. Tests for QMP commands defined in
+ * another subsystem should go into a test program maintained with
+ * that subsystem.
+ *
+ * TODO Actually cover the commands. The tests we got so far only
+ * demonstrate specific bugs we've fixed.
+ */
+
+#include "qemu/osdep.h"
+#include "libqtest.h"
+
+static void test_object_add_without_props(void)
+{
+ QDict *ret, *error;
+ const gchar *klass, *desc;
+
+ ret = qmp("{'execute': 'object-add',"
+ " 'arguments': { 'qom-type': 'memory-backend-ram', 'id': 'ram1' } }");
+ g_assert_nonnull(ret);
+
+ error = qdict_get_qdict(ret, "error");
+ klass = qdict_get_try_str(error, "class");
+ desc = qdict_get_try_str(error, "desc");
+
+ g_assert_cmpstr(klass, ==, "GenericError");
+ g_assert_cmpstr(desc, ==, "can't create backend with size 0");
+
+ QDECREF(ret);
+}
+
+static void test_qom_set_without_value(void)
+{
+ QDict *ret, *error;
+ const gchar *klass, *desc;
+
+ ret = qmp("{'execute': 'qom-set',"
+ " 'arguments': { 'path': '/machine', 'property': 'rtc-time' } }");
+ g_assert_nonnull(ret);
+
+ error = qdict_get_qdict(ret, "error");
+ klass = qdict_get_try_str(error, "class");
+ desc = qdict_get_try_str(error, "desc");
+
+ g_assert_cmpstr(klass, ==, "GenericError");
+ g_assert_cmpstr(desc, ==, "Parameter 'value' is missing");
+
+ QDECREF(ret);
+}
+
+int main(int argc, char **argv)
+{
+ int ret;
+
+ g_test_init(&argc, &argv, NULL);
+
+ qtest_start("");
+
+ qtest_add_func("/qemu-qmp/object-add-without-props",
+ test_object_add_without_props);
+ qtest_add_func("/qemu-qmp/qom-set-without-value",
+ test_qom_set_without_value);
+
+ ret = g_test_run();
+
+ qtest_end();
+
+ return ret;
+}
--
2.5.5
next prev parent reply other threads:[~2016-10-07 12:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-07 12:09 [Qemu-devel] [PULL 00/12] QAPI patches for 2016-10-07 Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 01/12] qmp: fix object-add assert() without props Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 02/12] qapi: Fix crash when 'any' or 'null' parameter is missing Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 03/12] tests/test-qmp-input-strict: Cover missing struct members Markus Armbruster
2016-10-07 12:09 ` Markus Armbruster [this message]
2016-10-07 12:09 ` [Qemu-devel] [PULL 05/12] qapi: add assert about root value Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 06/12] qapi: assert list entry has a value Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 07/12] qapi: return a 'missing parameter' error Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 08/12] MAINTAINERS: Pass the HMP staff from Luiz to David Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 09/12] MAINTAINERS: Pass the QObject staff from Luiz to Markus Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 10/12] qmp: Disable query-cpu-* commands when they're unavailable Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 11/12] docs: Belatedly update for move of qmp-commands.txt Markus Armbruster
2016-10-07 12:09 ` [Qemu-devel] [PULL 12/12] docs: Belatedly update for move of QMP/* to docs/ Markus Armbruster
2016-10-07 14:14 ` [Qemu-devel] [PULL 00/12] QAPI patches for 2016-10-07 Peter Maydell
2016-10-07 18:16 ` Markus Armbruster
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=1475842159-26039-5-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--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).