mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
libqos: add blkdebug_prepare_script
Pull this helper out of ide-test and into libqos, to be shared with ahci-test. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1426018503-821-6-git-send-email-jsnow@redhat.com
This commit is contained in:
parent
ba4ed39346
commit
72c85e949f
3 changed files with 24 additions and 22 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <glib.h>
|
||||
|
||||
#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;
|
||||
|
|
|
@ -105,3 +105,25 @@ void mkqcow2(const char *file, unsigned size_mb)
|
|||
{
|
||||
return mkimg(file, "qcow2", size_mb);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);
|
|||
void qtest_shutdown(QOSState *qs);
|
||||
void mkimg(const char *file, const char *fmt, unsigned size_mb);
|
||||
void 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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue