qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Hrdina <phrdina@redhat.com>
To: kwolf@redhat.com
Cc: Pavel Hrdina <phrdina@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v6 2/6] fdc-test: introduced qtest read_without_media
Date: Fri, 22 Jun 2012 12:33:53 +0200	[thread overview]
Message-ID: <5a9aeb4a4dc10f844c593d341b13ca309d23ba7e.1340220873.git.phrdina@redhat.com> (raw)
In-Reply-To: <cover.1340220873.git.phrdina@redhat.com>
In-Reply-To: <cover.1340220873.git.phrdina@redhat.com>

If you try to read from a floppy drive without a media, you should get
an abnormal termination error.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 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();
-- 
1.7.7.6

  parent reply	other threads:[~2012-06-22 10:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-22 10:33 [Qemu-devel] [PATCH v6 0/6] fdc: fix/rewrite seek, media_changed and interrupt handling Pavel Hrdina
2012-06-22 10:33 ` [Qemu-devel] [PATCH v6 1/6] fdc: fix implied seek while there is no media in drive Pavel Hrdina
2012-06-22 10:33 ` Pavel Hrdina [this message]
     [not found] ` <3359847e9dbdf4531ed17e86ef55be8b8676e329.1340360906.git.phrdina@redhat.com>
2012-06-22 10:33   ` [Qemu-devel] [PATCH v6 3/6] fdc: rewrite seek and DSKCHG bit handling Pavel Hrdina
2012-06-22 10:33   ` [Qemu-devel] [PATCH v6 4/6] fdc: fix interrupt handling Pavel Hrdina
2012-06-22 10:33   ` [Qemu-devel] [PATCH v6 5/6] fdc_test: update media_change test Pavel Hrdina
2012-06-24  6:16     ` Blue Swirl
     [not found]     ` <4FE83483.4010204@redhat.com>
2012-07-03 14:43       ` Pavel Hrdina
2012-06-22 10:33   ` [Qemu-devel] [PATCH v6 6/6] fdc_test: introduce test_sense_interrupt Pavel Hrdina
2012-07-04  9:07   ` [Qemu-devel] [PATCH v7 5/6] fdc_test: update media_change test Pavel Hrdina
2012-07-04 14:43     ` [Qemu-devel] [PATCH v8 " Kevin Wolf
2012-07-04  9:07   ` [Qemu-devel] [PATCH v7 6/6] fdc_test: introduce test_sense_interrupt Pavel Hrdina
2012-07-04  9:07 ` [Qemu-devel] [PATCH v7 0/6] fdc: fix/rewrite seek, media_changed and interrupt handling Pavel Hrdina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5a9aeb4a4dc10f844c593d341b13ca309d23ba7e.1340220873.git.phrdina@redhat.com \
    --to=phrdina@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).