From patchwork Mon Feb 12 12:44:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10212535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C750560329 for ; Mon, 12 Feb 2018 12:46:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C146728B56 for ; Mon, 12 Feb 2018 12:46:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B608F28B8C; Mon, 12 Feb 2018 12:46:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53D7428B56 for ; Mon, 12 Feb 2018 12:46:53 +0000 (UTC) Received: from localhost ([::1]:54349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elDVU-0001c6-FJ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Feb 2018 07:46:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elDTd-00005E-Qv for qemu-devel@nongnu.org; Mon, 12 Feb 2018 07:44:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elDTc-0003QK-0w for qemu-devel@nongnu.org; Mon, 12 Feb 2018 07:44:57 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57168 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 1elDTb-0003Pt-SG; Mon, 12 Feb 2018 07:44:55 -0500 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 60CB1404084B; Mon, 12 Feb 2018 12:44:55 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-132.ams2.redhat.com [10.36.116.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4C302166BAE; Mon, 12 Feb 2018 12:44:53 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Mon, 12 Feb 2018 13:44:47 +0100 Message-Id: <1518439489-2724-3-git-send-email-thuth@redhat.com> In-Reply-To: <1518439489-2724-1-git-send-email-thuth@redhat.com> References: <1518439489-2724-1-git-send-email-thuth@redhat.com> 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]); Mon, 12 Feb 2018 12:44:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 12 Feb 2018 12:44:55 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 2/4] tests/m48t59: Make the test independent of 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: , Cc: qemu-ppc@nongnu.org, Mark Cave-Ayland Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Stop using the functions that require global_qtest here and pass around the QTestState instead (global_qtest should finally get removed since this causes problems with tests running in parallel). Signed-off-by: Thomas Huth Reviewed-by: Eric Blake --- tests/m48t59-test.c | 60 ++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/m48t59-test.c b/tests/m48t59-test.c index a85f84d..8c25467 100644 --- a/tests/m48t59-test.c +++ b/tests/m48t59-test.c @@ -30,45 +30,45 @@ static uint16_t reg_base = 0x1ff0; /* 0x7f0 for m48t02 */ static int base_year; static bool use_mmio; -static uint8_t cmos_read_mmio(uint8_t reg) +static uint8_t cmos_read_mmio(QTestState *s, uint8_t reg) { - return readb(base + (uint32_t)reg_base + (uint32_t)reg); + return qtest_readb(s, base + (uint32_t)reg_base + (uint32_t)reg); } -static void cmos_write_mmio(uint8_t reg, uint8_t val) +static void cmos_write_mmio(QTestState *s, uint8_t reg, uint8_t val) { uint8_t data = val; - writeb(base + (uint32_t)reg_base + (uint32_t)reg, data); + qtest_writeb(s, base + (uint32_t)reg_base + (uint32_t)reg, data); } -static uint8_t cmos_read_ioio(uint8_t reg) +static uint8_t cmos_read_ioio(QTestState *s, uint8_t reg) { - outw(base + 0, reg_base + (uint16_t)reg); - return inb(base + 3); + qtest_outw(s, base + 0, reg_base + (uint16_t)reg); + return qtest_inb(s, base + 3); } -static void cmos_write_ioio(uint8_t reg, uint8_t val) +static void cmos_write_ioio(QTestState *s, uint8_t reg, uint8_t val) { - outw(base + 0, reg_base + (uint16_t)reg); - outb(base + 3, val); + qtest_outw(s, base + 0, reg_base + (uint16_t)reg); + qtest_outb(s, base + 3, val); } -static uint8_t cmos_read(uint8_t reg) +static uint8_t cmos_read(QTestState *s, uint8_t reg) { if (use_mmio) { - return cmos_read_mmio(reg); + return cmos_read_mmio(s, reg); } else { - return cmos_read_ioio(reg); + return cmos_read_ioio(s, reg); } } -static void cmos_write(uint8_t reg, uint8_t val) +static void cmos_write(QTestState *s, uint8_t reg, uint8_t val) { if (use_mmio) { - cmos_write_mmio(reg, val); + cmos_write_mmio(s, reg, val); } else { - cmos_write_ioio(reg, val); + cmos_write_ioio(s, reg, val); } } @@ -106,18 +106,18 @@ static void print_tm(struct tm *tm) } #endif -static void cmos_get_date_time(struct tm *date) +static void cmos_get_date_time(QTestState *s, struct tm *date) { int sec, min, hour, mday, mon, year; time_t ts; struct tm dummy; - sec = cmos_read(RTC_SECONDS); - min = cmos_read(RTC_MINUTES); - hour = cmos_read(RTC_HOURS); - mday = cmos_read(RTC_DAY_OF_MONTH); - mon = cmos_read(RTC_MONTH); - year = cmos_read(RTC_YEAR); + sec = cmos_read(s, RTC_SECONDS); + min = cmos_read(s, RTC_MINUTES); + hour = cmos_read(s, RTC_HOURS); + mday = cmos_read(s, RTC_DAY_OF_MONTH); + mon = cmos_read(s, RTC_MONTH); + year = cmos_read(s, RTC_YEAR); sec = bcd2dec(sec); min = bcd2dec(min); @@ -145,7 +145,7 @@ static void cmos_get_date_time(struct tm *date) static QTestState *m48t59_qtest_start(void) { - return qtest_start("-rtc clock=vm"); + return qtest_init("-rtc clock=vm"); } static void bcd_check_time(void) @@ -172,10 +172,10 @@ static void bcd_check_time(void) ts = time(NULL); gmtime_r(&ts, &start); - cmos_get_date_time(&date[0]); - cmos_get_date_time(&date[1]); - cmos_get_date_time(&date[2]); - cmos_get_date_time(&date[3]); + cmos_get_date_time(s, &date[0]); + cmos_get_date_time(s, &date[1]); + cmos_get_date_time(s, &date[2]); + cmos_get_date_time(s, &date[3]); ts = time(NULL); gmtime_r(&ts, &end); @@ -226,8 +226,8 @@ static void fuzz_registers(void) continue; } - cmos_write(reg, val); - cmos_read(reg); + cmos_write(s, reg, val); + cmos_read(s, reg); } qtest_quit(s);