From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcxn4-00024c-Tb for qemu-devel@nongnu.org; Fri, 18 Sep 2015 11:41:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcxn3-0000x4-IK for qemu-devel@nongnu.org; Fri, 18 Sep 2015 11:41:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxDQ-0001C4-J7 for qemu-devel@nongnu.org; Fri, 18 Sep 2015 11:04:44 -0400 From: John Snow Date: Fri, 18 Sep 2015 11:04:32 -0400 Message-Id: <1442588681-18564-3-git-send-email-jsnow@redhat.com> In-Reply-To: <1442588681-18564-1-git-send-email-jsnow@redhat.com> References: <1442588681-18564-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PULL 02/11] qtest/ahci: use generate_pattern everywhere List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, jsnow@redhat.com Fix the pattern generation to actually be interesting, and make sure all buffers in the ahci-test actually use it. Signed-off-by: John Snow Message-id: 1441926555-19471-2-git-send-email-jsnow@redhat.com --- tests/ahci-test.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index 87d7691..b1a785c 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -80,9 +80,9 @@ static void generate_pattern(void *buffer, size_t len, size_t cycle_len) /* Write an indicative pattern that varies and is unique per-cycle */ p = rand() % 256; - for (i = j = 0; i < len; i++, j++) { - tx[i] = p; - if (j % cycle_len == 0) { + for (i = 0; i < len; i++) { + tx[i] = p++ % 256; + if (i % cycle_len == 0) { p = rand() % 256; } } @@ -1155,7 +1155,6 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write) size_t bufsize = 4096; unsigned char *tx = g_malloc(bufsize); unsigned char *rx = g_malloc0(bufsize); - unsigned i; const char *uri = "tcp:127.0.0.1:1234"; src = ahci_boot_and_enable("-m 1024 -M q35 " @@ -1171,9 +1170,7 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write) ahci_port_clear(src, px); /* create pattern */ - for (i = 0; i < bufsize; i++) { - tx[i] = (bufsize - i); - } + generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE); /* Write, migrate, then read. */ ahci_io(src, px, cmd_write, tx, bufsize, 0); @@ -1213,7 +1210,6 @@ static void ahci_halted_io_test(uint8_t cmd_read, uint8_t cmd_write) size_t bufsize = 4096; unsigned char *tx = g_malloc(bufsize); unsigned char *rx = g_malloc0(bufsize); - unsigned i; uint64_t ptr; AHCICommand *cmd; @@ -1231,11 +1227,8 @@ static void ahci_halted_io_test(uint8_t cmd_read, uint8_t cmd_write) port = ahci_port_select(ahci); ahci_port_clear(ahci, port); - for (i = 0; i < bufsize; i++) { - tx[i] = (bufsize - i); - } - /* create DMA source buffer and write pattern */ + generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE); ptr = ahci_alloc(ahci, bufsize); g_assert(ptr); memwrite(ptr, tx, bufsize); @@ -1282,7 +1275,6 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write) size_t bufsize = 4096; unsigned char *tx = g_malloc(bufsize); unsigned char *rx = g_malloc0(bufsize); - unsigned i; uint64_t ptr; AHCICommand *cmd; const char *uri = "tcp:127.0.0.1:1234"; @@ -1310,10 +1302,7 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write) /* Initialize and prepare */ port = ahci_port_select(src); ahci_port_clear(src, port); - - for (i = 0; i < bufsize; i++) { - tx[i] = (bufsize - i); - } + generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE); /* create DMA source buffer and write pattern */ ptr = ahci_alloc(src, bufsize); -- 2.4.3