From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcbKB-0005yH-4W for qemu-devel@nongnu.org; Wed, 15 May 2013 09:00:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcbK9-0003Bx-Me for qemu-devel@nongnu.org; Wed, 15 May 2013 09:00:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcbK9-0003Bs-9n for qemu-devel@nongnu.org; Wed, 15 May 2013 09:00:53 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4FD0qqC000568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 15 May 2013 09:00:52 -0400 From: Kevin Wolf Date: Wed, 15 May 2013 15:00:39 +0200 Message-Id: <1368622839-7084-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] ide-test: Fix endianness problems List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com The test case passes on big endian hosts now (tested on ppc64) Signed-off-by: Kevin Wolf --- tests/ide-test.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/ide-test.c b/tests/ide-test.c index bdc1da7..365e995 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -252,7 +252,10 @@ static void test_bmdma_simple_rw(void) uintptr_t guest_buf = guest_alloc(guest_malloc, len); PrdtEntry prdt[] = { - { .addr = guest_buf, .size = len | PRDT_EOT }, + { + .addr = cpu_to_le32(guest_buf), + .size = cpu_to_le32(len | PRDT_EOT), + }, }; buf = g_malloc(len); @@ -304,7 +307,10 @@ static void test_bmdma_short_prdt(void) uint8_t status; PrdtEntry prdt[] = { - { .addr = 0, .size = 0x10 | PRDT_EOT }, + { + .addr = 0, + .size = cpu_to_le32(0x10 | PRDT_EOT), + }, }; /* Normal request */ @@ -325,7 +331,10 @@ static void test_bmdma_long_prdt(void) uint8_t status; PrdtEntry prdt[] = { - { .addr = 0, .size = 0x1000 | PRDT_EOT }, + { + .addr = 0, + .size = cpu_to_le32(0x1000 | PRDT_EOT), + }, }; /* Normal request */ @@ -355,6 +364,17 @@ static void test_bmdma_teardown(void) ide_test_quit(); } +static void string_cpu_to_be16(uint16_t *s, size_t bytes) +{ + g_assert((bytes & 1) == 0); + bytes /= 2; + + while (bytes--) { + *s = cpu_to_be16(*s); + s++; + } +} + static void test_identify(void) { uint8_t data; @@ -389,10 +409,12 @@ static void test_identify(void) assert_bit_clear(data, BSY | DF | ERR | DRQ); /* Check serial number/version in the buffer */ - ret = memcmp(&buf[10], "ettsidks ", 20); + string_cpu_to_be16(&buf[10], 20); + ret = memcmp(&buf[10], "testdisk ", 20); g_assert(ret == 0); - ret = memcmp(&buf[23], "evsroi n", 8); + string_cpu_to_be16(&buf[23], 8); + ret = memcmp(&buf[23], "version ", 8); g_assert(ret == 0); /* Write cache enabled bit */ -- 1.8.1.4