From nobody Wed Nov 5 14:50:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535645392108577.8175816091791; Thu, 30 Aug 2018 09:09:52 -0700 (PDT) Received: from localhost ([::1]:49749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPW2-0002fm-NO for importer@patchew.org; Thu, 30 Aug 2018 12:09:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPKt-0000uP-PG for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvPKs-0002OO-Gh for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:19 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55086 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvPKs-0002OB-9Y for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:18 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7C7640216E6; Thu, 30 Aug 2018 15:58:17 +0000 (UTC) Received: from localhost (ovpn-112-18.ams2.redhat.com [10.36.112.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BC3F101040B; Thu, 30 Aug 2018 15:58:15 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 17:58:07 +0200 Message-Id: <20180830155810.17629-2-marcandre.lureau@redhat.com> In-Reply-To: <20180830155810.17629-1-marcandre.lureau@redhat.com> References: <20180830155810.17629-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 30 Aug 2018 15:58:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 30 Aug 2018 15:58:17 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v5 1/4] tests: add qmp_assert_error_class() 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: Laurent Vivier , Thomas Huth , Markus Armbruster , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This helper will simplify a bunch of code checking for QMP errors and can be shared by various tests. Note that test-qga does check for error description as well, so don't replace the code there for now. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth --- tests/libqtest.h | 9 ++++++ tests/drive_del-test.c | 5 +-- tests/libqtest.c | 11 +++++++ tests/qmp-test.c | 73 +++++++++++++----------------------------- tests/test-qga.c | 9 ++---- 5 files changed, 46 insertions(+), 61 deletions(-) diff --git a/tests/libqtest.h b/tests/libqtest.h index 36d5caecd4..ed88ff99d5 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -1004,4 +1004,13 @@ void qtest_qmp_device_del(const char *id); */ bool qmp_rsp_is_err(QDict *rsp); =20 +/** + * qmp_assert_error_class: + * @rsp: QMP response to check for error + * @class: an error class + * + * Assert the response has the given error class and discard @rsp. + */ +void qmp_assert_error_class(QDict *rsp, const char *class); + #endif diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c index 673c10140f..4a1a0889c8 100644 --- a/tests/drive_del-test.c +++ b/tests/drive_del-test.c @@ -67,7 +67,6 @@ static void test_after_failed_device_add(void) { char driver[32]; QDict *response; - QDict *error; =20 snprintf(driver, sizeof(driver), "virtio-blk-%s", qvirtio_get_dev_type()); @@ -83,9 +82,7 @@ static void test_after_failed_device_add(void) " 'drive': 'drive0'" "}}", driver); g_assert(response); - error =3D qdict_get_qdict(response, "error"); - g_assert_cmpstr(qdict_get_try_str(error, "class"), =3D=3D, "GenericErr= or"); - qobject_unref(response); + qmp_assert_error_class(response, "GenericError"); =20 /* Delete the drive */ drive_del(); diff --git a/tests/libqtest.c b/tests/libqtest.c index d635c5bea0..2cd5736642 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1194,3 +1194,14 @@ bool qmp_rsp_is_err(QDict *rsp) qobject_unref(rsp); return !!error; } + +void qmp_assert_error_class(QDict *rsp, const char *class) +{ + QDict *error =3D qdict_get_qdict(rsp, "error"); + + g_assert_cmpstr(qdict_get_try_str(error, "class"), =3D=3D, class); + g_assert_nonnull(qdict_get_try_str(error, "desc")); + g_assert(!qdict_haskey(rsp, "return")); + + qobject_unref(rsp); +} diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 4ae2245484..b3472281ae 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -21,15 +21,6 @@ =20 const char common_args[] =3D "-nodefaults -machine none"; =20 -static const char *get_error_class(QDict *resp) -{ - QDict *error =3D qdict_get_qdict(resp, "error"); - const char *desc =3D qdict_get_try_str(error, "desc"); - - g_assert(desc); - return error ? qdict_get_try_str(error, "class") : NULL; -} - static void test_version(QObject *version) { Visitor *v; @@ -42,15 +33,12 @@ static void test_version(QObject *version) visit_free(v); } =20 -static bool recovered(QTestState *qts) +static void assert_recovered(QTestState *qts) { QDict *resp; - bool ret; =20 resp =3D qtest_qmp(qts, "{ 'execute': 'no-such-cmd' }"); - ret =3D !strcmp(get_error_class(resp), "CommandNotFound"); - qobject_unref(resp); - return ret; + qmp_assert_error_class(resp, "CommandNotFound"); } =20 static void test_malformed(QTestState *qts) @@ -60,73 +48,61 @@ static void test_malformed(QTestState *qts) /* syntax error */ qtest_qmp_send_raw(qts, "{]\n"); resp =3D qtest_qmp_receive(qts); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); - g_assert(recovered(qts)); + qmp_assert_error_class(resp, "GenericError"); + assert_recovered(qts); =20 /* lexical error: impossible byte outside string */ qtest_qmp_send_raw(qts, "{\xFF"); resp =3D qtest_qmp_receive(qts); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); - g_assert(recovered(qts)); + qmp_assert_error_class(resp, "GenericError"); + assert_recovered(qts); =20 /* lexical error: funny control character outside string */ qtest_qmp_send_raw(qts, "{\x01"); resp =3D qtest_qmp_receive(qts); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); - g_assert(recovered(qts)); + qmp_assert_error_class(resp, "GenericError"); + assert_recovered(qts); =20 /* lexical error: impossible byte in string */ qtest_qmp_send_raw(qts, "{'bad \xFF"); resp =3D qtest_qmp_receive(qts); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); - g_assert(recovered(qts)); + qmp_assert_error_class(resp, "GenericError"); + assert_recovered(qts); =20 /* lexical error: control character in string */ qtest_qmp_send_raw(qts, "{'execute': 'nonexistent', 'id':'\n"); resp =3D qtest_qmp_receive(qts); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); - g_assert(recovered(qts)); + qmp_assert_error_class(resp, "GenericError"); + assert_recovered(qts); =20 /* lexical error: interpolation */ qtest_qmp_send_raw(qts, "%%p\n"); /* two errors, one for "%", one for "p" */ resp =3D qtest_qmp_receive(qts); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); + qmp_assert_error_class(resp, "GenericError"); resp =3D qtest_qmp_receive(qts); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); - g_assert(recovered(qts)); + qmp_assert_error_class(resp, "GenericError"); + assert_recovered(qts); =20 /* Not even a dictionary */ resp =3D qtest_qmp(qts, "null"); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); + qmp_assert_error_class(resp, "GenericError"); =20 /* No "execute" key */ resp =3D qtest_qmp(qts, "{}"); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); + qmp_assert_error_class(resp, "GenericError"); =20 /* "execute" isn't a string */ resp =3D qtest_qmp(qts, "{ 'execute': true }"); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); + qmp_assert_error_class(resp, "GenericError"); =20 /* "arguments" isn't a dictionary */ resp =3D qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'arguments': [] }= "); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); + qmp_assert_error_class(resp, "GenericError"); =20 /* extra key */ resp =3D qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'extra': true }"); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); - qobject_unref(resp); + qmp_assert_error_class(resp, "GenericError"); } =20 static void test_qmp_protocol(void) @@ -148,8 +124,7 @@ static void test_qmp_protocol(void) =20 /* Test valid command before handshake */ resp =3D qtest_qmp(qts, "{ 'execute': 'query-version' }"); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "CommandNotFound"); - qobject_unref(resp); + qmp_assert_error_class(resp, "CommandNotFound"); =20 /* Test malformed commands before handshake */ test_malformed(qts); @@ -162,8 +137,7 @@ static void test_qmp_protocol(void) =20 /* Test repeated handshake */ resp =3D qtest_qmp(qts, "{ 'execute': 'qmp_capabilities' }"); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "CommandNotFound"); - qobject_unref(resp); + qmp_assert_error_class(resp, "CommandNotFound"); =20 /* Test valid command */ resp =3D qtest_qmp(qts, "{ 'execute': 'query-version' }"); @@ -182,9 +156,8 @@ static void test_qmp_protocol(void) =20 /* Test command failure with 'id' */ resp =3D qtest_qmp(qts, "{ 'execute': 'human-monitor-command', 'id': 2= }"); - g_assert_cmpstr(get_error_class(resp), =3D=3D, "GenericError"); g_assert_cmpint(qdict_get_int(resp, "id"), =3D=3D, 2); - qobject_unref(resp); + qmp_assert_error_class(resp, "GenericError"); =20 qtest_quit(qts); } diff --git a/tests/test-qga.c b/tests/test-qga.c index f69cdf6c03..3d6377436a 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -244,17 +244,12 @@ static void test_qga_invalid_id(gconstpointer fix) static void test_qga_invalid_oob(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret, *error; - const char *class; + QDict *ret; =20 ret =3D qmp_fd(fixture->fd, "{'exec-oob': 'guest-ping'}"); g_assert_nonnull(ret); =20 - error =3D qdict_get_qdict(ret, "error"); - class =3D qdict_get_try_str(error, "class"); - g_assert_cmpstr(class, =3D=3D, "GenericError"); - - qobject_unref(ret); + qmp_assert_error_class(ret, "GenericError"); } =20 static void test_qga_invalid_args(gconstpointer fix) --=20 2.19.0.rc0.48.gb9dfa238d5 From nobody Wed Nov 5 14:50:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535644957154424.4459433708224; Thu, 30 Aug 2018 09:02:37 -0700 (PDT) Received: from localhost ([::1]:49656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPP1-0003fb-U6 for importer@patchew.org; Thu, 30 Aug 2018 12:02:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPKv-0000w0-BQ for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvPKu-0002PR-Kr for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:21 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55090 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvPKu-0002PH-G7 for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2828A40216F9; Thu, 30 Aug 2018 15:58:20 +0000 (UTC) Received: from localhost (ovpn-112-18.ams2.redhat.com [10.36.112.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC4DD2166B41; Thu, 30 Aug 2018 15:58:19 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 17:58:08 +0200 Message-Id: <20180830155810.17629-3-marcandre.lureau@redhat.com> In-Reply-To: <20180830155810.17629-1-marcandre.lureau@redhat.com> References: <20180830155810.17629-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 30 Aug 2018 15:58:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 30 Aug 2018 15:58:20 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v5 2/4] tests: add qmp/object-add-without-props test 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: Laurent Vivier , Thomas Huth , Markus Armbruster , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" test_object_add_without_props() tests a bug in qmp_object_add() we fixed in commit e64c75a975. Sadly, we don't have systematic object-add tests. This lone test can go into qmp-cmd-test for want of a better home. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth --- tests/qmp-cmd-test.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/qmp-cmd-test.c b/tests/qmp-cmd-test.c index c5b70df974..d12cac539c 100644 --- a/tests/qmp-cmd-test.c +++ b/tests/qmp-cmd-test.c @@ -197,6 +197,19 @@ static void add_query_tests(QmpSchema *schema) } } =20 +static void test_object_add_without_props(void) +{ + QTestState *qts; + QDict *resp; + + qts =3D qtest_init(common_args); + resp =3D qtest_qmp(qts, "{'execute': 'object-add', 'arguments':" + " {'qom-type': 'memory-backend-ram', 'id': 'ram1' } }"= ); + g_assert_nonnull(resp); + qmp_assert_error_class(resp, "GenericError"); + qtest_quit(qts); +} + int main(int argc, char *argv[]) { QmpSchema schema; @@ -206,6 +219,11 @@ int main(int argc, char *argv[]) =20 qmp_schema_init(&schema); add_query_tests(&schema); + + qtest_add_func("qmp/object-add-without-props", + test_object_add_without_props); + /* TODO: add coverage of generic object-add failure modes */ + ret =3D g_test_run(); =20 qmp_schema_cleanup(&schema); --=20 2.19.0.rc0.48.gb9dfa238d5 From nobody Wed Nov 5 14:50:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535645280590277.643672268998; Thu, 30 Aug 2018 09:08:00 -0700 (PDT) Received: from localhost ([::1]:49733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPUF-0001H1-Bu for importer@patchew.org; Thu, 30 Aug 2018 12:07:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPKx-0000yL-Ig for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvPKw-0002QK-PV for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39276 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvPKw-0002Q9-Kd for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:22 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A9D440201BD; Thu, 30 Aug 2018 15:58:22 +0000 (UTC) Received: from localhost (ovpn-112-18.ams2.redhat.com [10.36.112.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEE6410CD781; Thu, 30 Aug 2018 15:58:21 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 17:58:09 +0200 Message-Id: <20180830155810.17629-4-marcandre.lureau@redhat.com> In-Reply-To: <20180830155810.17629-1-marcandre.lureau@redhat.com> References: <20180830155810.17629-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 30 Aug 2018 15:58:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 30 Aug 2018 15:58:22 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v5 3/4] tests: add qmp/qom-set-without-value test 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: Laurent Vivier , Thomas Huth , Markus Armbruster , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" test_qom_set_without_value() is about a bug in infrastructure used by the QMP core, fixed in commit c489780203. We covered the bug in infrastructure unit tests (commit bce3035a44). I wrote that test earlier, to cover QMP level as well, the test could go into qmp-test. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth --- tests/qmp-test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index b3472281ae..2b923f02db 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -321,6 +321,19 @@ static void test_qmp_preconfig(void) qtest_quit(qs); } =20 +static void test_qom_set_without_value(void) +{ + QTestState *qts; + QDict *resp; + + qts =3D qtest_init(common_args); + resp =3D qtest_qmp(qts, "{'execute': 'qom-set', 'arguments':" + " { 'path': '/machine', 'property': 'rtc-time' } }"); + g_assert_nonnull(resp); + qmp_assert_error_class(resp, "GenericError"); + qtest_quit(qts); +} + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); @@ -328,6 +341,7 @@ int main(int argc, char *argv[]) qtest_add_func("qmp/protocol", test_qmp_protocol); qtest_add_func("qmp/oob", test_qmp_oob); qtest_add_func("qmp/preconfig", test_qmp_preconfig); + qtest_add_func("qmp/qom-set-without-value", test_qom_set_without_value= ); =20 return g_test_run(); } --=20 2.19.0.rc0.48.gb9dfa238d5 From nobody Wed Nov 5 14:50:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535645430800476.6770138935402; Thu, 30 Aug 2018 09:10:30 -0700 (PDT) Received: from localhost ([::1]:49756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPWf-00038n-Gs for importer@patchew.org; Thu, 30 Aug 2018 12:10:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPL1-00012H-SB for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvPKy-0002Qv-MT for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:27 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39280 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvPKy-0002Qn-HD for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:58:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C84540201BD; Thu, 30 Aug 2018 15:58:24 +0000 (UTC) Received: from localhost (ovpn-112-18.ams2.redhat.com [10.36.112.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC4DA2166B41; Thu, 30 Aug 2018 15:58:23 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 17:58:10 +0200 Message-Id: <20180830155810.17629-5-marcandre.lureau@redhat.com> In-Reply-To: <20180830155810.17629-1-marcandre.lureau@redhat.com> References: <20180830155810.17629-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 30 Aug 2018 15:58:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 30 Aug 2018 15:58:24 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v5 4/4] tests: add a qmp success-response test 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: Laurent Vivier , Thomas Huth , Markus Armbruster , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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=C3=A9 Lureau Reviewed-by: Markus Armbruster --- tests/test-qmp-cmds.c | 17 +++++++++++++++++ tests/qapi-schema/qapi-schema-test.json | 2 ++ tests/qapi-schema/qapi-schema-test.out | 2 ++ 3 files changed, 21 insertions(+) diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index ab414fa0c9..4ab2b6e5ce 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -32,6 +32,10 @@ void qmp_test_flags_command(Error **errp) { } =20 +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); } =20 +static void test_dispatch_cmd_success_response(void) +{ + QDict *req =3D qdict_new(); + QDict *resp; + + qdict_put_str(req, "execute", "cmd-success-response"); + resp =3D 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); =20 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 11aa4c8f8d..fb03163430 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' } =20 +{ '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/qap= i-schema-test.out index 0da92455da..218ac7d556 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=3DTrue command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse +command cmd-success-response None -> None + gen=3DTrue success_response=3DFalse boxed=3DFalse oob=3DFalse preconfig= =3DFalse object q_obj_guest-get-time-arg member a: int optional=3DFalse member b: int optional=3DTrue --=20 2.19.0.rc0.48.gb9dfa238d5