From 354b86f85f516fecb60185f9c2b8e5933177b300 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 1 Feb 2018 21:21:28 +0100 Subject: tests: virtio-9p: add WRITE operation test Trivial test of a successful write. Signed-off-by: Greg Kurz (groug, handle potential overflow when computing request size, add missing g_free(buf), backend handles one written byte at a time to validate the server doesn't do short-reads) Reviewed-by: Stefan Hajnoczi --- hw/9pfs/9p-synth.c | 11 +++++++++++ hw/9pfs/9p-synth.h | 1 + 2 files changed, 12 insertions(+) (limited to 'hw/9pfs') diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index f17b74f..ade3460 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -515,6 +515,12 @@ static int synth_unlinkat(FsContext *ctx, V9fsPath *dir, return -1; } +static ssize_t v9fs_synth_qtest_write(void *buf, int len, off_t offset, + void *arg) +{ + return 1; +} + static int synth_init(FsContext *ctx, Error **errp) { QLIST_INIT(&synth_root.child); @@ -546,6 +552,11 @@ static int synth_init(FsContext *ctx, Error **errp) ret = qemu_v9fs_synth_add_file(NULL, 0, QTEST_V9FS_SYNTH_LOPEN_FILE, NULL, NULL, ctx); assert(!ret); + + /* File for WRITE test */ + ret = qemu_v9fs_synth_add_file(NULL, 0, QTEST_V9FS_SYNTH_WRITE_FILE, + NULL, v9fs_synth_qtest_write, ctx); + assert(!ret); } return 0; diff --git a/hw/9pfs/9p-synth.h b/hw/9pfs/9p-synth.h index 2a8d6fd..a74032d 100644 --- a/hw/9pfs/9p-synth.h +++ b/hw/9pfs/9p-synth.h @@ -53,5 +53,6 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode, #define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d" #define QTEST_V9FS_SYNTH_LOPEN_FILE "LOPEN" +#define QTEST_V9FS_SYNTH_WRITE_FILE "WRITE" #endif -- cgit v1.1