From patchwork Mon Oct 10 09:22:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 680307 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ssvtD4gczz9s3T for ; Mon, 10 Oct 2016 20:27:48 +1100 (AEDT) Received: from localhost ([::1]:48349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWs5-0005YH-BZ for incoming@patchwork.ozlabs.org; Mon, 10 Oct 2016 05:27:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWnf-0001rc-Ii for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:23:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btWnc-0002y6-Vx for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:23:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47272) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWnc-0002xt-MB for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:23:08 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3883E8E3F0 for ; Mon, 10 Oct 2016 09:23:08 +0000 (UTC) Received: from localhost (ovpn-116-23.phx2.redhat.com [10.3.116.23]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9A9N649000936; Mon, 10 Oct 2016 05:23:07 -0400 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 10 Oct 2016 13:22:38 +0400 Message-Id: <20161010092301.14974-2-marcandre.lureau@redhat.com> In-Reply-To: <20161010092301.14974-1-marcandre.lureau@redhat.com> References: <20161010092301.14974-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 10 Oct 2016 09:23:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 01/24] tests: start generic qemu-qmp tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" These 2 tests exhibit two qmp bugs fixed by the previous patches. Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrange Reviewed-by: Eric Blake 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 Signed-off-by: Markus Armbruster --- tests/qmp-test.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/Makefile.include | 2 ++ MAINTAINERS | 1 + 3 files changed, 82 insertions(+) create mode 100644 tests/qmp-test.c diff --git a/tests/qmp-test.c b/tests/qmp-test.c new file mode 100644 index 0000000..480ff28 --- /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("-machine none"); + + 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; +} diff --git a/tests/Makefile.include b/tests/Makefile.include index a77777c..b929c48 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -307,6 +307,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 @@ -650,6 +651,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/MAINTAINERS b/MAINTAINERS index a4d2dd4..41f4ea1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1285,6 +1285,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