From patchwork Mon Jul 16 13:48:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Hrdina X-Patchwork-Id: 171200 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3086D2C008C for ; Mon, 16 Jul 2012 23:48:53 +1000 (EST) Received: from localhost ([::1]:36412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqlfP-0004ug-8s for incoming@patchwork.ozlabs.org; Mon, 16 Jul 2012 09:48:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqlfA-0004jv-3V for qemu-devel@nongnu.org; Mon, 16 Jul 2012 09:48:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sqlf5-0000GQ-GN for qemu-devel@nongnu.org; Mon, 16 Jul 2012 09:48:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sqlf5-0000GH-7g for qemu-devel@nongnu.org; Mon, 16 Jul 2012 09:48:31 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6GDmU3F009821 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 Jul 2012 09:48:30 -0400 Received: from antique-laptop.brq.redhat.com (dhcp-27-171.brq.redhat.com [10.34.27.171]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6GDmR5o014086; Mon, 16 Jul 2012 09:48:29 -0400 From: Pavel Hrdina To: qemu-devel@nongnu.org Date: Mon, 16 Jul 2012 15:48:27 +0200 Message-Id: <2b0de7663792c35a4d9ff1f80fec891ae86e6335.1342446287.git.phrdina@redhat.com> In-Reply-To: <3911cbfe9b9c2a9fd2e07bf7f2ff327a7b9a1a1c.1342446287.git.phrdina@redhat.com> References: <3911cbfe9b9c2a9fd2e07bf7f2ff327a7b9a1a1c.1342446287.git.phrdina@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, Pavel Hrdina Subject: [Qemu-devel] [PATCH v3 2/2] fdc-test: introduce test_relative_seek X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Pavel Hrdina --- tests/fdc-test.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/tests/fdc-test.c b/tests/fdc-test.c index 585fb0e..10d11a4 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -47,9 +47,11 @@ enum { }; enum { - CMD_SENSE_INT = 0x08, - CMD_SEEK = 0x0f, - CMD_READ = 0xe6, + CMD_SENSE_INT = 0x08, + CMD_SEEK = 0x0f, + CMD_READ = 0xe6, + CMD_RELATIVE_SEEK_OUT = 0x8f, + CMD_RELATIVE_SEEK_IN = 0xcf, }; enum { @@ -91,13 +93,17 @@ static uint8_t floppy_recv(void) return inb(FLOPPY_BASE + reg_fifo); } -static void ack_irq(void) +static uint8_t ack_irq(void) { + uint8_t ret; + g_assert(get_irq(FLOPPY_IRQ)); floppy_send(CMD_SENSE_INT); floppy_recv(); - floppy_recv(); + ret = floppy_recv(); g_assert(!get_irq(FLOPPY_IRQ)); + + return ret; } static uint8_t send_read_command(void) @@ -281,6 +287,35 @@ static void test_sense_interrupt(void) floppy_recv(); } +static void test_relative_seek(void) +{ + uint8_t drive = 0; + uint8_t head = 0; + uint8_t cyl = 1; + uint8_t ret; + + /* Send seek to track 0 */ + send_step_pulse(0); + + /* Send relative seek to increase track by 1 */ + floppy_send(CMD_RELATIVE_SEEK_IN); + floppy_send(head << 2 | drive); + g_assert(!get_irq(FLOPPY_IRQ)); + floppy_send(cyl); + + ret = ack_irq(); + g_assert(ret == 1); + + /* Send relative seek to decrease track by 1 */ + floppy_send(CMD_RELATIVE_SEEK_OUT); + floppy_send(head << 2 | drive); + g_assert(!get_irq(FLOPPY_IRQ)); + floppy_send(cyl); + + ret = ack_irq(); + g_assert(ret == 0); +} + /* success if no crash or abort */ static void fuzz_registers(void) { @@ -329,6 +364,7 @@ int main(int argc, char **argv) qtest_add_func("/fdc/read_without_media", test_read_without_media); qtest_add_func("/fdc/media_change", test_media_change); qtest_add_func("/fdc/sense_interrupt", test_sense_interrupt); + qtest_add_func("/fdc/relative_seek", test_relative_seek); qtest_add_func("/fdc/fuzz-registers", fuzz_registers); ret = g_test_run();