From nobody Sat Oct 25 08:31:22 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 1518608142088878.8976664365464; Wed, 14 Feb 2018 03:35:42 -0800 (PST) Received: from localhost ([::1]:37664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elvLb-0002aC-P9 for importer@patchew.org; Wed, 14 Feb 2018 06:35:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elv7T-0006Rx-6D for qemu-devel@nongnu.org; Wed, 14 Feb 2018 06:21:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elv7Q-0007CH-Ts for qemu-devel@nongnu.org; Wed, 14 Feb 2018 06:20:59 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34528 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 1elv7Q-0007C5-OW for qemu-devel@nongnu.org; Wed, 14 Feb 2018 06:20:56 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 624CC4040852; Wed, 14 Feb 2018 11:20:56 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-136.ams2.redhat.com [10.36.116.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 977342024CA4; Wed, 14 Feb 2018 11:20:55 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 14 Feb 2018 12:20:27 +0100 Message-Id: <1518607234-17739-12-git-send-email-thuth@redhat.com> In-Reply-To: <1518607234-17739-1-git-send-email-thuth@redhat.com> References: <1518607234-17739-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 11:20:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 11:20:56 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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] [PULL 11/18] 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 d777f32..3b5bbcf 100644 --- a/tests/wdt_ib700-test.c +++ b/tests/wdt_ib700-test.c @@ -12,9 +12,9 @@ #include "qapi/qmp/qdict.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); } @@ -23,30 +23,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); @@ -57,48 +57,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