[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 2/4] fdc-test: introduced qtest read_without_medi
From: |
Pavel Hrdina |
Subject: |
[Qemu-devel] [PATCH v3 2/4] fdc-test: introduced qtest read_without_media |
Date: |
Tue, 12 Jun 2012 13:19:35 +0200 |
If you try to read from a floppy drive without a media, you should get
an abnormal termination error.
Signed-off-by: Pavel Hrdina <address@hidden>
---
tests/fdc-test.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index 22d24ac..670ab70 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,59 @@ static void ack_irq(void)
g_assert(!get_irq(FLOPPY_IRQ));
}
+static uint8_t send_read_command(void)
+{
+ static uint8_t drive = 0;
+ static uint8_t head = 0;
+ static uint8_t cyl = 0;
+ static uint8_t sect_addr = 1;
+ static uint8_t sect_size = 2;
+ static uint8_t eot = 1;
+ static uint8_t gap = 0x1b;
+ static 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 +200,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 +276,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