From patchwork Fri Jun 22 10:33:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Hrdina X-Patchwork-Id: 166570 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 233CEB6FA5 for ; Fri, 22 Jun 2012 20:42:47 +1000 (EST) Received: from localhost ([::1]:36805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Si1CX-000102-ST for incoming@patchwork.ozlabs.org; Fri, 22 Jun 2012 06:34:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Si1Bq-0007Xx-88 for qemu-devel@nongnu.org; Fri, 22 Jun 2012 06:34:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Si1Bj-00030O-RB for qemu-devel@nongnu.org; Fri, 22 Jun 2012 06:34:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Si1Bj-0002zs-J3 for qemu-devel@nongnu.org; Fri, 22 Jun 2012 06:34:03 -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 q5MAY27v003191 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 22 Jun 2012 06:34:02 -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 q5MAXvQu009017; Fri, 22 Jun 2012 06:34:01 -0400 From: Pavel Hrdina To: kwolf@redhat.com Date: Fri, 22 Jun 2012 12:33:53 +0200 Message-Id: <5a9aeb4a4dc10f844c593d341b13ca309d23ba7e.1340220873.git.phrdina@redhat.com> In-Reply-To: References: 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: Pavel Hrdina , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v6 2/6] fdc-test: introduced qtest read_without_media 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 If you try to read from a floppy drive without a media, you should get an abnormal termination error. Signed-off-by: Pavel Hrdina --- tests/fdc-test.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 66 insertions(+), 0 deletions(-) diff --git a/tests/fdc-test.c b/tests/fdc-test.c index 22d24ac..e730398 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -49,6 +49,7 @@ enum { enum { CMD_SENSE_INT = 0x08, CMD_SEEK = 0x0f, + CMD_READ = 0xe6, }; enum { @@ -99,6 +100,62 @@ static void ack_irq(void) g_assert(!get_irq(FLOPPY_IRQ)); } +static uint8_t send_read_command(void) +{ + uint8_t drive = 0; + uint8_t head = 0; + uint8_t cyl = 0; + uint8_t sect_addr = 1; + uint8_t sect_size = 2; + uint8_t eot = 1; + uint8_t gap = 0x1b; + uint8_t gpl = 0xff; + + uint8_t msr = 0; + uint8_t st0; + + uint8_t ret = 0; + + floppy_send(CMD_READ); + floppy_send(head << 2 | drive); + g_assert(!get_irq(FLOPPY_IRQ)); + floppy_send(cyl); + floppy_send(head); + floppy_send(sect_addr); + floppy_send(sect_size); + floppy_send(eot); + floppy_send(gap); + floppy_send(gpl); + + uint8_t i = 0; + uint8_t n = 2; + for (; i < n; i++) { + msr = inb(FLOPPY_BASE + reg_msr); + if (msr == 0xd0) { + break; + } + sleep(1); + } + + if (i >= n) { + return 1; + } + + st0 = floppy_recv(); + if (st0 != 0x40) { + ret = 1; + } + + floppy_recv(); + floppy_recv(); + floppy_recv(); + floppy_recv(); + floppy_recv(); + floppy_recv(); + + return ret; +} + static void send_step_pulse(void) { int drive = 0; @@ -146,6 +203,14 @@ static void test_no_media_on_start(void) assert_bit_set(dir, DSKCHG); } +static void test_read_without_media(void) +{ + uint8_t ret; + + ret = send_read_command(); + g_assert(ret == 0); +} + static void test_media_change(void) { uint8_t dir; @@ -214,6 +279,7 @@ int main(int argc, char **argv) qtest_irq_intercept_in(global_qtest, "ioapic"); qtest_add_func("/fdc/cmos", test_cmos); qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start); + qtest_add_func("/fdc/read_without_media", test_read_without_media); qtest_add_func("/fdc/media_change", test_media_change); ret = g_test_run();