From nobody Sun Oct 5 19:12:03 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504289637671197.2920849891874; Fri, 1 Sep 2017 11:13:57 -0700 (PDT) Received: from localhost ([::1]:53132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnqS4-00089n-DV for importer@patchew.org; Fri, 01 Sep 2017 14:13:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnqIS-00077P-Dl for qemu-devel@nongnu.org; Fri, 01 Sep 2017 14:04:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnqIN-0001Xm-6E for qemu-devel@nongnu.org; Fri, 01 Sep 2017 14:04:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnqIM-0001XW-TW for qemu-devel@nongnu.org; Fri, 01 Sep 2017 14:03:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0062781E05 for ; Fri, 1 Sep 2017 18:03:54 +0000 (UTC) Received: from red.redhat.com (ovpn-121-149.rdu2.redhat.com [10.10.121.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id A87F9627DE; Fri, 1 Sep 2017 18:03:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0062781E05 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eblake@redhat.com From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 1 Sep 2017 13:03:17 -0500 Message-Id: <20170901180340.30009-7-eblake@redhat.com> In-Reply-To: <20170901180340.30009-1-eblake@redhat.com> References: <20170901180340.30009-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 01 Sep 2017 18:03:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v6 06/29] tests: Clean up wait for event 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: pbonzini@redhat.com, armbru@redhat.com, Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster We still use hacks like qmp("") to wait for an event, even though we have qmp_eventwait() since commit 8fe941f, and qmp_eventwait_ref() since commit 7ffe312. Both commits neglected to convert all the existing hacks. Make up what they missed. Bonus: gets rid of empty format strings. A step towards compile-time format string checking without triggering -Wformat-zero-length. Signed-off-by: Markus Armbruster Message-Id: <1500645206-13559-8-git-send-email-armbru@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Eric Blake --- v4: hoist earlier in series --- tests/boot-order-test.c | 2 +- tests/libqos/pci-pc.c | 6 +----- tests/tco-test.c | 3 +-- tests/usb-hcd-uhci-test.c | 6 +----- tests/usb-hcd-xhci-test.c | 12 ++---------- tests/wdt_ib700-test.c | 35 ++++++++++------------------------- 6 files changed, 16 insertions(+), 48 deletions(-) diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index fc1e7941f7..9d516830dd 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -43,7 +43,7 @@ static void test_a_boot_order(const char *machine, * system_reset only requests reset. We get a RESET event after * the actual reset completes. Need to wait for that. */ - qmp_discard_response(""); /* HACK: wait for event */ + qmp_eventwait("RESET"); actual =3D read_boot_order(); g_assert_cmphex(actual, =3D=3D, expected_reboot); qtest_quit(global_qtest); diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c index ded1c54c06..02ce49927a 100644 --- a/tests/libqos/pci-pc.c +++ b/tests/libqos/pci-pc.c @@ -173,9 +173,5 @@ void qpci_unplug_acpi_device_test(const char *id, uint8= _t slot) outb(ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << slot); - response =3D qmp(""); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qmp_eventwait("DEVICE_DELETED"); } diff --git a/tests/tco-test.c b/tests/tco-test.c index c4c264eb3d..f2ed6ed91c 100644 --- a/tests/tco-test.c +++ b/tests/tco-test.c @@ -237,9 +237,8 @@ static void test_tco_max_timeout(void) static QDict *get_watchdog_action(void) { - QDict *ev =3D qmp(""); + QDict *ev =3D qmp_eventwait_ref("WATCHDOG"); QDict *data; - g_assert(!strcmp(qdict_get_str(ev, "event"), "WATCHDOG")); data =3D qdict_get_qdict(ev, "data"); QINCREF(data); diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index 5b500fedb0..0fb7f8d223 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -68,11 +68,7 @@ static void test_usb_storage_hotplug(void) g_assert(!qdict_haskey(response, "error")); QDECREF(response); - response =3D qmp(""); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qmp_eventwait("DEVICE_DELETED"); } int main(int argc, char **argv) diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c index 031764da6d..c05a339894 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -57,11 +57,7 @@ static void test_usb_uas_hotplug(void) g_assert(!qdict_haskey(response, "error")); QDECREF(response); - response =3D qmp(""); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); - + qmp_eventwait("DEVICE_DELETED"); response =3D qmp("{'execute': 'device_del'," " 'arguments': {" @@ -71,11 +67,7 @@ static void test_usb_uas_hotplug(void) g_assert(!qdict_haskey(response, "error")); QDECREF(response); - response =3D qmp(""); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qmp_eventwait("DEVICE_DELETED"); } int main(int argc, char **argv) diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c index 49f4f0c221..4fc8eeae86 100644 --- a/tests/wdt_ib700-test.c +++ b/tests/wdt_ib700-test.c @@ -18,26 +18,10 @@ static void qmp_check_no_event(void) QDECREF(resp); } -static QDict *qmp_get_event(const char *name) -{ - QDict *event =3D qmp(""); - QDict *data; - g_assert(qdict_haskey(event, "event")); - g_assert(!strcmp(qdict_get_str(event, "event"), name)); - - if (qdict_haskey(event, "data")) { - data =3D qdict_get_qdict(event, "data"); - QINCREF(data); - } else { - data =3D NULL; - } - - QDECREF(event); - return data; -} - static QDict *ib700_program_and_wait(QTestState *s) { + QDict *event, *data; + clock_step(NANOSECONDS_PER_SECOND * 40); qmp_check_no_event(); @@ -61,7 +45,11 @@ static QDict *ib700_program_and_wait(QTestState *s) clock_step(3 * NANOSECONDS_PER_SECOND); qmp_check_no_event(); clock_step(2 * NANOSECONDS_PER_SECOND); - return qmp_get_event("WATCHDOG"); + event =3D qmp_eventwait_ref("WATCHDOG"); + data =3D qdict_get_qdict(event, "data"); + QINCREF(data); + QDECREF(event); + return data; } @@ -73,8 +61,7 @@ static void ib700_pause(void) d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "pause")); QDECREF(d); - d =3D qmp_get_event("STOP"); - QDECREF(d); + qmp_eventwait("STOP"); qtest_end(); } @@ -86,8 +73,7 @@ static void ib700_reset(void) d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "reset")); QDECREF(d); - d =3D qmp_get_event("RESET"); - QDECREF(d); + qmp_eventwait("RESET"); qtest_end(); } @@ -99,8 +85,7 @@ static void ib700_shutdown(void) d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "reset")); QDECREF(d); - d =3D qmp_get_event("SHUTDOWN"); - QDECREF(d); + qmp_eventwait("SHUTDOWN"); qtest_end(); } --=20 2.13.5