From: Greg Kurz <groug@kaod.org>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>, Greg Kurz <groug@kaod.org>
Subject: [Qemu-devel] [PULL 06/10] tests: virtio-9p: add LOPEN operation test
Date: Tue, 30 Jan 2018 18:39:31 +0100 [thread overview]
Message-ID: <20180130173935.5172-7-groug@kaod.org> (raw)
In-Reply-To: <20180130173935.5172-1-groug@kaod.org>
Trivial test of a successful open.
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/9pfs/9p-synth.c | 5 +++++
hw/9pfs/9p-synth.h | 1 +
tests/virtio-9p-test.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+)
diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index dcbd320da17a..f17b74f44461 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -541,6 +541,11 @@ static int synth_init(FsContext *ctx, Error **errp)
assert(!ret);
g_free(name);
}
+
+ /* File for LOPEN test */
+ ret = qemu_v9fs_synth_add_file(NULL, 0, QTEST_V9FS_SYNTH_LOPEN_FILE,
+ NULL, NULL, ctx);
+ assert(!ret);
}
return 0;
diff --git a/hw/9pfs/9p-synth.h b/hw/9pfs/9p-synth.h
index 876b4ef58288..2a8d6fd00d69 100644
--- a/hw/9pfs/9p-synth.h
+++ b/hw/9pfs/9p-synth.h
@@ -52,5 +52,6 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
/* qtest stuff */
#define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d"
+#define QTEST_V9FS_SYNTH_LOPEN_FILE "LOPEN"
#endif
diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index 652198156731..6ba782e24f3a 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -238,6 +238,7 @@ static const char *rmessage_name(uint8_t id)
id == P9_RVERSION ? "RVERSION" :
id == P9_RATTACH ? "RATTACH" :
id == P9_RWALK ? "RWALK" :
+ id == P9_RLOPEN ? "RLOPEN" :
"<unknown>";
}
@@ -389,6 +390,34 @@ static void v9fs_rwalk(P9Req *req, uint16_t *nwqid, v9fs_qid **wqid)
v9fs_req_free(req);
}
+/* size[4] Tlopen tag[2] fid[4] flags[4] */
+static P9Req *v9fs_tlopen(QVirtIO9P *v9p, uint32_t fid, uint32_t flags,
+ uint16_t tag)
+{
+ P9Req *req;
+
+ req = v9fs_req_init(v9p, 4 + 4, P9_TLOPEN, tag);
+ v9fs_uint32_write(req, fid);
+ v9fs_uint32_write(req, flags);
+ v9fs_req_send(req);
+ return req;
+}
+
+/* size[4] Rlopen tag[2] qid[13] iounit[4] */
+static void v9fs_rlopen(P9Req *req, v9fs_qid *qid, uint32_t *iounit)
+{
+ v9fs_req_recv(req, P9_RLOPEN);
+ if (qid) {
+ v9fs_memread(req, qid, 13);
+ } else {
+ v9fs_memskip(req, 13);
+ }
+ if (iounit) {
+ v9fs_uint32_read(req, iounit);
+ }
+ v9fs_req_free(req);
+}
+
static void fs_version(QVirtIO9P *v9p)
{
const char *version = "9P2000.L";
@@ -478,6 +507,23 @@ static void fs_walk_dotdot(QVirtIO9P *v9p)
g_free(wnames[0]);
}
+static void fs_lopen(QVirtIO9P *v9p)
+{
+ char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_LOPEN_FILE) };
+ P9Req *req;
+
+ fs_attach(v9p);
+ req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
+ v9fs_req_wait_for_reply(req);
+ v9fs_rwalk(req, NULL, NULL);
+
+ req = v9fs_tlopen(v9p, 1, O_WRONLY, 0);
+ v9fs_req_wait_for_reply(req);
+ v9fs_rlopen(req, NULL, NULL);
+
+ g_free(wnames[0]);
+}
+
typedef void (*v9fs_test_fn)(QVirtIO9P *v9p);
static void v9fs_run_pci_test(gconstpointer data)
@@ -507,6 +553,7 @@ int main(int argc, char **argv)
v9fs_qtest_pci_add("/virtio/9p/pci/fs/walk/no_slash", fs_walk_no_slash);
v9fs_qtest_pci_add("/virtio/9p/pci/fs/walk/dotdot_from_root",
fs_walk_dotdot);
+ v9fs_qtest_pci_add("/virtio/9p/pci/fs/lopen/basic", fs_lopen);
return g_test_run();
}
--
2.13.6
next prev parent reply other threads:[~2018-01-30 17:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-30 17:39 [Qemu-devel] [PULL 00/10] 9p patches for 2.12 20180130 Greg Kurz
2018-01-30 17:39 ` [Qemu-devel] [PULL 01/10] 9pfs: drop v9fs_register_transport() Greg Kurz
2018-01-30 17:39 ` [Qemu-devel] [PULL 02/10] 9pfs: Correctly handle cancelled requests Greg Kurz
2018-01-30 17:39 ` [Qemu-devel] [PULL 03/10] tests: virtio-9p: move request tag to the test functions Greg Kurz
2018-01-30 17:39 ` [Qemu-devel] [PULL 04/10] tests: virtio-9p: wait for completion in the test code Greg Kurz
2018-01-30 17:39 ` [Qemu-devel] [PULL 05/10] tests: virtio-9p: use the synth backend Greg Kurz
2018-01-30 17:39 ` Greg Kurz [this message]
2018-01-30 17:39 ` [Qemu-devel] [PULL 07/10] tests: virtio-9p: add WRITE operation test Greg Kurz
2018-01-30 17:39 ` [Qemu-devel] [PULL 08/10] libqos/virtio: return length written into used descriptor Greg Kurz
2018-01-30 17:39 ` [Qemu-devel] [PULL 09/10] tests: virtio-9p: add FLUSH operation test Greg Kurz
2018-01-30 17:39 ` [Qemu-devel] [PULL 10/10] tests/virtio-9p: explicitly handle potential integer overflows Greg Kurz
2018-01-31 10:14 ` [Qemu-devel] [PULL 00/10] 9p patches for 2.12 20180130 Peter Maydell
2018-01-31 16:30 ` Greg Kurz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180130173935.5172-7-groug@kaod.org \
--to=groug@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).