From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqkN1-0001af-Ta for qemu-devel@nongnu.org; Mon, 16 Jul 2012 08:25:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SqkMy-0002s9-RZ for qemu-devel@nongnu.org; Mon, 16 Jul 2012 08:25:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqkMy-0002s5-JN for qemu-devel@nongnu.org; Mon, 16 Jul 2012 08:25:44 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6GCPiDJ015128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 Jul 2012 08:25:44 -0400 From: Pavel Hrdina Date: Mon, 16 Jul 2012 14:25:40 +0200 Message-Id: In-Reply-To: <9dc073c2eb42bb753565f23644bf449cb05ed4ed.1342440657.git.phrdina@redhat.com> References: <9dc073c2eb42bb753565f23644bf449cb05ed4ed.1342440657.git.phrdina@redhat.com> In-Reply-To: References: Subject: [Qemu-devel] [PATCH v2 2/2] fdc-test: introduce test_relative_seek List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Pavel Hrdina 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..4bc3515 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_OUT); + 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_IN); + 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 +371,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(); -- 1.7.10.4