From nobody Tue Feb 10 21:40:56 2026 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 1518122528140316.9343256091271; Thu, 8 Feb 2018 12:42:08 -0800 (PST) Received: from localhost ([::1]:46657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejt1D-0006R1-8i for importer@patchew.org; Thu, 08 Feb 2018 15:42:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejsW9-0002Se-Gb for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejsW8-0002Ou-9W for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:01 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52622 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 1ejsW8-0002OV-3v for qemu-devel@nongnu.org; Thu, 08 Feb 2018 15:10:00 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C9A368182D1B for ; Thu, 8 Feb 2018 20:09:59 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-204-120.brq.redhat.com [10.40.204.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id F00C4B301A; Thu, 8 Feb 2018 20:09:58 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 21:09:39 +0100 Message-Id: <1518120582-26647-12-git-send-email-thuth@redhat.com> In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com> References: <1518120582-26647-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 20:09:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 20:09:59 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 11/14] wdt_ib700-test: Drop dependence on global_qtest 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: , 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: Eric Blake As a general rule, we prefer avoiding implicit global state because it makes code harder to safely copy and paste without thinking about the global state. Improve this test to be explicit about the state. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/wdt_ib700-test.c | 63 +++++++++++++++++++++++++++-------------------= ---- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c index 4fc8eea..4bb8374 100644 --- a/tests/wdt_ib700-test.c +++ b/tests/wdt_ib700-test.c @@ -11,9 +11,9 @@ #include "libqtest.h" #include "qemu/timer.h" =20 -static void qmp_check_no_event(void) +static void qmp_check_no_event(QTestState *s) { - QDict *resp =3D qmp("{'execute':'query-status'}"); + QDict *resp =3D qtest_qmp(s, "{'execute':'query-status'}"); g_assert(qdict_haskey(resp, "return")); QDECREF(resp); } @@ -22,30 +22,30 @@ static QDict *ib700_program_and_wait(QTestState *s) { QDict *event, *data; =20 - clock_step(NANOSECONDS_PER_SECOND * 40); - qmp_check_no_event(); + qtest_clock_step(s, NANOSECONDS_PER_SECOND * 40); + qmp_check_no_event(s); =20 /* 2 second limit */ - outb(0x443, 14); + qtest_outb(s, 0x443, 14); =20 /* Ping */ - clock_step(NANOSECONDS_PER_SECOND); - qmp_check_no_event(); - outb(0x443, 14); + qtest_clock_step(s, NANOSECONDS_PER_SECOND); + qmp_check_no_event(s); + qtest_outb(s, 0x443, 14); =20 /* Disable */ - clock_step(NANOSECONDS_PER_SECOND); - qmp_check_no_event(); - outb(0x441, 1); - clock_step(3 * NANOSECONDS_PER_SECOND); - qmp_check_no_event(); + qtest_clock_step(s, NANOSECONDS_PER_SECOND); + qmp_check_no_event(s); + qtest_outb(s, 0x441, 1); + qtest_clock_step(s, 3 * NANOSECONDS_PER_SECOND); + qmp_check_no_event(s); =20 /* Enable and let it fire */ - outb(0x443, 13); - clock_step(3 * NANOSECONDS_PER_SECOND); - qmp_check_no_event(); - clock_step(2 * NANOSECONDS_PER_SECOND); - event =3D qmp_eventwait_ref("WATCHDOG"); + qtest_outb(s, 0x443, 13); + qtest_clock_step(s, 3 * NANOSECONDS_PER_SECOND); + qmp_check_no_event(s); + qtest_clock_step(s, 2 * NANOSECONDS_PER_SECOND); + event =3D qtest_qmp_eventwait_ref(s, "WATCHDOG"); data =3D qdict_get_qdict(event, "data"); QINCREF(data); QDECREF(event); @@ -56,48 +56,53 @@ static QDict *ib700_program_and_wait(QTestState *s) static void ib700_pause(void) { QDict *d; - QTestState *s =3D qtest_start("-watchdog-action pause -device ib700"); + QTestState *s =3D qtest_init("-watchdog-action pause -device ib700"); + qtest_irq_intercept_in(s, "ioapic"); d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "pause")); QDECREF(d); - qmp_eventwait("STOP"); - qtest_end(); + qtest_qmp_eventwait(s, "STOP"); + qtest_quit(s); } =20 static void ib700_reset(void) { QDict *d; - QTestState *s =3D qtest_start("-watchdog-action reset -device ib700"); + QTestState *s =3D qtest_init("-watchdog-action reset -device ib700"); + qtest_irq_intercept_in(s, "ioapic"); d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "reset")); QDECREF(d); - qmp_eventwait("RESET"); - qtest_end(); + qtest_qmp_eventwait(s, "RESET"); + qtest_quit(s); } =20 static void ib700_shutdown(void) { QDict *d; - QTestState *s =3D qtest_start("-watchdog-action reset -no-reboot -devi= ce ib700"); + QTestState *s; + + s =3D qtest_init("-watchdog-action reset -no-reboot -device ib700"); qtest_irq_intercept_in(s, "ioapic"); d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "reset")); QDECREF(d); - qmp_eventwait("SHUTDOWN"); - qtest_end(); + qtest_qmp_eventwait(s, "SHUTDOWN"); + qtest_quit(s); } =20 static void ib700_none(void) { QDict *d; - QTestState *s =3D qtest_start("-watchdog-action none -device ib700"); + QTestState *s =3D qtest_init("-watchdog-action none -device ib700"); + qtest_irq_intercept_in(s, "ioapic"); d =3D ib700_program_and_wait(s); g_assert(!strcmp(qdict_get_str(d, "action"), "none")); QDECREF(d); - qtest_end(); + qtest_quit(s); } =20 int main(int argc, char **argv) --=20 1.8.3.1