2014-02-21 20:15:21 +04:00
|
|
|
/*
|
|
|
|
* QTest testcase for VirtIO 9P
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014 SUSE LINUX Products GmbH
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
2021-05-06 16:12:23 +03:00
|
|
|
/*
|
|
|
|
* Not so fast! You might want to read the 9p developer docs first:
|
|
|
|
* https://wiki.qemu.org/Documentation/9p
|
|
|
|
*/
|
|
|
|
|
2016-01-26 21:17:10 +03:00
|
|
|
#include "qemu/osdep.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2022-09-29 14:41:06 +03:00
|
|
|
#include "libqos/virtio-9p-client.h"
|
2018-01-08 13:18:23 +03:00
|
|
|
|
2022-10-04 23:53:23 +03:00
|
|
|
#define twalk(...) v9fs_twalk((TWalkOpt) __VA_ARGS__)
|
2022-10-04 23:53:33 +03:00
|
|
|
#define tversion(...) v9fs_tversion((TVersionOpt) __VA_ARGS__)
|
2022-10-04 23:53:36 +03:00
|
|
|
#define tattach(...) v9fs_tattach((TAttachOpt) __VA_ARGS__)
|
2022-10-04 23:53:41 +03:00
|
|
|
#define tgetattr(...) v9fs_tgetattr((TGetAttrOpt) __VA_ARGS__)
|
2022-10-04 23:53:47 +03:00
|
|
|
#define treaddir(...) v9fs_treaddir((TReadDirOpt) __VA_ARGS__)
|
2022-10-04 23:53:52 +03:00
|
|
|
#define tlopen(...) v9fs_tlopen((TLOpenOpt) __VA_ARGS__)
|
2022-10-04 23:53:58 +03:00
|
|
|
#define twrite(...) v9fs_twrite((TWriteOpt) __VA_ARGS__)
|
2022-10-04 23:54:03 +03:00
|
|
|
#define tflush(...) v9fs_tflush((TFlushOpt) __VA_ARGS__)
|
2022-10-04 23:54:06 +03:00
|
|
|
#define tmkdir(...) v9fs_tmkdir((TMkdirOpt) __VA_ARGS__)
|
2022-10-04 23:54:09 +03:00
|
|
|
#define tlcreate(...) v9fs_tlcreate((TlcreateOpt) __VA_ARGS__)
|
2022-10-04 23:54:11 +03:00
|
|
|
#define tsymlink(...) v9fs_tsymlink((TsymlinkOpt) __VA_ARGS__)
|
2022-10-04 23:54:14 +03:00
|
|
|
#define tlink(...) v9fs_tlink((TlinkOpt) __VA_ARGS__)
|
2022-10-04 23:54:16 +03:00
|
|
|
#define tunlinkat(...) v9fs_tunlinkat((TunlinkatOpt) __VA_ARGS__)
|
2020-10-08 21:34:56 +03:00
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc)
|
2016-09-16 09:58:35 +03:00
|
|
|
{
|
2018-07-20 16:42:11 +03:00
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2018-07-20 16:42:11 +03:00
|
|
|
size_t tag_len = qvirtio_config_readw(v9p->vdev, 0);
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *tag = NULL;
|
2016-09-16 09:58:35 +03:00
|
|
|
int i;
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
g_assert_cmpint(tag_len, ==, strlen(MOUNT_TAG));
|
2016-09-16 09:58:35 +03:00
|
|
|
|
|
|
|
tag = g_malloc(tag_len);
|
|
|
|
for (i = 0; i < tag_len; i++) {
|
2018-07-20 16:42:11 +03:00
|
|
|
tag[i] = qvirtio_config_readb(v9p->vdev, i + 2);
|
2016-09-16 09:58:35 +03:00
|
|
|
}
|
2018-07-20 16:42:11 +03:00
|
|
|
g_assert_cmpmem(tag, tag_len, MOUNT_TAG, tag_len);
|
2017-01-03 19:28:44 +03:00
|
|
|
}
|
|
|
|
|
2022-03-15 13:08:35 +03:00
|
|
|
static inline bool is_same_qid(v9fs_qid a, v9fs_qid b)
|
|
|
|
{
|
|
|
|
/* don't compare QID version for checking for file ID equalness */
|
|
|
|
return a[0] == b[0] && memcmp(&a[5], &b[5], 8) == 0;
|
|
|
|
}
|
|
|
|
|
2020-10-20 19:09:14 +03:00
|
|
|
static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-10-04 23:53:33 +03:00
|
|
|
tversion({ .client = obj });
|
2020-10-20 19:09:14 +03:00
|
|
|
}
|
|
|
|
|
2020-10-20 19:09:34 +03:00
|
|
|
static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = obj });
|
2020-10-20 19:09:34 +03:00
|
|
|
}
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
static void fs_walk(void *obj, void *data, QGuestAllocator *t_alloc)
|
2017-01-03 19:28:44 +03:00
|
|
|
{
|
2018-07-20 16:42:11 +03:00
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2018-02-01 23:21:27 +03:00
|
|
|
char *wnames[P9_MAXWELEM];
|
2017-01-03 19:28:44 +03:00
|
|
|
uint16_t nwqid;
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree v9fs_qid *wqid = NULL;
|
2017-01-03 19:28:44 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < P9_MAXWELEM; i++) {
|
2018-02-01 23:21:27 +03:00
|
|
|
wnames[i] = g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i);
|
2017-01-03 19:28:44 +03:00
|
|
|
}
|
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
2022-10-04 23:53:23 +03:00
|
|
|
.client = v9p, .fid = 0, .newfid = 1,
|
2022-10-04 23:53:29 +03:00
|
|
|
.nwname = P9_MAXWELEM, .wnames = wnames,
|
|
|
|
.rwalk = { .nwqid = &nwqid, .wqid = &wqid }
|
|
|
|
});
|
2017-01-03 19:28:44 +03:00
|
|
|
|
|
|
|
g_assert_cmpint(nwqid, ==, P9_MAXWELEM);
|
|
|
|
|
|
|
|
for (i = 0; i < P9_MAXWELEM; i++) {
|
|
|
|
g_free(wnames[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-08 11:24:19 +03:00
|
|
|
static bool fs_dirents_contain_name(struct V9fsDirent *e, const char* name)
|
|
|
|
{
|
|
|
|
for (; e; e = e->next) {
|
|
|
|
if (!strcmp(e->name, name)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-29 11:10:23 +03:00
|
|
|
/* basic readdir test where reply fits into a single response message */
|
2020-02-08 11:24:19 +03:00
|
|
|
static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-10-04 23:53:23 +03:00
|
|
|
char *wnames[] = { g_strdup(QTEST_V9FS_SYNTH_READDIR_DIR) };
|
2020-02-08 11:24:19 +03:00
|
|
|
uint16_t nqid;
|
|
|
|
v9fs_qid qid;
|
|
|
|
uint32_t count, nentries;
|
|
|
|
struct V9fsDirent *entries = NULL;
|
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
2022-10-04 23:53:23 +03:00
|
|
|
.client = v9p, .fid = 0, .newfid = 1,
|
2022-10-04 23:53:29 +03:00
|
|
|
.nwname = 1, .wnames = wnames, .rwalk.nwqid = &nqid
|
|
|
|
});
|
2020-02-08 11:24:19 +03:00
|
|
|
g_assert_cmpint(nqid, ==, 1);
|
|
|
|
|
2022-10-04 23:53:55 +03:00
|
|
|
tlopen({
|
|
|
|
.client = v9p, .fid = 1, .flags = O_DIRECTORY, .rlopen.qid = &qid
|
|
|
|
});
|
2020-02-08 11:24:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* submit count = msize - 11, because 11 is the header size of Rreaddir
|
|
|
|
*/
|
2022-10-04 23:53:49 +03:00
|
|
|
treaddir({
|
2022-10-04 23:53:47 +03:00
|
|
|
.client = v9p, .fid = 1, .offset = 0, .count = P9_MAX_SIZE - 11,
|
2022-10-04 23:53:49 +03:00
|
|
|
.rreaddir = {
|
|
|
|
.count = &count, .nentries = &nentries, .entries = &entries
|
|
|
|
}
|
|
|
|
});
|
2020-02-08 11:24:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Assuming msize (P9_MAX_SIZE) is large enough so we can retrieve all
|
|
|
|
* dir entries with only one readdir request.
|
|
|
|
*/
|
|
|
|
g_assert_cmpint(
|
|
|
|
nentries, ==,
|
|
|
|
QTEST_V9FS_SYNTH_READDIR_NFILES + 2 /* "." and ".." */
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check all file names exist in returned entries, ignore their order
|
|
|
|
* though.
|
|
|
|
*/
|
|
|
|
g_assert_cmpint(fs_dirents_contain_name(entries, "."), ==, true);
|
|
|
|
g_assert_cmpint(fs_dirents_contain_name(entries, ".."), ==, true);
|
|
|
|
for (int i = 0; i < QTEST_V9FS_SYNTH_READDIR_NFILES; ++i) {
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *name =
|
|
|
|
g_strdup_printf(QTEST_V9FS_SYNTH_READDIR_FILE, i);
|
2020-02-08 11:24:19 +03:00
|
|
|
g_assert_cmpint(fs_dirents_contain_name(entries, name), ==, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
v9fs_free_dirents(entries);
|
|
|
|
g_free(wnames[0]);
|
|
|
|
}
|
|
|
|
|
2020-07-29 11:10:23 +03:00
|
|
|
/* readdir test where overall request is split over several messages */
|
2020-10-20 19:09:20 +03:00
|
|
|
static void do_readdir_split(QVirtio9P *v9p, uint32_t count)
|
2020-07-29 11:10:23 +03:00
|
|
|
{
|
2022-10-04 23:53:23 +03:00
|
|
|
char *wnames[] = { g_strdup(QTEST_V9FS_SYNTH_READDIR_DIR) };
|
2020-07-29 11:10:23 +03:00
|
|
|
uint16_t nqid;
|
|
|
|
v9fs_qid qid;
|
|
|
|
uint32_t nentries, npartialentries;
|
|
|
|
struct V9fsDirent *entries, *tail, *partialentries;
|
|
|
|
int fid;
|
|
|
|
uint64_t offset;
|
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2020-07-29 11:10:23 +03:00
|
|
|
|
|
|
|
fid = 1;
|
|
|
|
offset = 0;
|
|
|
|
entries = NULL;
|
|
|
|
nentries = 0;
|
|
|
|
tail = NULL;
|
|
|
|
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
2022-10-04 23:53:23 +03:00
|
|
|
.client = v9p, .fid = 0, .newfid = fid,
|
2022-10-04 23:53:29 +03:00
|
|
|
.nwname = 1, .wnames = wnames, .rwalk.nwqid = &nqid
|
|
|
|
});
|
2020-07-29 11:10:23 +03:00
|
|
|
g_assert_cmpint(nqid, ==, 1);
|
|
|
|
|
2022-10-04 23:53:55 +03:00
|
|
|
tlopen({
|
|
|
|
.client = v9p, .fid = fid, .flags = O_DIRECTORY, .rlopen.qid = &qid
|
|
|
|
});
|
2020-07-29 11:10:23 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* send as many Treaddir requests as required to get all directory
|
|
|
|
* entries
|
|
|
|
*/
|
|
|
|
while (true) {
|
|
|
|
npartialentries = 0;
|
|
|
|
partialentries = NULL;
|
|
|
|
|
2022-10-04 23:53:49 +03:00
|
|
|
treaddir({
|
2022-10-04 23:53:47 +03:00
|
|
|
.client = v9p, .fid = fid, .offset = offset, .count = count,
|
2022-10-04 23:53:49 +03:00
|
|
|
.rreaddir = {
|
|
|
|
.count = &count, .nentries = &npartialentries,
|
|
|
|
.entries = &partialentries
|
|
|
|
}
|
|
|
|
});
|
2020-07-29 11:10:23 +03:00
|
|
|
if (npartialentries > 0 && partialentries) {
|
|
|
|
if (!entries) {
|
|
|
|
entries = partialentries;
|
|
|
|
nentries = npartialentries;
|
|
|
|
tail = partialentries;
|
|
|
|
} else {
|
|
|
|
tail->next = partialentries;
|
|
|
|
nentries += npartialentries;
|
|
|
|
}
|
|
|
|
while (tail->next) {
|
|
|
|
tail = tail->next;
|
|
|
|
}
|
|
|
|
offset = tail->offset;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_cmpint(
|
|
|
|
nentries, ==,
|
|
|
|
QTEST_V9FS_SYNTH_READDIR_NFILES + 2 /* "." and ".." */
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check all file names exist in returned entries, ignore their order
|
|
|
|
* though.
|
|
|
|
*/
|
|
|
|
g_assert_cmpint(fs_dirents_contain_name(entries, "."), ==, true);
|
|
|
|
g_assert_cmpint(fs_dirents_contain_name(entries, ".."), ==, true);
|
|
|
|
for (int i = 0; i < QTEST_V9FS_SYNTH_READDIR_NFILES; ++i) {
|
|
|
|
char *name = g_strdup_printf(QTEST_V9FS_SYNTH_READDIR_FILE, i);
|
|
|
|
g_assert_cmpint(fs_dirents_contain_name(entries, name), ==, true);
|
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
v9fs_free_dirents(entries);
|
|
|
|
|
|
|
|
g_free(wnames[0]);
|
|
|
|
}
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
static void fs_walk_no_slash(void *obj, void *data, QGuestAllocator *t_alloc)
|
2017-01-03 19:28:44 +03:00
|
|
|
{
|
2018-07-20 16:42:11 +03:00
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-10-04 23:53:23 +03:00
|
|
|
char *wnames[] = { g_strdup(" /") };
|
2017-01-03 19:28:44 +03:00
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
2022-10-04 23:53:23 +03:00
|
|
|
.client = v9p, .fid = 0, .newfid = 1, .nwname = 1, .wnames = wnames,
|
2022-10-04 23:53:29 +03:00
|
|
|
.expectErr = ENOENT
|
|
|
|
});
|
2017-01-03 19:28:44 +03:00
|
|
|
|
|
|
|
g_free(wnames[0]);
|
|
|
|
}
|
|
|
|
|
2022-03-15 13:08:30 +03:00
|
|
|
static void fs_walk_nonexistent(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-03-15 13:08:30 +03:00
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-03-15 13:08:41 +03:00
|
|
|
/*
|
|
|
|
* The 9p2000 protocol spec says: "If the first element cannot be walked
|
|
|
|
* for any reason, Rerror is returned."
|
|
|
|
*/
|
2022-10-04 23:53:23 +03:00
|
|
|
twalk({ .client = v9p, .path = "non-existent", .expectErr = ENOENT });
|
2022-03-15 13:08:30 +03:00
|
|
|
}
|
|
|
|
|
2022-03-15 13:08:41 +03:00
|
|
|
static void fs_walk_2nd_nonexistent(void *obj, void *data,
|
|
|
|
QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-03-15 13:08:47 +03:00
|
|
|
v9fs_qid root_qid;
|
2022-03-15 13:08:41 +03:00
|
|
|
uint16_t nwqid;
|
2022-10-04 23:53:44 +03:00
|
|
|
uint32_t fid;
|
2022-03-15 13:08:41 +03:00
|
|
|
g_autofree v9fs_qid *wqid = NULL;
|
|
|
|
g_autofree char *path = g_strdup_printf(
|
|
|
|
QTEST_V9FS_SYNTH_WALK_FILE "/non-existent", 0
|
|
|
|
);
|
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p, .rattach.qid = &root_qid });
|
2022-10-04 23:53:23 +03:00
|
|
|
fid = twalk({
|
|
|
|
.client = v9p, .path = path,
|
2022-10-04 23:53:29 +03:00
|
|
|
.rwalk = { .nwqid = &nwqid, .wqid = &wqid }
|
2022-10-04 23:53:23 +03:00
|
|
|
}).newfid;
|
2022-03-15 13:08:41 +03:00
|
|
|
/*
|
|
|
|
* The 9p2000 protocol spec says: "nwqid is therefore either nwname or the
|
|
|
|
* index of the first elementwise walk that failed."
|
|
|
|
*/
|
|
|
|
assert(nwqid == 1);
|
2022-03-15 13:08:47 +03:00
|
|
|
|
|
|
|
/* returned QID wqid[0] is file ID of 1st subdir */
|
|
|
|
g_assert(wqid && wqid[0] && !is_same_qid(root_qid, wqid[0]));
|
|
|
|
|
|
|
|
/* expect fid being unaffected by walk above */
|
2022-10-04 23:53:44 +03:00
|
|
|
tgetattr({
|
2022-10-04 23:53:41 +03:00
|
|
|
.client = v9p, .fid = fid, .request_mask = P9_GETATTR_BASIC,
|
2022-10-04 23:53:44 +03:00
|
|
|
.expectErr = ENOENT
|
|
|
|
});
|
2022-03-15 13:08:41 +03:00
|
|
|
}
|
|
|
|
|
2022-03-15 13:08:33 +03:00
|
|
|
static void fs_walk_none(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-03-15 13:08:33 +03:00
|
|
|
v9fs_qid root_qid;
|
|
|
|
g_autofree v9fs_qid *wqid = NULL;
|
2022-03-15 13:08:35 +03:00
|
|
|
struct v9fs_attr attr;
|
2022-03-15 13:08:33 +03:00
|
|
|
|
2022-10-04 23:53:33 +03:00
|
|
|
tversion({ .client = v9p });
|
2022-10-04 23:53:38 +03:00
|
|
|
tattach({
|
|
|
|
.client = v9p, .fid = 0, .n_uname = getuid(),
|
|
|
|
.rattach.qid = &root_qid
|
|
|
|
});
|
2022-03-15 13:08:33 +03:00
|
|
|
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
2022-10-04 23:53:23 +03:00
|
|
|
.client = v9p, .fid = 0, .newfid = 1, .nwname = 0, .wnames = NULL,
|
2022-10-04 23:53:29 +03:00
|
|
|
.rwalk.wqid = &wqid
|
|
|
|
});
|
2022-03-15 13:08:33 +03:00
|
|
|
|
|
|
|
/* special case: no QID is returned if nwname=0 was sent */
|
|
|
|
g_assert(wqid == NULL);
|
2022-03-15 13:08:35 +03:00
|
|
|
|
2022-10-04 23:53:44 +03:00
|
|
|
tgetattr({
|
2022-10-04 23:53:41 +03:00
|
|
|
.client = v9p, .fid = 1, .request_mask = P9_GETATTR_BASIC,
|
2022-10-04 23:53:44 +03:00
|
|
|
.rgetattr.attr = &attr
|
|
|
|
});
|
2022-03-15 13:08:35 +03:00
|
|
|
|
|
|
|
g_assert(is_same_qid(root_qid, attr.qid));
|
2022-03-15 13:08:33 +03:00
|
|
|
}
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
static void fs_walk_dotdot(void *obj, void *data, QGuestAllocator *t_alloc)
|
2017-01-03 19:28:44 +03:00
|
|
|
{
|
2018-07-20 16:42:11 +03:00
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-10-04 23:53:23 +03:00
|
|
|
char *wnames[] = { g_strdup("..") };
|
2021-11-16 19:40:08 +03:00
|
|
|
v9fs_qid root_qid;
|
|
|
|
g_autofree v9fs_qid *wqid = NULL;
|
2017-01-03 19:28:44 +03:00
|
|
|
|
2022-10-04 23:53:33 +03:00
|
|
|
tversion({ .client = v9p });
|
2022-10-04 23:53:38 +03:00
|
|
|
tattach({
|
|
|
|
.client = v9p, .fid = 0, .n_uname = getuid(),
|
|
|
|
.rattach.qid = &root_qid
|
|
|
|
});
|
2017-01-03 19:28:44 +03:00
|
|
|
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
2022-10-04 23:53:23 +03:00
|
|
|
.client = v9p, .fid = 0, .newfid = 1, .nwname = 1, .wnames = wnames,
|
2022-10-04 23:53:29 +03:00
|
|
|
.rwalk.wqid = &wqid /* We now we'll get one qid */
|
|
|
|
});
|
2017-01-03 19:28:44 +03:00
|
|
|
|
|
|
|
g_assert_cmpmem(&root_qid, 13, wqid[0], 13);
|
|
|
|
|
|
|
|
g_free(wnames[0]);
|
|
|
|
}
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
static void fs_lopen(void *obj, void *data, QGuestAllocator *t_alloc)
|
2018-02-01 23:21:28 +03:00
|
|
|
{
|
2018-07-20 16:42:11 +03:00
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-10-04 23:53:23 +03:00
|
|
|
char *wnames[] = { g_strdup(QTEST_V9FS_SYNTH_LOPEN_FILE) };
|
2018-02-01 23:21:28 +03:00
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
|
|
|
.client = v9p, .fid = 0, .newfid = 1, .nwname = 1, .wnames = wnames
|
|
|
|
});
|
2018-02-01 23:21:28 +03:00
|
|
|
|
2022-10-04 23:53:55 +03:00
|
|
|
tlopen({ .client = v9p, .fid = 1, .flags = O_WRONLY });
|
2018-02-01 23:21:28 +03:00
|
|
|
|
|
|
|
g_free(wnames[0]);
|
|
|
|
}
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
static void fs_write(void *obj, void *data, QGuestAllocator *t_alloc)
|
2018-02-01 23:21:28 +03:00
|
|
|
{
|
2018-07-20 16:42:11 +03:00
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2018-02-01 23:21:28 +03:00
|
|
|
static const uint32_t write_count = P9_MAX_SIZE / 2;
|
2022-10-04 23:53:23 +03:00
|
|
|
char *wnames[] = { g_strdup(QTEST_V9FS_SYNTH_WRITE_FILE) };
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *buf = g_malloc0(write_count);
|
2018-02-01 23:21:28 +03:00
|
|
|
uint32_t count;
|
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
|
|
|
.client = v9p, .fid = 0, .newfid = 1, .nwname = 1, .wnames = wnames
|
|
|
|
});
|
2018-02-01 23:21:28 +03:00
|
|
|
|
2022-10-04 23:53:55 +03:00
|
|
|
tlopen({ .client = v9p, .fid = 1, .flags = O_WRONLY });
|
2018-02-01 23:21:28 +03:00
|
|
|
|
2022-10-04 23:54:00 +03:00
|
|
|
count = twrite({
|
2022-10-04 23:53:58 +03:00
|
|
|
.client = v9p, .fid = 1, .offset = 0, .count = write_count,
|
2022-10-04 23:54:00 +03:00
|
|
|
.data = buf
|
|
|
|
}).count;
|
2018-02-01 23:21:28 +03:00
|
|
|
g_assert_cmpint(count, ==, write_count);
|
|
|
|
|
|
|
|
g_free(wnames[0]);
|
|
|
|
}
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
static void fs_flush_success(void *obj, void *data, QGuestAllocator *t_alloc)
|
2018-02-01 23:21:28 +03:00
|
|
|
{
|
2018-07-20 16:42:11 +03:00
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-10-04 23:53:23 +03:00
|
|
|
char *wnames[] = { g_strdup(QTEST_V9FS_SYNTH_FLUSH_FILE) };
|
2018-02-01 23:21:28 +03:00
|
|
|
P9Req *req, *flush_req;
|
|
|
|
uint32_t reply_len;
|
|
|
|
uint8_t should_block;
|
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
|
|
|
.client = v9p, .fid = 0, .newfid = 1, .nwname = 1, .wnames = wnames
|
|
|
|
});
|
2018-02-01 23:21:28 +03:00
|
|
|
|
2022-10-04 23:53:55 +03:00
|
|
|
tlopen({ .client = v9p, .fid = 1, .flags = O_WRONLY });
|
2018-02-01 23:21:28 +03:00
|
|
|
|
|
|
|
/* This will cause the 9p server to try to write data to the backend,
|
|
|
|
* until the write request gets cancelled.
|
|
|
|
*/
|
|
|
|
should_block = 1;
|
2022-10-04 23:53:58 +03:00
|
|
|
req = twrite({
|
|
|
|
.client = v9p, .fid = 1, .offset = 0,
|
|
|
|
.count = sizeof(should_block), .data = &should_block,
|
|
|
|
.requestOnly = true
|
|
|
|
}).req;
|
2018-02-01 23:21:28 +03:00
|
|
|
|
2022-10-04 23:54:03 +03:00
|
|
|
flush_req = tflush({
|
|
|
|
.client = v9p, .oldtag = req->tag, .tag = 1, .requestOnly = true
|
|
|
|
}).req;
|
2018-02-01 23:21:28 +03:00
|
|
|
|
|
|
|
/* The write request is supposed to be flushed: the server should just
|
|
|
|
* mark the write request as used and reply to the flush request.
|
|
|
|
*/
|
|
|
|
v9fs_req_wait_for_reply(req, &reply_len);
|
|
|
|
g_assert_cmpint(reply_len, ==, 0);
|
|
|
|
v9fs_req_free(req);
|
|
|
|
v9fs_rflush(flush_req);
|
|
|
|
|
|
|
|
g_free(wnames[0]);
|
|
|
|
}
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
static void fs_flush_ignored(void *obj, void *data, QGuestAllocator *t_alloc)
|
2018-02-01 23:21:28 +03:00
|
|
|
{
|
2018-07-20 16:42:11 +03:00
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2022-10-04 23:53:23 +03:00
|
|
|
char *wnames[] = { g_strdup(QTEST_V9FS_SYNTH_FLUSH_FILE) };
|
2018-02-01 23:21:28 +03:00
|
|
|
P9Req *req, *flush_req;
|
|
|
|
uint32_t count;
|
|
|
|
uint8_t should_block;
|
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:53:29 +03:00
|
|
|
twalk({
|
|
|
|
.client = v9p, .fid = 0, .newfid = 1, .nwname = 1, .wnames = wnames
|
|
|
|
});
|
2018-02-01 23:21:28 +03:00
|
|
|
|
2022-10-04 23:53:55 +03:00
|
|
|
tlopen({ .client = v9p, .fid = 1, .flags = O_WRONLY });
|
2018-02-01 23:21:28 +03:00
|
|
|
|
|
|
|
/* This will cause the write request to complete right away, before it
|
|
|
|
* could be actually cancelled.
|
|
|
|
*/
|
|
|
|
should_block = 0;
|
2022-10-04 23:53:58 +03:00
|
|
|
req = twrite({
|
|
|
|
.client = v9p, .fid = 1, .offset = 0,
|
|
|
|
.count = sizeof(should_block), .data = &should_block,
|
|
|
|
.requestOnly = true
|
|
|
|
}).req;
|
2018-02-01 23:21:28 +03:00
|
|
|
|
2022-10-04 23:54:03 +03:00
|
|
|
flush_req = tflush({
|
|
|
|
.client = v9p, .oldtag = req->tag, .tag = 1, .requestOnly = true
|
|
|
|
}).req;
|
2018-02-01 23:21:28 +03:00
|
|
|
|
|
|
|
/* The write request is supposed to complete. The server should
|
|
|
|
* reply to the write request and the flush request.
|
|
|
|
*/
|
|
|
|
v9fs_req_wait_for_reply(req, NULL);
|
|
|
|
v9fs_rwrite(req, &count);
|
|
|
|
g_assert_cmpint(count, ==, sizeof(should_block));
|
|
|
|
v9fs_rflush(flush_req);
|
|
|
|
|
|
|
|
g_free(wnames[0]);
|
|
|
|
}
|
|
|
|
|
2020-07-29 11:10:23 +03:00
|
|
|
static void fs_readdir_split_128(void *obj, void *data,
|
|
|
|
QGuestAllocator *t_alloc)
|
|
|
|
{
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-20 19:09:20 +03:00
|
|
|
do_readdir_split(obj, 128);
|
2020-07-29 11:10:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void fs_readdir_split_256(void *obj, void *data,
|
|
|
|
QGuestAllocator *t_alloc)
|
|
|
|
{
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-20 19:09:20 +03:00
|
|
|
do_readdir_split(obj, 256);
|
2020-07-29 11:10:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void fs_readdir_split_512(void *obj, void *data,
|
|
|
|
QGuestAllocator *t_alloc)
|
|
|
|
{
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-20 19:09:20 +03:00
|
|
|
do_readdir_split(obj, 512);
|
2020-07-29 11:10:23 +03:00
|
|
|
}
|
|
|
|
|
2020-10-08 21:34:56 +03:00
|
|
|
|
|
|
|
/* tests using the 9pfs 'local' fs driver */
|
|
|
|
|
|
|
|
static void fs_create_dir(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-08 21:34:56 +03:00
|
|
|
struct stat st;
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *root_path = virtio_9p_test_path("");
|
|
|
|
g_autofree char *new_dir = virtio_9p_test_path("01");
|
2020-10-08 21:34:56 +03:00
|
|
|
|
|
|
|
g_assert(root_path != NULL);
|
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:54:06 +03:00
|
|
|
tmkdir({ .client = v9p, .atPath = "/", .name = "01" });
|
2020-10-08 21:34:56 +03:00
|
|
|
|
|
|
|
/* check if created directory really exists now ... */
|
|
|
|
g_assert(stat(new_dir, &st) == 0);
|
|
|
|
/* ... and is actually a directory */
|
|
|
|
g_assert((st.st_mode & S_IFMT) == S_IFDIR);
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:17:01 +03:00
|
|
|
static void fs_unlinkat_dir(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-21 15:17:01 +03:00
|
|
|
struct stat st;
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *root_path = virtio_9p_test_path("");
|
|
|
|
g_autofree char *new_dir = virtio_9p_test_path("02");
|
2020-10-21 15:17:01 +03:00
|
|
|
|
|
|
|
g_assert(root_path != NULL);
|
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:54:06 +03:00
|
|
|
tmkdir({ .client = v9p, .atPath = "/", .name = "02" });
|
2020-10-21 15:17:01 +03:00
|
|
|
|
|
|
|
/* check if created directory really exists now ... */
|
|
|
|
g_assert(stat(new_dir, &st) == 0);
|
|
|
|
/* ... and is actually a directory */
|
|
|
|
g_assert((st.st_mode & S_IFMT) == S_IFDIR);
|
|
|
|
|
2022-10-04 23:54:16 +03:00
|
|
|
tunlinkat({
|
|
|
|
.client = v9p, .atPath = "/", .name = "02",
|
|
|
|
.flags = P9_DOTL_AT_REMOVEDIR
|
|
|
|
});
|
2020-10-21 15:17:01 +03:00
|
|
|
/* directory should be gone now */
|
|
|
|
g_assert(stat(new_dir, &st) != 0);
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:25:33 +03:00
|
|
|
static void fs_create_file(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-21 15:25:33 +03:00
|
|
|
struct stat st;
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *new_file = virtio_9p_test_path("03/1st_file");
|
2020-10-21 15:25:33 +03:00
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:54:06 +03:00
|
|
|
tmkdir({ .client = v9p, .atPath = "/", .name = "03" });
|
2022-10-04 23:54:09 +03:00
|
|
|
tlcreate({ .client = v9p, .atPath = "03", .name = "1st_file" });
|
2020-10-21 15:25:33 +03:00
|
|
|
|
|
|
|
/* check if created file exists now ... */
|
|
|
|
g_assert(stat(new_file, &st) == 0);
|
|
|
|
/* ... and is a regular file */
|
|
|
|
g_assert((st.st_mode & S_IFMT) == S_IFREG);
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:28:37 +03:00
|
|
|
static void fs_unlinkat_file(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-21 15:28:37 +03:00
|
|
|
struct stat st;
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *new_file = virtio_9p_test_path("04/doa_file");
|
2020-10-21 15:28:37 +03:00
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:54:06 +03:00
|
|
|
tmkdir({ .client = v9p, .atPath = "/", .name = "04" });
|
2022-10-04 23:54:09 +03:00
|
|
|
tlcreate({ .client = v9p, .atPath = "04", .name = "doa_file" });
|
2020-10-21 15:28:37 +03:00
|
|
|
|
|
|
|
/* check if created file exists now ... */
|
|
|
|
g_assert(stat(new_file, &st) == 0);
|
|
|
|
/* ... and is a regular file */
|
|
|
|
g_assert((st.st_mode & S_IFMT) == S_IFREG);
|
|
|
|
|
2022-10-04 23:54:16 +03:00
|
|
|
tunlinkat({ .client = v9p, .atPath = "04", .name = "doa_file" });
|
2020-10-21 15:28:37 +03:00
|
|
|
/* file should be gone now */
|
|
|
|
g_assert(stat(new_file, &st) != 0);
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:33:34 +03:00
|
|
|
static void fs_symlink_file(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-21 15:33:34 +03:00
|
|
|
struct stat st;
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *real_file = virtio_9p_test_path("05/real_file");
|
|
|
|
g_autofree char *symlink_file = virtio_9p_test_path("05/symlink_file");
|
2020-10-21 15:33:34 +03:00
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:54:06 +03:00
|
|
|
tmkdir({ .client = v9p, .atPath = "/", .name = "05" });
|
2022-10-04 23:54:09 +03:00
|
|
|
tlcreate({ .client = v9p, .atPath = "05", .name = "real_file" });
|
2020-10-21 15:33:34 +03:00
|
|
|
g_assert(stat(real_file, &st) == 0);
|
|
|
|
g_assert((st.st_mode & S_IFMT) == S_IFREG);
|
|
|
|
|
2022-10-04 23:54:11 +03:00
|
|
|
tsymlink({
|
|
|
|
.client = v9p, .atPath = "05", .name = "symlink_file",
|
|
|
|
.symtgt = "real_file"
|
|
|
|
});
|
2020-10-21 15:33:34 +03:00
|
|
|
|
|
|
|
/* check if created link exists now */
|
|
|
|
g_assert(stat(symlink_file, &st) == 0);
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:36:23 +03:00
|
|
|
static void fs_unlinkat_symlink(void *obj, void *data,
|
|
|
|
QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-21 15:36:23 +03:00
|
|
|
struct stat st;
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *real_file = virtio_9p_test_path("06/real_file");
|
|
|
|
g_autofree char *symlink_file = virtio_9p_test_path("06/symlink_file");
|
2020-10-21 15:36:23 +03:00
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:54:06 +03:00
|
|
|
tmkdir({ .client = v9p, .atPath = "/", .name = "06" });
|
2022-10-04 23:54:09 +03:00
|
|
|
tlcreate({ .client = v9p, .atPath = "06", .name = "real_file" });
|
2020-10-21 15:36:23 +03:00
|
|
|
g_assert(stat(real_file, &st) == 0);
|
|
|
|
g_assert((st.st_mode & S_IFMT) == S_IFREG);
|
|
|
|
|
2022-10-04 23:54:11 +03:00
|
|
|
tsymlink({
|
|
|
|
.client = v9p, .atPath = "06", .name = "symlink_file",
|
|
|
|
.symtgt = "real_file"
|
|
|
|
});
|
2020-10-21 15:36:23 +03:00
|
|
|
g_assert(stat(symlink_file, &st) == 0);
|
|
|
|
|
2022-10-04 23:54:16 +03:00
|
|
|
tunlinkat({ .client = v9p, .atPath = "06", .name = "symlink_file" });
|
2020-10-21 15:36:23 +03:00
|
|
|
/* symlink should be gone now */
|
|
|
|
g_assert(stat(symlink_file, &st) != 0);
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:51:09 +03:00
|
|
|
static void fs_hardlink_file(void *obj, void *data, QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-21 15:51:09 +03:00
|
|
|
struct stat st_real, st_link;
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *real_file = virtio_9p_test_path("07/real_file");
|
|
|
|
g_autofree char *hardlink_file = virtio_9p_test_path("07/hardlink_file");
|
2020-10-21 15:51:09 +03:00
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:54:06 +03:00
|
|
|
tmkdir({ .client = v9p, .atPath = "/", .name = "07" });
|
2022-10-04 23:54:09 +03:00
|
|
|
tlcreate({ .client = v9p, .atPath = "07", .name = "real_file" });
|
2020-10-21 15:51:09 +03:00
|
|
|
g_assert(stat(real_file, &st_real) == 0);
|
|
|
|
g_assert((st_real.st_mode & S_IFMT) == S_IFREG);
|
|
|
|
|
2022-10-04 23:54:14 +03:00
|
|
|
tlink({
|
|
|
|
.client = v9p, .atPath = "07", .name = "hardlink_file",
|
|
|
|
.toPath = "07/real_file"
|
|
|
|
});
|
2020-10-21 15:51:09 +03:00
|
|
|
|
|
|
|
/* check if link exists now ... */
|
|
|
|
g_assert(stat(hardlink_file, &st_link) == 0);
|
|
|
|
/* ... and it's a hard link, right? */
|
|
|
|
g_assert((st_link.st_mode & S_IFMT) == S_IFREG);
|
|
|
|
g_assert(st_link.st_dev == st_real.st_dev);
|
|
|
|
g_assert(st_link.st_ino == st_real.st_ino);
|
|
|
|
}
|
|
|
|
|
2020-10-21 15:55:46 +03:00
|
|
|
static void fs_unlinkat_hardlink(void *obj, void *data,
|
|
|
|
QGuestAllocator *t_alloc)
|
|
|
|
{
|
|
|
|
QVirtio9P *v9p = obj;
|
2022-09-29 14:41:06 +03:00
|
|
|
v9fs_set_allocator(t_alloc);
|
2020-10-21 15:55:46 +03:00
|
|
|
struct stat st_real, st_link;
|
2021-11-16 19:40:08 +03:00
|
|
|
g_autofree char *real_file = virtio_9p_test_path("08/real_file");
|
|
|
|
g_autofree char *hardlink_file = virtio_9p_test_path("08/hardlink_file");
|
2020-10-21 15:55:46 +03:00
|
|
|
|
2022-10-04 23:53:36 +03:00
|
|
|
tattach({ .client = v9p });
|
2022-10-04 23:54:06 +03:00
|
|
|
tmkdir({ .client = v9p, .atPath = "/", .name = "08" });
|
2022-10-04 23:54:09 +03:00
|
|
|
tlcreate({ .client = v9p, .atPath = "08", .name = "real_file" });
|
2020-10-21 15:55:46 +03:00
|
|
|
g_assert(stat(real_file, &st_real) == 0);
|
|
|
|
g_assert((st_real.st_mode & S_IFMT) == S_IFREG);
|
|
|
|
|
2022-10-04 23:54:14 +03:00
|
|
|
tlink({
|
|
|
|
.client = v9p, .atPath = "08", .name = "hardlink_file",
|
|
|
|
.toPath = "08/real_file"
|
|
|
|
});
|
2020-10-21 15:55:46 +03:00
|
|
|
g_assert(stat(hardlink_file, &st_link) == 0);
|
|
|
|
|
2022-10-04 23:54:16 +03:00
|
|
|
tunlinkat({ .client = v9p, .atPath = "08", .name = "hardlink_file" });
|
2020-10-21 15:55:46 +03:00
|
|
|
/* symlink should be gone now */
|
|
|
|
g_assert(stat(hardlink_file, &st_link) != 0);
|
|
|
|
/* and old file should still exist */
|
|
|
|
g_assert(stat(real_file, &st_real) == 0);
|
|
|
|
}
|
|
|
|
|
2020-10-08 21:34:56 +03:00
|
|
|
static void *assign_9p_local_driver(GString *cmd_line, void *arg)
|
|
|
|
{
|
|
|
|
virtio_9p_assign_local_driver(cmd_line, "security_model=mapped-xattr");
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
static void register_virtio_9p_test(void)
|
2017-01-03 19:28:44 +03:00
|
|
|
{
|
2020-10-08 21:34:56 +03:00
|
|
|
|
|
|
|
QOSGraphTestOptions opts = {
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 9pfs test cases using the 'synth' filesystem driver */
|
|
|
|
qos_add_test("synth/config", "virtio-9p", pci_config, &opts);
|
|
|
|
qos_add_test("synth/version/basic", "virtio-9p", fs_version, &opts);
|
|
|
|
qos_add_test("synth/attach/basic", "virtio-9p", fs_attach, &opts);
|
|
|
|
qos_add_test("synth/walk/basic", "virtio-9p", fs_walk, &opts);
|
2020-10-08 21:34:56 +03:00
|
|
|
qos_add_test("synth/walk/no_slash", "virtio-9p", fs_walk_no_slash,
|
2020-10-08 21:34:56 +03:00
|
|
|
&opts);
|
2022-03-15 13:08:33 +03:00
|
|
|
qos_add_test("synth/walk/none", "virtio-9p", fs_walk_none, &opts);
|
2020-10-08 21:34:56 +03:00
|
|
|
qos_add_test("synth/walk/dotdot_from_root", "virtio-9p",
|
2020-10-08 21:34:56 +03:00
|
|
|
fs_walk_dotdot, &opts);
|
2022-03-15 13:08:30 +03:00
|
|
|
qos_add_test("synth/walk/non_existent", "virtio-9p", fs_walk_nonexistent,
|
|
|
|
&opts);
|
2022-03-15 13:08:41 +03:00
|
|
|
qos_add_test("synth/walk/2nd_non_existent", "virtio-9p",
|
|
|
|
fs_walk_2nd_nonexistent, &opts);
|
2020-10-08 21:34:56 +03:00
|
|
|
qos_add_test("synth/lopen/basic", "virtio-9p", fs_lopen, &opts);
|
|
|
|
qos_add_test("synth/write/basic", "virtio-9p", fs_write, &opts);
|
2020-10-08 21:34:56 +03:00
|
|
|
qos_add_test("synth/flush/success", "virtio-9p", fs_flush_success,
|
2020-10-08 21:34:56 +03:00
|
|
|
&opts);
|
2020-10-08 21:34:56 +03:00
|
|
|
qos_add_test("synth/flush/ignored", "virtio-9p", fs_flush_ignored,
|
2020-10-08 21:34:56 +03:00
|
|
|
&opts);
|
|
|
|
qos_add_test("synth/readdir/basic", "virtio-9p", fs_readdir, &opts);
|
2020-10-08 21:34:56 +03:00
|
|
|
qos_add_test("synth/readdir/split_512", "virtio-9p",
|
2020-10-08 21:34:56 +03:00
|
|
|
fs_readdir_split_512, &opts);
|
2020-10-08 21:34:56 +03:00
|
|
|
qos_add_test("synth/readdir/split_256", "virtio-9p",
|
2020-10-08 21:34:56 +03:00
|
|
|
fs_readdir_split_256, &opts);
|
2020-10-08 21:34:56 +03:00
|
|
|
qos_add_test("synth/readdir/split_128", "virtio-9p",
|
2020-10-08 21:34:56 +03:00
|
|
|
fs_readdir_split_128, &opts);
|
|
|
|
|
|
|
|
|
|
|
|
/* 9pfs test cases using the 'local' filesystem driver */
|
2020-11-24 10:43:43 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: Until we are sure that these tests can run everywhere,
|
|
|
|
* keep them as "slow" so that they aren't run with "make check".
|
|
|
|
*/
|
|
|
|
if (!g_test_slow()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-08 21:34:56 +03:00
|
|
|
opts.before = assign_9p_local_driver;
|
|
|
|
qos_add_test("local/config", "virtio-9p", pci_config, &opts);
|
2020-10-08 21:34:56 +03:00
|
|
|
qos_add_test("local/create_dir", "virtio-9p", fs_create_dir, &opts);
|
2020-10-21 15:17:01 +03:00
|
|
|
qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts);
|
2020-10-21 15:25:33 +03:00
|
|
|
qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts);
|
2020-10-21 15:28:37 +03:00
|
|
|
qos_add_test("local/unlinkat_file", "virtio-9p", fs_unlinkat_file, &opts);
|
2020-10-21 15:33:34 +03:00
|
|
|
qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts);
|
2020-10-21 15:36:23 +03:00
|
|
|
qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlink,
|
|
|
|
&opts);
|
2020-10-21 15:51:09 +03:00
|
|
|
qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &opts);
|
2020-10-21 15:55:46 +03:00
|
|
|
qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardlink,
|
|
|
|
&opts);
|
2016-09-16 09:58:35 +03:00
|
|
|
}
|
|
|
|
|
2018-07-20 16:42:11 +03:00
|
|
|
libqos_init(register_virtio_9p_test);
|
2020-11-01 17:37:12 +03:00
|
|
|
|
|
|
|
static void __attribute__((constructor)) construct_9p_test(void)
|
|
|
|
{
|
|
|
|
/* make sure test dir for the 'local' tests exists */
|
|
|
|
virtio_9p_create_local_test_dir();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __attribute__((destructor)) destruct_9p_test(void)
|
|
|
|
{
|
|
|
|
/* remove previously created test dir when test suite completed */
|
|
|
|
virtio_9p_remove_local_test_dir();
|
|
|
|
}
|