From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ3d9-0003v0-6L for qemu-devel@nongnu.org; Mon, 23 Feb 2015 19:45:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQ3d5-00018C-By for qemu-devel@nongnu.org; Mon, 23 Feb 2015 19:45:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQ3d5-00017n-4m for qemu-devel@nongnu.org; Mon, 23 Feb 2015 19:45:39 -0500 From: John Snow Date: Mon, 23 Feb 2015 19:45:28 -0500 Message-Id: <1424738729-17082-6-git-send-email-jsnow@redhat.com> In-Reply-To: <1424738729-17082-1-git-send-email-jsnow@redhat.com> References: <1424738729-17082-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH 5/6] libqos: add blkdebug_prepare_script List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, marc.mari.barcelo@gmail.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow , afaerber@suse.de Pull this helper out of ide-test and into libqos, to be shared with ahci-test. Signed-off-by: John Snow --- tests/ide-test.c | 23 +---------------------- tests/libqos/libqos.c | 22 ++++++++++++++++++++++ tests/libqos/libqos.h | 1 + 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/tests/ide-test.c b/tests/ide-test.c index 1dae84f..78382e9 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -29,6 +29,7 @@ #include #include "libqtest.h" +#include "libqos/libqos.h" #include "libqos/pci-pc.h" #include "libqos/malloc-pc.h" @@ -494,28 +495,6 @@ static void test_flush(void) ide_test_quit(); } -static void prepare_blkdebug_script(const char *debug_fn, const char *event) -{ - FILE *debug_file = fopen(debug_fn, "w"); - int ret; - - fprintf(debug_file, "[inject-error]\n"); - fprintf(debug_file, "event = \"%s\"\n", event); - fprintf(debug_file, "errno = \"5\"\n"); - fprintf(debug_file, "state = \"1\"\n"); - fprintf(debug_file, "immediately = \"off\"\n"); - fprintf(debug_file, "once = \"on\"\n"); - - fprintf(debug_file, "[set-state]\n"); - fprintf(debug_file, "event = \"%s\"\n", event); - fprintf(debug_file, "new_state = \"2\"\n"); - fflush(debug_file); - g_assert(!ferror(debug_file)); - - ret = fclose(debug_file); - g_assert(ret == 0); -} - static void test_retry_flush(const char *machine) { uint8_t data; diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index 3577401..1a54a32 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -91,3 +91,25 @@ int mkqcow2(const char *file, unsigned size_mb) g_assert_not_reached(); } + +void prepare_blkdebug_script(const char *debug_fn, const char *event) +{ + FILE *debug_file = fopen(debug_fn, "w"); + int ret; + + fprintf(debug_file, "[inject-error]\n"); + fprintf(debug_file, "event = \"%s\"\n", event); + fprintf(debug_file, "errno = \"5\"\n"); + fprintf(debug_file, "state = \"1\"\n"); + fprintf(debug_file, "immediately = \"off\"\n"); + fprintf(debug_file, "once = \"on\"\n"); + + fprintf(debug_file, "[set-state]\n"); + fprintf(debug_file, "event = \"%s\"\n", event); + fprintf(debug_file, "new_state = \"2\"\n"); + fflush(debug_file); + g_assert(!ferror(debug_file)); + + ret = fclose(debug_file); + g_assert(ret == 0); +} diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h index 5abd2bd..f459783 100644 --- a/tests/libqos/libqos.h +++ b/tests/libqos/libqos.h @@ -20,6 +20,7 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap); QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...); void qtest_shutdown(QOSState *qs); int mkqcow2(const char *file, unsigned size_mb); +void prepare_blkdebug_script(const char *debug_fn, const char *event); static inline uint64_t qmalloc(QOSState *q, size_t bytes) { -- 1.9.3