From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Um6kh-0007hH-V7 for qemu-devel@nongnu.org; Mon, 10 Jun 2013 14:23:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Um6kg-0004n4-Mo for qemu-devel@nongnu.org; Mon, 10 Jun 2013 14:23:35 -0400 Received: from mail-oa0-x230.google.com ([2607:f8b0:4003:c02::230]:34531) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Um6kg-0004mw-Hi for qemu-devel@nongnu.org; Mon, 10 Jun 2013 14:23:34 -0400 Received: by mail-oa0-f48.google.com with SMTP id f4so2480336oah.7 for ; Mon, 10 Jun 2013 11:23:34 -0700 (PDT) Sender: fluxion From: Michael Roth Date: Mon, 10 Jun 2013 13:23:20 -0500 Message-Id: <1370888600-25388-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] ide-test: fix failure for test_flush List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, afaerber@suse.de, stefanha@redhat.com bd07684aacfb61668ae2c25b7dd00b64f3d7c7f3 added a test to ensure BSY flag is set when a flush request is in flight. It does this by setting a blkdebug breakpoint on flush_to_os before issuing a CMD_FLUSH_CACHE. It then resumes CMD_FLUSH_CACHE operation and checks that BSY is unset. The actual unsetting of BSY does not occur until ide_flush_cb gets called in a bh, however, so in some cases this check will race with the actual completion. Fix this by polling the ide status register until BSY flag gets unset before we do our final sanity checks. According to f68ec8379e88502b4841a110c070e9b118d3151c this is in line with how a guest would determine whether or not the device is still busy. Signed-off-by: Michael Roth --- tests/ide-test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/ide-test.c b/tests/ide-test.c index 828e71a..7e2eb94 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -455,7 +455,10 @@ static void test_flush(void) data = inb(IDE_BASE + reg_device); g_assert_cmpint(data & DEV, ==, 0); - data = inb(IDE_BASE + reg_status); + do { + data = inb(IDE_BASE + reg_status); + } while (data & BSY); + assert_bit_set(data, DRDY); assert_bit_clear(data, BSY | DF | ERR | DRQ); -- 1.7.9.5