From patchwork Mon Jul 16 14:36:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 171214 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 8CFFA2C00E0 for ; Tue, 17 Jul 2012 00:36:43 +1000 (EST) Received: from localhost ([::1]:44531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqmPh-0002Wk-KL for incoming@patchwork.ozlabs.org; Mon, 16 Jul 2012 10:36:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqmPI-0001tR-Cy for qemu-devel@nongnu.org; Mon, 16 Jul 2012 10:36:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SqmP8-0006cP-O5 for qemu-devel@nongnu.org; Mon, 16 Jul 2012 10:36:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqmP8-0006cF-F6 for qemu-devel@nongnu.org; Mon, 16 Jul 2012 10:36:06 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6GEa5eT002592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 Jul 2012 10:36:05 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6GEa1dI004634; Mon, 16 Jul 2012 10:36:04 -0400 From: Kevin Wolf To: phrdina@redhat.com Date: Mon, 16 Jul 2012 16:36:00 +0200 Message-Id: <1342449360-15227-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1342449360-15227-1-git-send-email-kwolf@redhat.com> References: <1342449360-15227-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 2/2] fdc-test: Check RELATIVE SEEK beyond track 0/80 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 TODO This needs to be checked against a real drive Signed-off-by: Kevin Wolf --- tests/fdc-test.c | 48 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 37 insertions(+), 11 deletions(-) diff --git a/tests/fdc-test.c b/tests/fdc-test.c index fa74411..56e745a 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -94,13 +94,17 @@ static uint8_t floppy_recv(void) } /* pcn: Present Cylinder Number */ -static void ack_irq(uint8_t *pcn) +static void ack_irq(uint8_t *st0, uint8_t *pcn) { uint8_t ret; g_assert(get_irq(FLOPPY_IRQ)); floppy_send(CMD_SENSE_INT); - floppy_recv(); + + ret = floppy_recv(); + if (st0 != NULL) { + *st0 = ret; + } ret = floppy_recv(); if (pcn != NULL) { @@ -175,7 +179,7 @@ static void send_seek(int cyl) floppy_send(head << 2 | drive); g_assert(!get_irq(FLOPPY_IRQ)); floppy_send(cyl); - ack_irq(NULL); + ack_irq(NULL, NULL); } static uint8_t cmos_read(uint8_t reg) @@ -295,29 +299,51 @@ static void test_relative_seek(void) { uint8_t drive = 0; uint8_t head = 0; - uint8_t cyl = 1; uint8_t pcn; + uint8_t st0; /* Send seek to track 0 */ send_seek(0); - /* Send relative seek to increase track by 1 */ + /* Send relative seek to increase track by 3 */ floppy_send(CMD_RELATIVE_SEEK_IN); floppy_send(head << 2 | drive); g_assert(!get_irq(FLOPPY_IRQ)); - floppy_send(cyl); + floppy_send(3); - ack_irq(&pcn); - g_assert(pcn == 1); + ack_irq(&st0, &pcn); + g_assert_cmpint(pcn, ==, 3); + g_assert_cmpint(st0, ==, 0x20); /* 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); + floppy_send(1); + + ack_irq(&st0, &pcn); + g_assert_cmpint(pcn, ==, 2); + g_assert_cmpint(st0, ==, 0x20); + + /* Send relative seek to beyond track 0 */ + floppy_send(CMD_RELATIVE_SEEK_OUT); + floppy_send(head << 2 | drive); + g_assert(!get_irq(FLOPPY_IRQ)); + floppy_send(42); + + ack_irq(&st0, &pcn); + g_assert_cmpint(pcn, ==, 0); + g_assert_cmpint(st0, ==, 0x70); + + /* Send try relative seek to beyond track 80 */ + floppy_send(CMD_RELATIVE_SEEK_IN); + floppy_send(head << 2 | drive); + g_assert(!get_irq(FLOPPY_IRQ)); + floppy_send(200); - ack_irq(&pcn); - g_assert(pcn == 0); + ack_irq(&st0, &pcn); + g_assert_cmpint(pcn, ==, 79); + g_assert_cmpint(st0, ==, 0x50); } /* success if no crash or abort */