From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcyCT-0006gs-3K for qemu-devel@nongnu.org; Fri, 18 Sep 2015 12:07:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcyCO-0002Ue-0V for qemu-devel@nongnu.org; Fri, 18 Sep 2015 12:07:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35550) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxDR-0001CD-3V for qemu-devel@nongnu.org; Fri, 18 Sep 2015 11:04:45 -0400 From: John Snow Date: Fri, 18 Sep 2015 11:04:33 -0400 Message-Id: <1442588681-18564-4-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 03/11] qtest/ahci: export generate_pattern 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 Share the pattern function for ide and ahci test. Signed-off-by: John Snow Message-id: 1441926555-19471-3-git-send-email-jsnow@redhat.com --- tests/ahci-test.c | 26 -------------------------- tests/libqos/libqos.c | 26 ++++++++++++++++++++++++++ tests/libqos/libqos.h | 1 + 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index b1a785c..59d387c 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -71,32 +71,6 @@ static void string_bswap16(uint16_t *s, size_t bytes) } } -static void generate_pattern(void *buffer, size_t len, size_t cycle_len) -{ - int i, j; - unsigned char *tx = (unsigned char *)buffer; - unsigned char p; - size_t *sx; - - /* Write an indicative pattern that varies and is unique per-cycle */ - p = rand() % 256; - for (i = 0; i < len; i++) { - tx[i] = p++ % 256; - if (i % cycle_len == 0) { - p = rand() % 256; - } - } - - /* force uniqueness by writing an id per-cycle */ - for (i = 0; i < len / cycle_len; i++) { - j = i * cycle_len; - if (j + sizeof(*sx) <= len) { - sx = (size_t *)&tx[j]; - *sx = i; - } - } -} - /** * Verify that the transfer did not corrupt our state at all. */ diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index fce625b..8d7c5a9 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -212,3 +212,29 @@ void prepare_blkdebug_script(const char *debug_fn, const char *event) ret = fclose(debug_file); g_assert(ret == 0); } + +void generate_pattern(void *buffer, size_t len, size_t cycle_len) +{ + int i, j; + unsigned char *tx = (unsigned char *)buffer; + unsigned char p; + size_t *sx; + + /* Write an indicative pattern that varies and is unique per-cycle */ + p = rand() % 256; + for (i = 0; i < len; i++) { + tx[i] = p++ % 256; + if (i % cycle_len == 0) { + p = rand() % 256; + } + } + + /* force uniqueness by writing an id per-cycle */ + for (i = 0; i < len / cycle_len; i++) { + j = i * cycle_len; + if (j + sizeof(*sx) <= len) { + sx = (size_t *)&tx[j]; + *sx = i; + } + } +} diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h index e1f14ea..492a651 100644 --- a/tests/libqos/libqos.h +++ b/tests/libqos/libqos.h @@ -24,6 +24,7 @@ void mkqcow2(const char *file, unsigned size_mb); void set_context(QOSState *s); void migrate(QOSState *from, QOSState *to, const char *uri); void prepare_blkdebug_script(const char *debug_fn, const char *event); +void generate_pattern(void *buffer, size_t len, size_t cycle_len); static inline uint64_t qmalloc(QOSState *q, size_t bytes) { -- 2.4.3