fusefs: make the tests more cplusplusy
* Prefer std::unique_ptr to raw pointers * Prefer pass-by-reference to pass-by-pointer * Prefer static_cast to C-style cast, unless it's too much typing Reported by: ngie Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
cc04566c46
commit
29edc611c1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=348307
@ -108,9 +108,9 @@ TEST_F(AllowOther, creds)
|
|||||||
get_unprivileged_id(&uid, &gid);
|
get_unprivileged_id(&uid, &gid);
|
||||||
fork(true, &status, [=] {
|
fork(true, &status, [=] {
|
||||||
EXPECT_CALL(*m_mock, process( ResultOf([=](auto in) {
|
EXPECT_CALL(*m_mock, process( ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_LOOKUP &&
|
return (in.header.opcode == FUSE_LOOKUP &&
|
||||||
in->header.uid == uid &&
|
in.header.uid == uid &&
|
||||||
in->header.gid == gid);
|
in.header.gid == gid);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(1)
|
).Times(1)
|
||||||
@ -143,25 +143,25 @@ TEST_F(AllowOther, privilege_escalation)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | 0600, 0, 2);
|
expect_lookup(RELPATH, ino, S_IFREG | 0600, 0, 2);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.pid == (uint32_t)getpid() &&
|
in.header.pid == (uint32_t)getpid() &&
|
||||||
in->header.uid == (uint32_t)geteuid() &&
|
in.header.uid == (uint32_t)geteuid() &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(
|
).WillOnce(Invoke(
|
||||||
ReturnImmediate([](auto in __unused, auto out) {
|
ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
out->body.open.fh = fh;
|
out.body.open.fh = fh;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.pid != (uint32_t)getpid() &&
|
in.header.pid != (uint32_t)getpid() &&
|
||||||
in->header.uid != (uint32_t)geteuid() &&
|
in.header.uid != (uint32_t)geteuid() &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(AnyNumber())
|
).Times(AnyNumber())
|
||||||
@ -228,12 +228,12 @@ TEST_F(NoAllowOther, disallowed_beneath_root)
|
|||||||
|
|
||||||
expect_lookup(RELPATH, ino, S_IFDIR | 0755, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFDIR | 0755, 0, 1);
|
||||||
EXPECT_LOOKUP(ino, RELPATH2)
|
EXPECT_LOOKUP(ino, RELPATH2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino2;
|
out.body.entry.nodeid = ino2;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
expect_opendir(ino);
|
expect_opendir(ino);
|
||||||
dfd = open(FULLPATH, O_DIRECTORY);
|
dfd = open(FULLPATH, O_DIRECTORY);
|
||||||
@ -269,12 +269,12 @@ TEST_F(NoAllowOther, setextattr)
|
|||||||
fork(true, &status, [&] {
|
fork(true, &status, [&] {
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(
|
.WillOnce(Invoke(
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -44,10 +44,10 @@ void expect_create(const char *relpath, mode_t mode, ProcessMockerT r)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_open_in);
|
sizeof(fuse_open_in);
|
||||||
return (in->header.opcode == FUSE_CREATE &&
|
return (in.header.opcode == FUSE_CREATE &&
|
||||||
in->body.open.mode == mode &&
|
in.body.open.mode == mode &&
|
||||||
(0 == strcmp(relpath, name)));
|
(0 == strcmp(relpath, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
@ -80,18 +80,18 @@ TEST_F(Create, attr_cache)
|
|||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
expect_create(RELPATH, mode,
|
expect_create(RELPATH, mode,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, create);
|
SET_OUT_HEADER_LEN(out, create);
|
||||||
out->body.create.entry.attr.mode = mode;
|
out.body.create.entry.attr.mode = mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
@ -114,25 +114,25 @@ TEST_F(Create, clear_attr_cache)
|
|||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == 1);
|
in.header.nodeid == 1);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(2)
|
).Times(2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = 1;
|
out.body.attr.attr.ino = 1;
|
||||||
out->body.attr.attr.mode = S_IFDIR | 0755;
|
out.body.attr.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
expect_create(RELPATH, mode,
|
expect_create(RELPATH, mode,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, create);
|
SET_OUT_HEADER_LEN(out, create);
|
||||||
out->body.create.entry.attr.mode = mode;
|
out.body.create.entry.attr.mode = mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
EXPECT_EQ(0, stat("mountpoint", &sb)) << strerror(errno);
|
EXPECT_EQ(0, stat("mountpoint", &sb)) << strerror(errno);
|
||||||
@ -177,30 +177,30 @@ TEST_F(Create, Enosys)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_mknod_in);
|
sizeof(fuse_mknod_in);
|
||||||
return (in->header.opcode == FUSE_MKNOD &&
|
return (in.header.opcode == FUSE_MKNOD &&
|
||||||
in->body.mknod.mode == (S_IFREG | mode) &&
|
in.body.mknod.mode == (S_IFREG | mode) &&
|
||||||
in->body.mknod.rdev == 0 &&
|
in.body.mknod.rdev == 0 &&
|
||||||
(0 == strcmp(RELPATH, name)));
|
(0 == strcmp(RELPATH, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
@ -229,12 +229,12 @@ TEST_F(Create, entry_cache_negative)
|
|||||||
/* create will first do a LOOKUP, adding a negative cache entry */
|
/* create will first do a LOOKUP, adding a negative cache entry */
|
||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(ReturnNegativeCache(&entry_valid));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(ReturnNegativeCache(&entry_valid));
|
||||||
expect_create(RELPATH, mode,
|
expect_create(RELPATH, mode,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, create);
|
SET_OUT_HEADER_LEN(out, create);
|
||||||
out->body.create.entry.attr.mode = mode;
|
out.body.create.entry.attr.mode = mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
|
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
|
||||||
@ -261,11 +261,11 @@ TEST_F(Create, entry_cache_negative_purge)
|
|||||||
|
|
||||||
/* Then the CREATE should purge the negative cache entry */
|
/* Then the CREATE should purge the negative cache entry */
|
||||||
expect_create(RELPATH, mode,
|
expect_create(RELPATH, mode,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, create);
|
SET_OUT_HEADER_LEN(out, create);
|
||||||
out->body.create.entry.attr.mode = mode;
|
out.body.create.entry.attr.mode = mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
|
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
|
||||||
@ -305,12 +305,12 @@ TEST_F(Create, ok)
|
|||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
expect_create(RELPATH, mode,
|
expect_create(RELPATH, mode,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, create);
|
SET_OUT_HEADER_LEN(out, create);
|
||||||
out->body.create.entry.attr.mode = mode;
|
out.body.create.entry.attr.mode = mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
|
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
|
||||||
@ -336,12 +336,12 @@ TEST_F(Create, wronly_0444)
|
|||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
expect_create(RELPATH, mode,
|
expect_create(RELPATH, mode,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, create);
|
SET_OUT_HEADER_LEN(out, create);
|
||||||
out->body.create.entry.attr.mode = mode;
|
out.body.create.entry.attr.mode = mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_CREAT | O_WRONLY, mode);
|
fd = open(FULLPATH, O_CREAT | O_WRONLY, mode);
|
||||||
@ -359,12 +359,12 @@ TEST_F(Create_7_8, ok)
|
|||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
expect_create(RELPATH, mode,
|
expect_create(RELPATH, mode,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, create_7_8);
|
SET_OUT_HEADER_LEN(out, create_7_8);
|
||||||
out->body.create.entry.attr.mode = mode;
|
out.body.create.entry.attr.mode = mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
|
fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
|
||||||
|
@ -61,7 +61,7 @@ virtual void SetUp() {
|
|||||||
/* With -o default_permissions, FUSE_ACCESS should never be called */
|
/* With -o default_permissions, FUSE_ACCESS should never be called */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_ACCESS);
|
return (in.header.opcode == FUSE_ACCESS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
@ -72,18 +72,18 @@ void expect_chmod(uint64_t ino, mode_t mode, uint64_t size = 0)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == FATTR_MODE &&
|
in.body.setattr.valid == FATTR_MODE &&
|
||||||
in->body.setattr.mode == mode);
|
in.body.setattr.mode == mode);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | mode;
|
out.body.attr.attr.mode = S_IFREG | mode;
|
||||||
out->body.attr.attr.size = size;
|
out.body.attr.attr.size = size;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,18 +91,18 @@ void expect_create(const char *relpath, uint64_t ino)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_open_in);
|
sizeof(fuse_open_in);
|
||||||
return (in->header.opcode == FUSE_CREATE &&
|
return (in.header.opcode == FUSE_CREATE &&
|
||||||
(0 == strcmp(relpath, name)));
|
(0 == strcmp(relpath, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, create);
|
SET_OUT_HEADER_LEN(out, create);
|
||||||
out->body.create.entry.attr.mode = S_IFREG | 0644;
|
out.body.create.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,19 +111,19 @@ void expect_getattr(uint64_t ino, mode_t mode, uint64_t attr_valid, int times,
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(times)
|
).Times(times)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = mode;
|
out.body.attr.attr.mode = mode;
|
||||||
out->body.attr.attr.size = 0;
|
out.body.attr.attr.size = 0;
|
||||||
out->body.attr.attr.uid = uid;
|
out.body.attr.attr.uid = uid;
|
||||||
out->body.attr.attr.uid = gid;
|
out.body.attr.attr.uid = gid;
|
||||||
out->body.attr.attr_valid = attr_valid;
|
out.body.attr.attr_valid = attr_valid;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ void expect_removexattr()
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_REMOVEXATTR);
|
return (in.header.opcode == FUSE_REMOVEXATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(0)));
|
).WillOnce(Invoke(ReturnErrno(0)));
|
||||||
@ -171,7 +171,7 @@ void expect_getxattr(ProcessMockerT r)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETXATTR);
|
return (in.header.opcode == FUSE_GETXATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(r));
|
).WillOnce(Invoke(r));
|
||||||
@ -184,11 +184,11 @@ void expect_listxattr()
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_LISTXATTR);
|
return (in.header.opcode == FUSE_LISTXATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto& out) {
|
||||||
out->body.listxattr.size = 0;
|
out.body.listxattr.size = 0;
|
||||||
SET_OUT_HEADER_LEN(out, listxattr);
|
SET_OUT_HEADER_LEN(out, listxattr);
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ public:
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_RENAME);
|
return (in.header.opcode == FUSE_RENAME);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(error)));
|
).WillOnce(Invoke(ReturnErrno(error)));
|
||||||
@ -217,7 +217,7 @@ void expect_setxattr(int error)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETXATTR);
|
return (in.header.opcode == FUSE_SETXATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(error)));
|
).WillOnce(Invoke(ReturnErrno(error)));
|
||||||
@ -312,13 +312,13 @@ TEST_F(Chown, chown_to_self)
|
|||||||
/* The OS may optimize chown by omitting the redundant setattr */
|
/* The OS may optimize chown by omitting the redundant setattr */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR);
|
return (in.header.opcode == FUSE_SETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out){
|
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out){
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.mode = S_IFREG | mode;
|
out.body.attr.attr.mode = S_IFREG | mode;
|
||||||
out->body.attr.attr.uid = uid;
|
out.body.attr.attr.uid = uid;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_EQ(0, chown(FULLPATH, uid, -1)) << strerror(errno);
|
EXPECT_EQ(0, chown(FULLPATH, uid, -1)) << strerror(errno);
|
||||||
@ -342,17 +342,17 @@ TEST_F(Chown, clear_suid)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, uid);
|
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, uid);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.mode == newmode);
|
in.body.setattr.mode == newmode);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | newmode;
|
out.body.attr.attr.mode = S_IFREG | newmode;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_EQ(0, chown(FULLPATH, uid, -1)) << strerror(errno);
|
EXPECT_EQ(0, chown(FULLPATH, uid, -1)) << strerror(errno);
|
||||||
@ -371,7 +371,7 @@ TEST_F(Chown, eperm)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | mode, UINT64_MAX, geteuid());
|
expect_lookup(RELPATH, ino, S_IFREG | mode, UINT64_MAX, geteuid());
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR);
|
return (in.header.opcode == FUSE_SETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
@ -399,17 +399,17 @@ TEST_F(Chgrp, clear_suid)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, uid, gid);
|
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, uid, gid);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.mode == newmode);
|
in.body.setattr.mode == newmode);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | newmode;
|
out.body.attr.attr.mode = S_IFREG | newmode;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_EQ(0, chown(FULLPATH, -1, gid)) << strerror(errno);
|
EXPECT_EQ(0, chown(FULLPATH, -1, gid)) << strerror(errno);
|
||||||
@ -433,7 +433,7 @@ TEST_F(Chgrp, eperm)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | mode, UINT64_MAX, uid, gid);
|
expect_lookup(RELPATH, ino, S_IFREG | mode, UINT64_MAX, uid, gid);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR);
|
return (in.header.opcode == FUSE_SETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
@ -460,15 +460,15 @@ TEST_F(Chgrp, ok)
|
|||||||
/* The OS may optimize chgrp by omitting the redundant setattr */
|
/* The OS may optimize chgrp by omitting the redundant setattr */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out){
|
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out){
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.mode = S_IFREG | mode;
|
out.body.attr.attr.mode = S_IFREG | mode;
|
||||||
out->body.attr.attr.uid = uid;
|
out.body.attr.attr.uid = uid;
|
||||||
out->body.attr.attr.gid = newgid;
|
out.body.attr.attr.gid = newgid;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_EQ(0, chown(FULLPATH, -1, newgid)) << strerror(errno);
|
EXPECT_EQ(0, chown(FULLPATH, -1, newgid)) << strerror(errno);
|
||||||
@ -564,15 +564,15 @@ TEST_F(Utimensat, utime_now)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | mode, UINT64_MAX, owner);
|
expect_lookup(RELPATH, ino, S_IFREG | mode, UINT64_MAX, owner);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid & FATTR_ATIME &&
|
in.body.setattr.valid & FATTR_ATIME &&
|
||||||
in->body.setattr.valid & FATTR_MTIME);
|
in.body.setattr.valid & FATTR_MTIME);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.mode = S_IFREG | mode;
|
out.body.attr.attr.mode = S_IFREG | mode;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, utimensat(AT_FDCWD, FULLPATH, ×[0], 0))
|
ASSERT_EQ(0, utimensat(AT_FDCWD, FULLPATH, ×[0], 0))
|
||||||
@ -647,9 +647,9 @@ TEST_F(Getextattr, ok)
|
|||||||
/* Getting user attributes only requires read access */
|
/* Getting user attributes only requires read access */
|
||||||
expect_lookup(RELPATH, ino, S_IFREG | 0444, UINT64_MAX, 0);
|
expect_lookup(RELPATH, ino, S_IFREG | 0444, UINT64_MAX, 0);
|
||||||
expect_getxattr(
|
expect_getxattr(
|
||||||
ReturnImmediate([&](auto in __unused, auto out) {
|
ReturnImmediate([&](auto in __unused, auto& out) {
|
||||||
memcpy((void*)out->body.bytes, value, value_len);
|
memcpy((void*)out.body.bytes, value, value_len);
|
||||||
out->header.len = sizeof(out->header) + value_len;
|
out.header.len = sizeof(out.header) + value_len;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -892,13 +892,13 @@ TEST_F(Rename, eperm_on_sticky_dstdir)
|
|||||||
expect_lookup(RELSRC, src_ino, S_IFREG | 0644, UINT64_MAX);
|
expect_lookup(RELSRC, src_ino, S_IFREG | 0644, UINT64_MAX);
|
||||||
expect_lookup(RELDSTDIR, dstdir_ino, S_IFDIR | 01777, UINT64_MAX);
|
expect_lookup(RELDSTDIR, dstdir_ino, S_IFDIR | 01777, UINT64_MAX);
|
||||||
EXPECT_LOOKUP(dstdir_ino, RELDST)
|
EXPECT_LOOKUP(dstdir_ino, RELDST)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = dst_ino;
|
out.body.entry.nodeid = dst_ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.uid = 0;
|
out.body.entry.attr.uid = 0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(-1, rename(FULLSRC, FULLDST));
|
ASSERT_EQ(-1, rename(FULLSRC, FULLDST));
|
||||||
@ -952,14 +952,14 @@ TEST_F(Setattr, ok)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, geteuid());
|
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, geteuid());
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.mode == newmode);
|
in.body.setattr.mode == newmode);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.mode = S_IFREG | newmode;
|
out.body.attr.attr.mode = S_IFREG | newmode;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_EQ(0, chmod(FULLPATH, newmode)) << strerror(errno);
|
EXPECT_EQ(0, chmod(FULLPATH, newmode)) << strerror(errno);
|
||||||
@ -977,7 +977,7 @@ TEST_F(Setattr, eacces)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, 0);
|
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, 0);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR);
|
return (in.header.opcode == FUSE_SETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
@ -1004,16 +1004,16 @@ TEST_F(Setattr, ftruncate_of_newly_created_file)
|
|||||||
expect_create(RELPATH, ino);
|
expect_create(RELPATH, ino);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
(in->body.setattr.valid & FATTR_SIZE));
|
(in.body.setattr.valid & FATTR_SIZE));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino;
|
out.body.attr.attr.ino = ino;
|
||||||
out->body.attr.attr.mode = S_IFREG | mode;
|
out.body.attr.attr.mode = S_IFREG | mode;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_CREAT | O_RDWR, 0);
|
fd = open(FULLPATH, O_CREAT | O_RDWR, 0);
|
||||||
@ -1040,7 +1040,7 @@ TEST_F(Setattr, sgid_by_non_group_member)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, uid, gid);
|
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, uid, gid);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR);
|
return (in.header.opcode == FUSE_SETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
@ -1062,7 +1062,7 @@ TEST_F(Setattr, sticky_regular_file)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, geteuid());
|
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, geteuid());
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR);
|
return (in.header.opcode == FUSE_SETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
@ -1173,11 +1173,11 @@ TEST_F(Unlink, cached_unwritable_directory)
|
|||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.Times(AnyNumber())
|
.Times(AnyNumber())
|
||||||
.WillRepeatedly(Invoke(
|
.WillRepeatedly(Invoke(
|
||||||
ReturnImmediate([=](auto i __unused, auto out) {
|
ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ virtual void SetUp() {
|
|||||||
/* With -o default_permissions, FUSE_ACCESS should never be called */
|
/* With -o default_permissions, FUSE_ACCESS should never be called */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_ACCESS);
|
return (in.header.opcode == FUSE_ACCESS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
@ -72,19 +72,19 @@ void expect_getattr(uint64_t ino, mode_t mode, uint64_t attr_valid, int times,
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(times)
|
).Times(times)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = mode;
|
out.body.attr.attr.mode = mode;
|
||||||
out->body.attr.attr.size = 0;
|
out.body.attr.attr.size = 0;
|
||||||
out->body.attr.attr.uid = uid;
|
out.body.attr.attr.uid = uid;
|
||||||
out->body.attr.attr.uid = gid;
|
out.body.attr.attr.uid = gid;
|
||||||
out->body.attr.attr_valid = attr_valid;
|
out.body.attr.attr_valid = attr_valid;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,12 +110,12 @@ TEST_F(Setattr, sticky_regular_file)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, geteuid());
|
expect_lookup(RELPATH, ino, S_IFREG | oldmode, UINT64_MAX, geteuid());
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR);
|
return (in.header.opcode == FUSE_SETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.mode = S_IFREG | newmode;
|
out.body.attr.attr.mode = S_IFREG | newmode;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_EQ(0, chmod(FULLPATH, newmode)) << strerror(errno);
|
EXPECT_EQ(0, chmod(FULLPATH, newmode)) << strerror(errno);
|
||||||
|
@ -127,73 +127,73 @@ TEST_F(Kqueue, data)
|
|||||||
ASSERT_EQ(0, sem_init(&sem1, 0, 0)) << strerror(errno);
|
ASSERT_EQ(0, sem_init(&sem1, 0, 0)) << strerror(errno);
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, "foo")
|
EXPECT_LOOKUP(1, "foo")
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = foo_ino;
|
out.body.entry.nodeid = foo_ino;
|
||||||
})));
|
})));
|
||||||
EXPECT_LOOKUP(1, "bar")
|
EXPECT_LOOKUP(1, "bar")
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = bar_ino;
|
out.body.entry.nodeid = bar_ino;
|
||||||
})));
|
})));
|
||||||
EXPECT_LOOKUP(1, "baz")
|
EXPECT_LOOKUP(1, "baz")
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = baz_ino;
|
out.body.entry.nodeid = baz_ino;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == foo_ino);
|
in.header.nodeid == foo_ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
)
|
)
|
||||||
.WillOnce(Invoke(ReturnImmediate([&](auto in, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([&](auto in, auto& out) {
|
||||||
nready0 = m_mock->m_nready;
|
nready0 = m_mock->m_nready;
|
||||||
|
|
||||||
sem_post(&sem0);
|
sem_post(&sem0);
|
||||||
// Block the daemon so we can accumulate a few more ops
|
// Block the daemon so we can accumulate a few more ops
|
||||||
sem_wait(&sem1);
|
sem_wait(&sem1);
|
||||||
|
|
||||||
out->header.unique = in->header.unique;
|
out.header.unique = in.header.unique;
|
||||||
out->header.error = -EIO;
|
out.header.error = -EIO;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
(in->header.nodeid == bar_ino ||
|
(in.header.nodeid == bar_ino ||
|
||||||
in->header.nodeid == baz_ino));
|
in.header.nodeid == baz_ino));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([&](auto in, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([&](auto in, auto& out) {
|
||||||
nready1 = m_mock->m_nready;
|
nready1 = m_mock->m_nready;
|
||||||
out->header.unique = in->header.unique;
|
out.header.unique = in.header.unique;
|
||||||
out->header.error = -EIO;
|
out.header.error = -EIO;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
(in->header.nodeid == bar_ino ||
|
(in.header.nodeid == bar_ino ||
|
||||||
in->header.nodeid == baz_ino));
|
in.header.nodeid == baz_ino));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([&](auto in, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([&](auto in, auto& out) {
|
||||||
nready2 = m_mock->m_nready;
|
nready2 = m_mock->m_nready;
|
||||||
out->header.unique = in->header.unique;
|
out.header.unique = in.header.unique;
|
||||||
out->header.error = -EIO;
|
out.header.error = -EIO;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -159,27 +159,27 @@ TEST_F(Socket, read_write)
|
|||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_MKNOD);
|
return (in.header.opcode == FUSE_MKNOD);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.InSequence(seq)
|
.InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
@ -46,10 +46,10 @@ expect_flush(uint64_t ino, int times, pid_t lo, ProcessMockerT r)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_FLUSH &&
|
return (in.header.opcode == FUSE_FLUSH &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.flush.lock_owner == (uint64_t)lo &&
|
in.body.flush.lock_owner == (uint64_t)lo &&
|
||||||
in->body.flush.fh == FH);
|
in.body.flush.fh == FH);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(times)
|
).Times(times)
|
||||||
@ -69,7 +69,7 @@ void expect_release()
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_RELEASE);
|
return (in.header.opcode == FUSE_RELEASE);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnErrno(0)));
|
).WillRepeatedly(Invoke(ReturnErrno(0)));
|
||||||
@ -206,9 +206,9 @@ TEST_F(FlushWithLocks, unlock_on_close)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETLK &&
|
return (in.header.opcode == FUSE_SETLK &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setlk.fh == FH);
|
in.body.setlk.fh == FH);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(0)));
|
).WillOnce(Invoke(ReturnErrno(0)));
|
||||||
|
@ -54,15 +54,15 @@ void expect_fsync(uint64_t ino, uint32_t flags, int error)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_FSYNC &&
|
return (in.header.opcode == FUSE_FSYNC &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
/*
|
/*
|
||||||
* TODO: reenable pid check after fixing
|
* TODO: reenable pid check after fixing
|
||||||
* bug 236379
|
* bug 236379
|
||||||
*/
|
*/
|
||||||
//(pid_t)in->header.pid == getpid() &&
|
//(pid_t)in.header.pid == getpid() &&
|
||||||
in->body.fsync.fh == FH &&
|
in.body.fsync.fh == FH &&
|
||||||
in->body.fsync.fsync_flags == flags);
|
in.body.fsync.fsync_flags == flags);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(error)));
|
).WillOnce(Invoke(ReturnErrno(error)));
|
||||||
@ -129,16 +129,16 @@ TEST_F(Fsync, close)
|
|||||||
expect_write(ino, bufsize, CONTENTS);
|
expect_write(ino, bufsize, CONTENTS);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR);
|
return (in.header.opcode == FUSE_SETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
})));
|
})));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_FSYNC);
|
return (in.header.opcode == FUSE_FSYNC);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
|
@ -54,15 +54,15 @@ void expect_fsyncdir(uint64_t ino, uint32_t flags, int error)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_FSYNCDIR &&
|
return (in.header.opcode == FUSE_FSYNCDIR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
/*
|
/*
|
||||||
* TODO: reenable pid check after fixing
|
* TODO: reenable pid check after fixing
|
||||||
* bug 236379
|
* bug 236379
|
||||||
*/
|
*/
|
||||||
//(pid_t)in->header.pid == getpid() &&
|
//(pid_t)in.header.pid == getpid() &&
|
||||||
in->body.fsyncdir.fh == FH &&
|
in.body.fsyncdir.fh == FH &&
|
||||||
in->body.fsyncdir.fsync_flags == flags);
|
in.body.fsyncdir.fsync_flags == flags);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(error)));
|
).WillOnce(Invoke(ReturnErrno(error)));
|
||||||
|
@ -44,15 +44,15 @@ void expect_lookup(const char *relpath, uint64_t ino, mode_t mode,
|
|||||||
{
|
{
|
||||||
EXPECT_LOOKUP(1, relpath)
|
EXPECT_LOOKUP(1, relpath)
|
||||||
.Times(times)
|
.Times(times)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr_valid = attr_valid;
|
out.body.entry.attr_valid = attr_valid;
|
||||||
out->body.entry.attr_valid_nsec = attr_valid_nsec;
|
out.body.entry.attr_valid_nsec = attr_valid_nsec;
|
||||||
out->body.entry.attr.size = size;
|
out.body.entry.attr.size = size;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -77,23 +77,23 @@ TEST_F(Getattr, attr_cache)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
})));
|
})));
|
||||||
EXPECT_EQ(0, stat(FULLPATH, &sb));
|
EXPECT_EQ(0, stat(FULLPATH, &sb));
|
||||||
/* The second stat(2) should use cached attributes */
|
/* The second stat(2) should use cached attributes */
|
||||||
@ -115,17 +115,17 @@ TEST_F(Getattr, attr_cache_timeout)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1, 0, 0);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1, 0, 0);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(2)
|
).Times(2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr_valid_nsec = NAP_NS / 2;
|
out.body.attr.attr_valid_nsec = NAP_NS / 2;
|
||||||
out->body.attr.attr_valid = 0;
|
out.body.attr.attr_valid = 0;
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_EQ(0, stat(FULLPATH, &sb));
|
EXPECT_EQ(0, stat(FULLPATH, &sb));
|
||||||
@ -148,15 +148,15 @@ TEST_F(Getattr, blksize_zero)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 1, 1, 0, 0);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 1, 1, 0, 0);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.blksize = 0;
|
out.body.attr.attr.blksize = 0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, stat(FULLPATH, &sb)) << strerror(errno);
|
ASSERT_EQ(0, stat(FULLPATH, &sb)) << strerror(errno);
|
||||||
@ -173,8 +173,8 @@ TEST_F(Getattr, enoent)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1, 0, 0);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1, 0, 0);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
@ -192,27 +192,27 @@ TEST_F(Getattr, ok)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 1, 1, 0, 0);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 1, 1, 0, 0);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
out->body.attr.attr.size = 1;
|
out.body.attr.attr.size = 1;
|
||||||
out->body.attr.attr.blocks = 2;
|
out.body.attr.attr.blocks = 2;
|
||||||
out->body.attr.attr.atime = 3;
|
out.body.attr.attr.atime = 3;
|
||||||
out->body.attr.attr.mtime = 4;
|
out.body.attr.attr.mtime = 4;
|
||||||
out->body.attr.attr.ctime = 5;
|
out.body.attr.attr.ctime = 5;
|
||||||
out->body.attr.attr.atimensec = 6;
|
out.body.attr.attr.atimensec = 6;
|
||||||
out->body.attr.attr.mtimensec = 7;
|
out.body.attr.attr.mtimensec = 7;
|
||||||
out->body.attr.attr.ctimensec = 8;
|
out.body.attr.attr.ctimensec = 8;
|
||||||
out->body.attr.attr.nlink = 9;
|
out.body.attr.attr.nlink = 9;
|
||||||
out->body.attr.attr.uid = 10;
|
out.body.attr.attr.uid = 10;
|
||||||
out->body.attr.attr.gid = 11;
|
out.body.attr.attr.gid = 11;
|
||||||
out->body.attr.attr.rdev = 12;
|
out.body.attr.attr.rdev = 12;
|
||||||
out->body.attr.attr.blksize = 12345;
|
out.body.attr.attr.blksize = 12345;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, stat(FULLPATH, &sb)) << strerror(errno);
|
ASSERT_EQ(0, stat(FULLPATH, &sb)) << strerror(errno);
|
||||||
@ -248,35 +248,35 @@ TEST_F(Getattr_7_8, ok)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry_7_8);
|
SET_OUT_HEADER_LEN(out, entry_7_8);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr.size = 1;
|
out.body.entry.attr.size = 1;
|
||||||
})));
|
})));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr_7_8);
|
SET_OUT_HEADER_LEN(out, attr_7_8);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
out->body.attr.attr.size = 1;
|
out.body.attr.attr.size = 1;
|
||||||
out->body.attr.attr.blocks = 2;
|
out.body.attr.attr.blocks = 2;
|
||||||
out->body.attr.attr.atime = 3;
|
out.body.attr.attr.atime = 3;
|
||||||
out->body.attr.attr.mtime = 4;
|
out.body.attr.attr.mtime = 4;
|
||||||
out->body.attr.attr.ctime = 5;
|
out.body.attr.attr.ctime = 5;
|
||||||
out->body.attr.attr.atimensec = 6;
|
out.body.attr.attr.atimensec = 6;
|
||||||
out->body.attr.attr.mtimensec = 7;
|
out.body.attr.attr.mtimensec = 7;
|
||||||
out->body.attr.attr.ctimensec = 8;
|
out.body.attr.attr.ctimensec = 8;
|
||||||
out->body.attr.attr.nlink = 9;
|
out.body.attr.attr.nlink = 9;
|
||||||
out->body.attr.attr.uid = 10;
|
out.body.attr.attr.uid = 10;
|
||||||
out->body.attr.attr.gid = 11;
|
out.body.attr.attr.gid = 11;
|
||||||
out->body.attr.attr.rdev = 12;
|
out.body.attr.attr.rdev = 12;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, stat(FULLPATH, &sb)) << strerror(errno);
|
ASSERT_EQ(0, stat(FULLPATH, &sb)) << strerror(errno);
|
||||||
|
@ -100,11 +100,11 @@ void expect_mkdir(uint64_t *mkdir_unique)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_MKDIR);
|
return (in.header.opcode == FUSE_MKDIR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([=](auto in, auto &out __unused) {
|
).WillOnce(Invoke([=](auto in, auto &out __unused) {
|
||||||
*mkdir_unique = in->header.unique;
|
*mkdir_unique = in.header.unique;
|
||||||
sem_post(blocked_semaphore);
|
sem_post(blocked_semaphore);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -117,12 +117,12 @@ void expect_read(uint64_t ino, uint64_t *read_unique)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ &&
|
return (in.header.opcode == FUSE_READ &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([=](auto in, auto &out __unused) {
|
).WillOnce(Invoke([=](auto in, auto &out __unused) {
|
||||||
*read_unique = in->header.unique;
|
*read_unique = in.header.unique;
|
||||||
sem_post(blocked_semaphore);
|
sem_post(blocked_semaphore);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -135,12 +135,12 @@ void expect_write(uint64_t ino, uint64_t *write_unique)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_WRITE &&
|
return (in.header.opcode == FUSE_WRITE &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([=](auto in, auto &out __unused) {
|
).WillOnce(Invoke([=](auto in, auto &out __unused) {
|
||||||
*write_unique = in->header.unique;
|
*write_unique = in.header.unique;
|
||||||
sem_post(blocked_semaphore);
|
sem_post(blocked_semaphore);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -228,33 +228,33 @@ TEST_F(Interrupt, already_complete)
|
|||||||
expect_mkdir(&mkdir_unique);
|
expect_mkdir(&mkdir_unique);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_INTERRUPT &&
|
return (in.header.opcode == FUSE_INTERRUPT &&
|
||||||
in->body.interrupt.unique == mkdir_unique);
|
in.body.interrupt.unique == mkdir_unique);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([&](auto in, auto &out) {
|
).WillOnce(Invoke([&](auto in, auto &out) {
|
||||||
// First complete the mkdir request
|
// First complete the mkdir request
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
out0->header.unique = mkdir_unique;
|
out0->header.unique = mkdir_unique;
|
||||||
SET_OUT_HEADER_LEN(out0, entry);
|
SET_OUT_HEADER_LEN(*out0, entry);
|
||||||
out0->body.create.entry.attr.mode = S_IFDIR | MODE;
|
out0->body.create.entry.attr.mode = S_IFDIR | MODE;
|
||||||
out0->body.create.entry.nodeid = ino;
|
out0->body.create.entry.nodeid = ino;
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
|
|
||||||
// Then, respond EAGAIN to the interrupt request
|
// Then, respond EAGAIN to the interrupt request
|
||||||
auto out1 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out1(new mockfs_buf_out);
|
||||||
out1->header.unique = in->header.unique;
|
out1->header.unique = in.header.unique;
|
||||||
out1->header.error = -EAGAIN;
|
out1->header.error = -EAGAIN;
|
||||||
out1->header.len = sizeof(out1->header);
|
out1->header.len = sizeof(out1->header);
|
||||||
out.push_back(out1);
|
out.push_back(std::move(out1));
|
||||||
}));
|
}));
|
||||||
EXPECT_LOOKUP(1, RELDIRPATH0)
|
EXPECT_LOOKUP(1, RELDIRPATH0)
|
||||||
.InSequence(seq)
|
.InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFDIR | MODE;
|
out.body.entry.attr.mode = S_IFDIR | MODE;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 2;
|
out.body.entry.attr.nlink = 2;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
setup_interruptor(self);
|
setup_interruptor(self);
|
||||||
@ -289,44 +289,44 @@ TEST_F(Interrupt, enosys)
|
|||||||
expect_mkdir(&mkdir_unique);
|
expect_mkdir(&mkdir_unique);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_INTERRUPT &&
|
return (in.header.opcode == FUSE_INTERRUPT &&
|
||||||
in->body.interrupt.unique == mkdir_unique);
|
in.body.interrupt.unique == mkdir_unique);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
.WillOnce(Invoke([&](auto in, auto &out) {
|
.WillOnce(Invoke([&](auto in, auto &out) {
|
||||||
// reject FUSE_INTERRUPT and respond to the FUSE_MKDIR
|
// reject FUSE_INTERRUPT and respond to the FUSE_MKDIR
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
auto out1 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out1(new mockfs_buf_out);
|
||||||
|
|
||||||
out0->header.unique = in->header.unique;
|
out0->header.unique = in.header.unique;
|
||||||
out0->header.error = -ENOSYS;
|
out0->header.error = -ENOSYS;
|
||||||
out0->header.len = sizeof(out0->header);
|
out0->header.len = sizeof(out0->header);
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
|
|
||||||
SET_OUT_HEADER_LEN(out1, entry);
|
SET_OUT_HEADER_LEN(*out1, entry);
|
||||||
out1->body.create.entry.attr.mode = S_IFDIR | MODE;
|
out1->body.create.entry.attr.mode = S_IFDIR | MODE;
|
||||||
out1->body.create.entry.nodeid = ino1;
|
out1->body.create.entry.nodeid = ino1;
|
||||||
out1->header.unique = mkdir_unique;
|
out1->header.unique = mkdir_unique;
|
||||||
out.push_back(out1);
|
out.push_back(std::move(out1));
|
||||||
}));
|
}));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_MKDIR);
|
return (in.header.opcode == FUSE_MKDIR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
.WillOnce(Invoke([&](auto in, auto &out) {
|
.WillOnce(Invoke([&](auto in, auto &out) {
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
|
|
||||||
sem_post(&sem0);
|
sem_post(&sem0);
|
||||||
sem_wait(&sem1);
|
sem_wait(&sem1);
|
||||||
|
|
||||||
SET_OUT_HEADER_LEN(out0, entry);
|
SET_OUT_HEADER_LEN(*out0, entry);
|
||||||
out0->body.create.entry.attr.mode = S_IFDIR | MODE;
|
out0->body.create.entry.attr.mode = S_IFDIR | MODE;
|
||||||
out0->body.create.entry.nodeid = ino0;
|
out0->body.create.entry.nodeid = ino0;
|
||||||
out0->header.unique = in->header.unique;
|
out0->header.unique = in.header.unique;
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setup_interruptor(self);
|
setup_interruptor(self);
|
||||||
@ -367,8 +367,8 @@ TEST_F(Interrupt, fatal_signal)
|
|||||||
expect_mkdir(&mkdir_unique);
|
expect_mkdir(&mkdir_unique);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_INTERRUPT &&
|
return (in.header.opcode == FUSE_INTERRUPT &&
|
||||||
in->body.interrupt.unique == mkdir_unique);
|
in.body.interrupt.unique == mkdir_unique);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
).WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
||||||
@ -424,18 +424,18 @@ TEST_F(Interrupt, ignore)
|
|||||||
expect_mkdir(&mkdir_unique);
|
expect_mkdir(&mkdir_unique);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_INTERRUPT &&
|
return (in.header.opcode == FUSE_INTERRUPT &&
|
||||||
in->body.interrupt.unique == mkdir_unique);
|
in.body.interrupt.unique == mkdir_unique);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([&](auto in __unused, auto &out) {
|
).WillOnce(Invoke([&](auto in __unused, auto &out) {
|
||||||
// Ignore FUSE_INTERRUPT; respond to the FUSE_MKDIR
|
// Ignore FUSE_INTERRUPT; respond to the FUSE_MKDIR
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
out0->header.unique = mkdir_unique;
|
out0->header.unique = mkdir_unique;
|
||||||
SET_OUT_HEADER_LEN(out0, entry);
|
SET_OUT_HEADER_LEN(*out0, entry);
|
||||||
out0->body.create.entry.attr.mode = S_IFDIR | MODE;
|
out0->body.create.entry.attr.mode = S_IFDIR | MODE;
|
||||||
out0->body.create.entry.nodeid = ino;
|
out0->body.create.entry.nodeid = ino;
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setup_interruptor(self);
|
setup_interruptor(self);
|
||||||
@ -466,18 +466,18 @@ TEST_F(Interrupt, in_kernel_restartable)
|
|||||||
expect_open(ino1, 0, 1);
|
expect_open(ino1, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_MKDIR);
|
return (in.header.opcode == FUSE_MKDIR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([&](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([&](auto in __unused, auto& out) {
|
||||||
/* Let the next write proceed */
|
/* Let the next write proceed */
|
||||||
sem_post(&sem1);
|
sem_post(&sem1);
|
||||||
/* Pause the daemon thread so it won't read the next op */
|
/* Pause the daemon thread so it won't read the next op */
|
||||||
sem_wait(&sem0);
|
sem_wait(&sem0);
|
||||||
|
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.create.entry.attr.mode = S_IFDIR | MODE;
|
out.body.create.entry.attr.mode = S_IFDIR | MODE;
|
||||||
out->body.create.entry.nodeid = ino0;
|
out.body.create.entry.nodeid = ino0;
|
||||||
})));
|
})));
|
||||||
FuseTest::expect_read(ino1, 0, FILESIZE, 0, NULL);
|
FuseTest::expect_read(ino1, 0, FILESIZE, 0, NULL);
|
||||||
|
|
||||||
@ -539,18 +539,18 @@ TEST_F(Interrupt, in_kernel_nonrestartable)
|
|||||||
expect_open(ino1, 0, 1);
|
expect_open(ino1, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_MKDIR);
|
return (in.header.opcode == FUSE_MKDIR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([&](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([&](auto in __unused, auto& out) {
|
||||||
/* Let the next write proceed */
|
/* Let the next write proceed */
|
||||||
sem_post(&sem1);
|
sem_post(&sem1);
|
||||||
/* Pause the daemon thread so it won't read the next op */
|
/* Pause the daemon thread so it won't read the next op */
|
||||||
sem_wait(&sem0);
|
sem_wait(&sem0);
|
||||||
|
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.create.entry.attr.mode = S_IFDIR | MODE;
|
out.body.create.entry.attr.mode = S_IFDIR | MODE;
|
||||||
out->body.create.entry.nodeid = ino0;
|
out.body.create.entry.nodeid = ino0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd1 = open(FULLPATH1, O_WRONLY);
|
fd1 = open(FULLPATH1, O_WRONLY);
|
||||||
@ -597,16 +597,16 @@ TEST_F(Interrupt, in_progress)
|
|||||||
expect_mkdir(&mkdir_unique);
|
expect_mkdir(&mkdir_unique);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_INTERRUPT &&
|
return (in.header.opcode == FUSE_INTERRUPT &&
|
||||||
in->body.interrupt.unique == mkdir_unique);
|
in.body.interrupt.unique == mkdir_unique);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([&](auto in __unused, auto &out) {
|
).WillOnce(Invoke([&](auto in __unused, auto &out) {
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
out0->header.error = -EINTR;
|
out0->header.error = -EINTR;
|
||||||
out0->header.unique = mkdir_unique;
|
out0->header.unique = mkdir_unique;
|
||||||
out0->header.len = sizeof(out0->header);
|
out0->header.len = sizeof(out0->header);
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setup_interruptor(self);
|
setup_interruptor(self);
|
||||||
@ -633,16 +633,16 @@ TEST_F(Interrupt, in_progress_read)
|
|||||||
expect_read(ino, &read_unique);
|
expect_read(ino, &read_unique);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_INTERRUPT &&
|
return (in.header.opcode == FUSE_INTERRUPT &&
|
||||||
in->body.interrupt.unique == read_unique);
|
in.body.interrupt.unique == read_unique);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([&](auto in __unused, auto &out) {
|
).WillOnce(Invoke([&](auto in __unused, auto &out) {
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
out0->header.error = -EINTR;
|
out0->header.error = -EINTR;
|
||||||
out0->header.unique = read_unique;
|
out0->header.unique = read_unique;
|
||||||
out0->header.len = sizeof(out0->header);
|
out0->header.len = sizeof(out0->header);
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_RDONLY);
|
fd = open(FULLPATH, O_RDONLY);
|
||||||
@ -670,12 +670,12 @@ TEST_F(Interrupt, priority)
|
|||||||
EXPECT_LOOKUP(1, RELDIRPATH1).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELDIRPATH1).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_MKDIR);
|
return (in.header.opcode == FUSE_MKDIR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([&](auto in, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([&](auto in, auto& out) {
|
||||||
mkdir_unique = in->header.unique;
|
mkdir_unique = in.header.unique;
|
||||||
|
|
||||||
/* Let the next mkdir proceed */
|
/* Let the next mkdir proceed */
|
||||||
sem_post(&sem1);
|
sem_post(&sem1);
|
||||||
@ -684,9 +684,9 @@ TEST_F(Interrupt, priority)
|
|||||||
sem_wait(&sem0);
|
sem_wait(&sem0);
|
||||||
|
|
||||||
/* Finally, interrupt the original op */
|
/* Finally, interrupt the original op */
|
||||||
out->header.error = -EINTR;
|
out.header.error = -EINTR;
|
||||||
out->header.unique = mkdir_unique;
|
out.header.unique = mkdir_unique;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
/*
|
/*
|
||||||
* FUSE_INTERRUPT should be received before the second FUSE_MKDIR,
|
* FUSE_INTERRUPT should be received before the second FUSE_MKDIR,
|
||||||
@ -694,22 +694,22 @@ TEST_F(Interrupt, priority)
|
|||||||
*/
|
*/
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_INTERRUPT &&
|
return (in.header.opcode == FUSE_INTERRUPT &&
|
||||||
in->body.interrupt.unique == mkdir_unique);
|
in.body.interrupt.unique == mkdir_unique);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnErrno(EAGAIN)));
|
.WillOnce(Invoke(ReturnErrno(EAGAIN)));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_MKDIR);
|
return (in.header.opcode == FUSE_MKDIR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.create.entry.attr.mode = S_IFDIR | MODE;
|
out.body.create.entry.attr.mode = S_IFDIR | MODE;
|
||||||
out->body.create.entry.nodeid = ino1;
|
out.body.create.entry.nodeid = ino1;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
/* Use a separate thread for the first mkdir */
|
/* Use a separate thread for the first mkdir */
|
||||||
@ -751,8 +751,8 @@ TEST_F(Interrupt, too_soon)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_INTERRUPT &&
|
return (in.header.opcode == FUSE_INTERRUPT &&
|
||||||
in->body.interrupt.unique == mkdir_unique);
|
in.body.interrupt.unique == mkdir_unique);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
@ -760,17 +760,17 @@ TEST_F(Interrupt, too_soon)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([&](auto in) {
|
ResultOf([&](auto in) {
|
||||||
return (in->header.opcode == FUSE_INTERRUPT &&
|
return (in.header.opcode == FUSE_INTERRUPT &&
|
||||||
in->body.interrupt.unique == mkdir_unique);
|
in.body.interrupt.unique == mkdir_unique);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).InSequence(seq)
|
).InSequence(seq)
|
||||||
.WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
.WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
out0->header.error = -EINTR;
|
out0->header.error = -EINTR;
|
||||||
out0->header.unique = mkdir_unique;
|
out0->header.unique = mkdir_unique;
|
||||||
out0->header.len = sizeof(out0->header);
|
out0->header.len = sizeof(out0->header);
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setup_interruptor(self);
|
setup_interruptor(self);
|
||||||
|
@ -43,20 +43,20 @@ void expect_link(uint64_t ino, const char *relpath, mode_t mode, uint32_t nlink)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes
|
const char *name = (const char*)in.body.bytes
|
||||||
+ sizeof(struct fuse_link_in);
|
+ sizeof(struct fuse_link_in);
|
||||||
return (in->header.opcode == FUSE_LINK &&
|
return (in.header.opcode == FUSE_LINK &&
|
||||||
in->body.link.oldnodeid == ino &&
|
in.body.link.oldnodeid == ino &&
|
||||||
(0 == strcmp(name, relpath)));
|
(0 == strcmp(name, relpath)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.attr.nlink = nlink;
|
out.body.entry.attr.nlink = nlink;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,20 +77,20 @@ void expect_link(uint64_t ino, const char *relpath, mode_t mode, uint32_t nlink)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes
|
const char *name = (const char*)in.body.bytes
|
||||||
+ sizeof(struct fuse_link_in);
|
+ sizeof(struct fuse_link_in);
|
||||||
return (in->header.opcode == FUSE_LINK &&
|
return (in.header.opcode == FUSE_LINK &&
|
||||||
in->body.link.oldnodeid == ino &&
|
in.body.link.oldnodeid == ino &&
|
||||||
(0 == strcmp(name, relpath)));
|
(0 == strcmp(name, relpath)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry_7_8);
|
SET_OUT_HEADER_LEN(out, entry_7_8);
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.attr.nlink = nlink;
|
out.body.entry.attr.nlink = nlink;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,26 +117,26 @@ TEST_F(Link, clear_attr_cache)
|
|||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == 1);
|
in.header.nodeid == 1);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(2)
|
).Times(2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = 1;
|
out.body.attr.attr.ino = 1;
|
||||||
out->body.attr.attr.mode = S_IFDIR | 0755;
|
out.body.attr.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELDST)
|
EXPECT_LOOKUP(1, RELDST)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
expect_link(ino, RELPATH, mode, 2);
|
expect_link(ino, RELPATH, mode, 2);
|
||||||
|
|
||||||
@ -158,10 +158,10 @@ TEST_F(Link, emlink)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes
|
const char *name = (const char*)in.body.bytes
|
||||||
+ sizeof(struct fuse_link_in);
|
+ sizeof(struct fuse_link_in);
|
||||||
return (in->header.opcode == FUSE_LINK &&
|
return (in.header.opcode == FUSE_LINK &&
|
||||||
in->body.link.oldnodeid == dst_ino &&
|
in.body.link.oldnodeid == dst_ino &&
|
||||||
(0 == strcmp(name, RELPATH)));
|
(0 == strcmp(name, RELPATH)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
@ -183,13 +183,13 @@ TEST_F(Link, ok)
|
|||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
EXPECT_LOOKUP(1, RELDST)
|
EXPECT_LOOKUP(1, RELDST)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
expect_link(ino, RELPATH, mode, 2);
|
expect_link(ino, RELPATH, mode, 2);
|
||||||
|
|
||||||
@ -211,13 +211,13 @@ TEST_F(Link_7_8, ok)
|
|||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
EXPECT_LOOKUP(1, RELDST)
|
EXPECT_LOOKUP(1, RELDST)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry_7_8);
|
SET_OUT_HEADER_LEN(out, entry_7_8);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
expect_link(ino, RELPATH, mode, 2);
|
expect_link(ino, RELPATH, mode, 2);
|
||||||
|
|
||||||
|
@ -110,20 +110,20 @@ TEST_F(Getlk, no_locks)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETLK &&
|
return (in.header.opcode == FUSE_GETLK &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.getlk.fh == FH &&
|
in.body.getlk.fh == FH &&
|
||||||
in->body.getlk.owner == (uint32_t)pid &&
|
in.body.getlk.owner == (uint32_t)pid &&
|
||||||
in->body.getlk.lk.start == 10 &&
|
in.body.getlk.lk.start == 10 &&
|
||||||
in->body.getlk.lk.end == 1009 &&
|
in.body.getlk.lk.end == 1009 &&
|
||||||
in->body.getlk.lk.type == F_RDLCK &&
|
in.body.getlk.lk.type == F_RDLCK &&
|
||||||
in->body.getlk.lk.pid == (uint64_t)pid);
|
in.body.getlk.lk.pid == (uint64_t)pid);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, getlk);
|
SET_OUT_HEADER_LEN(out, getlk);
|
||||||
out->body.getlk.lk = in->body.getlk.lk;
|
out.body.getlk.lk = in.body.getlk.lk;
|
||||||
out->body.getlk.lk.type = F_UNLCK;
|
out.body.getlk.lk.type = F_UNLCK;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_RDWR);
|
fd = open(FULLPATH, O_RDWR);
|
||||||
@ -154,22 +154,22 @@ TEST_F(Getlk, lock_exists)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETLK &&
|
return (in.header.opcode == FUSE_GETLK &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.getlk.fh == FH &&
|
in.body.getlk.fh == FH &&
|
||||||
in->body.getlk.owner == (uint32_t)pid &&
|
in.body.getlk.owner == (uint32_t)pid &&
|
||||||
in->body.getlk.lk.start == 10 &&
|
in.body.getlk.lk.start == 10 &&
|
||||||
in->body.getlk.lk.end == 1009 &&
|
in.body.getlk.lk.end == 1009 &&
|
||||||
in->body.getlk.lk.type == F_RDLCK &&
|
in.body.getlk.lk.type == F_RDLCK &&
|
||||||
in->body.getlk.lk.pid == (uint64_t)pid);
|
in.body.getlk.lk.pid == (uint64_t)pid);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, getlk);
|
SET_OUT_HEADER_LEN(out, getlk);
|
||||||
out->body.getlk.lk.start = 100;
|
out.body.getlk.lk.start = 100;
|
||||||
out->body.getlk.lk.end = 199;
|
out.body.getlk.lk.end = 199;
|
||||||
out->body.getlk.lk.type = F_WRLCK;
|
out.body.getlk.lk.type = F_WRLCK;
|
||||||
out->body.getlk.lk.pid = (uint32_t)pid2;;
|
out.body.getlk.lk.pid = (uint32_t)pid2;;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_RDWR);
|
fd = open(FULLPATH, O_RDWR);
|
||||||
@ -231,14 +231,14 @@ TEST_F(Setlk, set)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETLK &&
|
return (in.header.opcode == FUSE_SETLK &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setlk.fh == FH &&
|
in.body.setlk.fh == FH &&
|
||||||
in->body.setlk.owner == (uint32_t)pid &&
|
in.body.setlk.owner == (uint32_t)pid &&
|
||||||
in->body.setlk.lk.start == 10 &&
|
in.body.setlk.lk.start == 10 &&
|
||||||
in->body.setlk.lk.end == 1009 &&
|
in.body.setlk.lk.end == 1009 &&
|
||||||
in->body.setlk.lk.type == F_RDLCK &&
|
in.body.setlk.lk.type == F_RDLCK &&
|
||||||
in->body.setlk.lk.pid == (uint64_t)pid);
|
in.body.setlk.lk.pid == (uint64_t)pid);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(0)));
|
).WillOnce(Invoke(ReturnErrno(0)));
|
||||||
@ -269,14 +269,14 @@ TEST_F(Setlk, set_eof)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETLK &&
|
return (in.header.opcode == FUSE_SETLK &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setlk.fh == FH &&
|
in.body.setlk.fh == FH &&
|
||||||
in->body.setlk.owner == (uint32_t)pid &&
|
in.body.setlk.owner == (uint32_t)pid &&
|
||||||
in->body.setlk.lk.start == 10 &&
|
in.body.setlk.lk.start == 10 &&
|
||||||
in->body.setlk.lk.end == OFFSET_MAX &&
|
in.body.setlk.lk.end == OFFSET_MAX &&
|
||||||
in->body.setlk.lk.type == F_RDLCK &&
|
in.body.setlk.lk.type == F_RDLCK &&
|
||||||
in->body.setlk.lk.pid == (uint64_t)pid);
|
in.body.setlk.lk.pid == (uint64_t)pid);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(0)));
|
).WillOnce(Invoke(ReturnErrno(0)));
|
||||||
@ -307,14 +307,14 @@ TEST_F(Setlk, eagain)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETLK &&
|
return (in.header.opcode == FUSE_SETLK &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setlk.fh == FH &&
|
in.body.setlk.fh == FH &&
|
||||||
in->body.setlk.owner == (uint32_t)pid &&
|
in.body.setlk.owner == (uint32_t)pid &&
|
||||||
in->body.setlk.lk.start == 10 &&
|
in.body.setlk.lk.start == 10 &&
|
||||||
in->body.setlk.lk.end == 1009 &&
|
in.body.setlk.lk.end == 1009 &&
|
||||||
in->body.setlk.lk.type == F_RDLCK &&
|
in.body.setlk.lk.type == F_RDLCK &&
|
||||||
in->body.setlk.lk.pid == (uint64_t)pid);
|
in.body.setlk.lk.pid == (uint64_t)pid);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(EAGAIN)));
|
).WillOnce(Invoke(ReturnErrno(EAGAIN)));
|
||||||
@ -377,14 +377,14 @@ TEST_F(Setlkw, set)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETLK &&
|
return (in.header.opcode == FUSE_SETLK &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setlkw.fh == FH &&
|
in.body.setlkw.fh == FH &&
|
||||||
in->body.setlkw.owner == (uint32_t)pid &&
|
in.body.setlkw.owner == (uint32_t)pid &&
|
||||||
in->body.setlkw.lk.start == 10 &&
|
in.body.setlkw.lk.start == 10 &&
|
||||||
in->body.setlkw.lk.end == 1009 &&
|
in.body.setlkw.lk.end == 1009 &&
|
||||||
in->body.setlkw.lk.type == F_RDLCK &&
|
in.body.setlkw.lk.type == F_RDLCK &&
|
||||||
in->body.setlkw.lk.pid == (uint64_t)pid);
|
in.body.setlkw.lk.pid == (uint64_t)pid);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(0)));
|
).WillOnce(Invoke(ReturnErrno(0)));
|
||||||
|
@ -59,25 +59,25 @@ TEST_F(Lookup, attr_cache)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.ino = ino; // Must match nodeid
|
out.body.entry.attr.ino = ino; // Must match nodeid
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.attr.size = 1;
|
out.body.entry.attr.size = 1;
|
||||||
out->body.entry.attr.blocks = 2;
|
out.body.entry.attr.blocks = 2;
|
||||||
out->body.entry.attr.atime = 3;
|
out.body.entry.attr.atime = 3;
|
||||||
out->body.entry.attr.mtime = 4;
|
out.body.entry.attr.mtime = 4;
|
||||||
out->body.entry.attr.ctime = 5;
|
out.body.entry.attr.ctime = 5;
|
||||||
out->body.entry.attr.atimensec = 6;
|
out.body.entry.attr.atimensec = 6;
|
||||||
out->body.entry.attr.mtimensec = 7;
|
out.body.entry.attr.mtimensec = 7;
|
||||||
out->body.entry.attr.ctimensec = 8;
|
out.body.entry.attr.ctimensec = 8;
|
||||||
out->body.entry.attr.nlink = 9;
|
out.body.entry.attr.nlink = 9;
|
||||||
out->body.entry.attr.uid = 10;
|
out.body.entry.attr.uid = 10;
|
||||||
out->body.entry.attr.gid = 11;
|
out.body.entry.attr.gid = 11;
|
||||||
out->body.entry.attr.rdev = 12;
|
out.body.entry.attr.rdev = 12;
|
||||||
out->body.entry.generation = generation;
|
out.body.entry.generation = generation;
|
||||||
})));
|
})));
|
||||||
/* stat(2) issues a VOP_LOOKUP followed by a VOP_GETATTR */
|
/* stat(2) issues a VOP_LOOKUP followed by a VOP_GETATTR */
|
||||||
ASSERT_EQ(0, stat(FULLPATH, &sb)) << strerror(errno);
|
ASSERT_EQ(0, stat(FULLPATH, &sb)) << strerror(errno);
|
||||||
@ -120,12 +120,12 @@ TEST_F(Lookup, attr_cache_timeout)
|
|||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.Times(2)
|
.Times(2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid_nsec = NAP_NS / 2;
|
out.body.entry.attr_valid_nsec = NAP_NS / 2;
|
||||||
out->body.entry.attr.ino = ino; // Must match nodeid
|
out.body.entry.attr.ino = ino; // Must match nodeid
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
/* access(2) will issue a VOP_LOOKUP and fill the attr cache */
|
/* access(2) will issue a VOP_LOOKUP and fill the attr cache */
|
||||||
@ -143,12 +143,12 @@ TEST_F(Lookup, dot)
|
|||||||
uint64_t ino = 42;
|
uint64_t ino = 42;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELDIRPATH)
|
EXPECT_LOOKUP(1, RELDIRPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFDIR | 0755;
|
out.body.entry.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -164,12 +164,12 @@ TEST_F(Lookup, dotdot)
|
|||||||
const char RELDIRPATH[] = "some_dir";
|
const char RELDIRPATH[] = "some_dir";
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELDIRPATH)
|
EXPECT_LOOKUP(1, RELDIRPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFDIR | 0755;
|
out.body.entry.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.entry.nodeid = 14;
|
out.body.entry.nodeid = 14;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -195,11 +195,11 @@ TEST_F(Lookup, enotdir)
|
|||||||
const char RELPATH[] = "not_a_dir";
|
const char RELPATH[] = "not_a_dir";
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = 42;
|
out.body.entry.nodeid = 42;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(-1, access(FULLPATH, F_OK));
|
ASSERT_EQ(-1, access(FULLPATH, F_OK));
|
||||||
@ -216,11 +216,11 @@ TEST_F(Lookup, entry_cache)
|
|||||||
const char RELPATH[] = "some_file.txt";
|
const char RELPATH[] = "some_file.txt";
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = 14;
|
out.body.entry.nodeid = 14;
|
||||||
})));
|
})));
|
||||||
ASSERT_EQ(0, access(FULLPATH, F_OK)) << strerror(errno);
|
ASSERT_EQ(0, access(FULLPATH, F_OK)) << strerror(errno);
|
||||||
/* The second access(2) should use the cache */
|
/* The second access(2) should use the cache */
|
||||||
@ -275,11 +275,11 @@ TEST_F(Lookup, entry_cache_timeout)
|
|||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.Times(2)
|
.Times(2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.entry_valid_nsec = NAP_NS / 2;
|
out.body.entry.entry_valid_nsec = NAP_NS / 2;
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = 14;
|
out.body.entry.nodeid = 14;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
/* access(2) will issue a VOP_LOOKUP and fill the entry cache */
|
/* access(2) will issue a VOP_LOOKUP and fill the entry cache */
|
||||||
@ -303,10 +303,10 @@ TEST_F(Lookup, ok)
|
|||||||
const char RELPATH[] = "some_file.txt";
|
const char RELPATH[] = "some_file.txt";
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = 14;
|
out.body.entry.nodeid = 14;
|
||||||
})));
|
})));
|
||||||
/*
|
/*
|
||||||
* access(2) is one of the few syscalls that will not (always) follow
|
* access(2) is one of the few syscalls that will not (always) follow
|
||||||
@ -325,16 +325,16 @@ TEST_F(Lookup, subdir)
|
|||||||
uint64_t file_ino = 3;
|
uint64_t file_ino = 3;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, DIRPATH)
|
EXPECT_LOOKUP(1, DIRPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFDIR | 0755;
|
out.body.entry.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.entry.nodeid = dir_ino;
|
out.body.entry.nodeid = dir_ino;
|
||||||
})));
|
})));
|
||||||
EXPECT_LOOKUP(dir_ino, RELPATH)
|
EXPECT_LOOKUP(dir_ino, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = file_ino;
|
out.body.entry.nodeid = file_ino;
|
||||||
})));
|
})));
|
||||||
/*
|
/*
|
||||||
* access(2) is one of the few syscalls that will not (always) follow
|
* access(2) is one of the few syscalls that will not (always) follow
|
||||||
@ -369,10 +369,10 @@ TEST_F(Lookup_7_8, ok)
|
|||||||
const char RELPATH[] = "some_file.txt";
|
const char RELPATH[] = "some_file.txt";
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry_7_8);
|
SET_OUT_HEADER_LEN(out, entry_7_8);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = 14;
|
out.body.entry.nodeid = 14;
|
||||||
})));
|
})));
|
||||||
/*
|
/*
|
||||||
* access(2) is one of the few syscalls that will not (always) follow
|
* access(2) is one of the few syscalls that will not (always) follow
|
||||||
|
@ -60,10 +60,10 @@ TEST_F(Mkdir, emlink)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_mkdir_in);
|
sizeof(fuse_mkdir_in);
|
||||||
return (in->header.opcode == FUSE_MKDIR &&
|
return (in.header.opcode == FUSE_MKDIR &&
|
||||||
in->body.mkdir.mode == (S_IFDIR | mode) &&
|
in.body.mkdir.mode == (S_IFDIR | mode) &&
|
||||||
(0 == strcmp(RELPATH, name)));
|
(0 == strcmp(RELPATH, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
@ -94,19 +94,19 @@ TEST_F(Mkdir, entry_cache_negative)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_open_in);
|
sizeof(fuse_open_in);
|
||||||
return (in->header.opcode == FUSE_MKDIR &&
|
return (in.header.opcode == FUSE_MKDIR &&
|
||||||
in->body.mkdir.mode == (S_IFDIR | mode) &&
|
in.body.mkdir.mode == (S_IFDIR | mode) &&
|
||||||
(0 == strcmp(RELPATH, name)));
|
(0 == strcmp(RELPATH, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.create.entry.attr.mode = S_IFDIR | mode;
|
out.body.create.entry.attr.mode = S_IFDIR | mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, mkdir(FULLPATH, mode)) << strerror(errno);
|
ASSERT_EQ(0, mkdir(FULLPATH, mode)) << strerror(errno);
|
||||||
@ -131,18 +131,18 @@ TEST_F(Mkdir, entry_cache_negative_purge)
|
|||||||
/* Then the MKDIR should purge the negative cache entry */
|
/* Then the MKDIR should purge the negative cache entry */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_open_in);
|
sizeof(fuse_open_in);
|
||||||
return (in->header.opcode == FUSE_MKDIR &&
|
return (in.header.opcode == FUSE_MKDIR &&
|
||||||
in->body.mkdir.mode == (S_IFDIR | mode) &&
|
in.body.mkdir.mode == (S_IFDIR | mode) &&
|
||||||
(0 == strcmp(RELPATH, name)));
|
(0 == strcmp(RELPATH, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFDIR | mode;
|
out.body.entry.attr.mode = S_IFDIR | mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, mkdir(FULLPATH, mode)) << strerror(errno);
|
ASSERT_EQ(0, mkdir(FULLPATH, mode)) << strerror(errno);
|
||||||
@ -164,19 +164,19 @@ TEST_F(Mkdir, ok)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_mkdir_in);
|
sizeof(fuse_mkdir_in);
|
||||||
return (in->header.opcode == FUSE_MKDIR &&
|
return (in.header.opcode == FUSE_MKDIR &&
|
||||||
in->body.mkdir.mode == (S_IFDIR | mode) &&
|
in.body.mkdir.mode == (S_IFDIR | mode) &&
|
||||||
(0 == strcmp(RELPATH, name)));
|
(0 == strcmp(RELPATH, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.create.entry.attr.mode = S_IFDIR | mode;
|
out.body.create.entry.attr.mode = S_IFDIR | mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, mkdir(FULLPATH, mode)) << strerror(errno);
|
ASSERT_EQ(0, mkdir(FULLPATH, mode)) << strerror(errno);
|
||||||
@ -193,19 +193,19 @@ TEST_F(Mkdir_7_8, ok)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_mkdir_in);
|
sizeof(fuse_mkdir_in);
|
||||||
return (in->header.opcode == FUSE_MKDIR &&
|
return (in.header.opcode == FUSE_MKDIR &&
|
||||||
in->body.mkdir.mode == (S_IFDIR | mode) &&
|
in.body.mkdir.mode == (S_IFDIR | mode) &&
|
||||||
(0 == strcmp(RELPATH, name)));
|
(0 == strcmp(RELPATH, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry_7_8);
|
SET_OUT_HEADER_LEN(out, entry_7_8);
|
||||||
out->body.create.entry.attr.mode = S_IFDIR | mode;
|
out.body.create.entry.attr.mode = S_IFDIR | mode;
|
||||||
out->body.create.entry.nodeid = ino;
|
out.body.create.entry.nodeid = ino;
|
||||||
out->body.create.entry.entry_valid = UINT64_MAX;
|
out.body.create.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.create.entry.attr_valid = UINT64_MAX;
|
out.body.create.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, mkdir(FULLPATH, mode)) << strerror(errno);
|
ASSERT_EQ(0, mkdir(FULLPATH, mode)) << strerror(errno);
|
||||||
|
@ -66,21 +66,21 @@ void expect_mknod(mode_t mode, dev_t dev) {
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_mknod_in);
|
sizeof(fuse_mknod_in);
|
||||||
return (in->header.opcode == FUSE_MKNOD &&
|
return (in.header.opcode == FUSE_MKNOD &&
|
||||||
in->body.mknod.mode == mode &&
|
in.body.mknod.mode == mode &&
|
||||||
in->body.mknod.rdev == (uint32_t)dev &&
|
in.body.mknod.rdev == (uint32_t)dev &&
|
||||||
(0 == strcmp(RELPATH, name)));
|
(0 == strcmp(RELPATH, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.rdev = dev;
|
out.body.entry.attr.rdev = dev;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,10 +119,10 @@ TEST_F(Mknod, eperm)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes +
|
const char *name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_mknod_in);
|
sizeof(fuse_mknod_in);
|
||||||
return (in->header.opcode == FUSE_MKNOD &&
|
return (in.header.opcode == FUSE_MKNOD &&
|
||||||
in->body.mknod.mode == mode &&
|
in.body.mknod.mode == mode &&
|
||||||
(0 == strcmp(RELPATH, name)));
|
(0 == strcmp(RELPATH, name)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
|
@ -112,11 +112,11 @@ ProcessMockerT
|
|||||||
ReturnErrno(int error)
|
ReturnErrno(int error)
|
||||||
{
|
{
|
||||||
return([=](auto in, auto &out) {
|
return([=](auto in, auto &out) {
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
out0->header.unique = in->header.unique;
|
out0->header.unique = in.header.unique;
|
||||||
out0->header.error = -error;
|
out0->header.error = -error;
|
||||||
out0->header.len = sizeof(out0->header);
|
out0->header.len = sizeof(out0->header);
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,26 +126,26 @@ ReturnNegativeCache(const struct timespec *entry_valid)
|
|||||||
{
|
{
|
||||||
return([=](auto in, auto &out) {
|
return([=](auto in, auto &out) {
|
||||||
/* nodeid means ENOENT and cache it */
|
/* nodeid means ENOENT and cache it */
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
out0->body.entry.nodeid = 0;
|
out0->body.entry.nodeid = 0;
|
||||||
out0->header.unique = in->header.unique;
|
out0->header.unique = in.header.unique;
|
||||||
out0->header.error = 0;
|
out0->header.error = 0;
|
||||||
out0->body.entry.entry_valid = entry_valid->tv_sec;
|
out0->body.entry.entry_valid = entry_valid->tv_sec;
|
||||||
out0->body.entry.entry_valid_nsec = entry_valid->tv_nsec;
|
out0->body.entry.entry_valid_nsec = entry_valid->tv_nsec;
|
||||||
SET_OUT_HEADER_LEN(out0, entry);
|
SET_OUT_HEADER_LEN(*out0, entry);
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessMockerT
|
ProcessMockerT
|
||||||
ReturnImmediate(std::function<void(const struct mockfs_buf_in *in,
|
ReturnImmediate(std::function<void(const mockfs_buf_in& in,
|
||||||
struct mockfs_buf_out *out)> f)
|
struct mockfs_buf_out &out)> f)
|
||||||
{
|
{
|
||||||
return([=](auto in, auto &out) {
|
return([=](auto& in, auto &out) {
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
out0->header.unique = in->header.unique;
|
out0->header.unique = in.header.unique;
|
||||||
f(in, out0);
|
f(in, *out0);
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,117 +153,117 @@ void sigint_handler(int __unused sig) {
|
|||||||
// Don't do anything except interrupt the daemon's read(2) call
|
// Don't do anything except interrupt the daemon's read(2) call
|
||||||
}
|
}
|
||||||
|
|
||||||
void debug_fuseop(const mockfs_buf_in *in)
|
void debug_fuseop(const mockfs_buf_in &in)
|
||||||
{
|
{
|
||||||
printf("%-11s ino=%2" PRIu64, opcode2opname(in->header.opcode),
|
printf("%-11s ino=%2" PRIu64, opcode2opname(in.header.opcode),
|
||||||
in->header.nodeid);
|
in.header.nodeid);
|
||||||
if (verbosity > 1) {
|
if (verbosity > 1) {
|
||||||
printf(" uid=%5u gid=%5u pid=%5u unique=%" PRIu64 " len=%u",
|
printf(" uid=%5u gid=%5u pid=%5u unique=%" PRIu64 " len=%u",
|
||||||
in->header.uid, in->header.gid, in->header.pid,
|
in.header.uid, in.header.gid, in.header.pid,
|
||||||
in->header.unique, in->header.len);
|
in.header.unique, in.header.len);
|
||||||
}
|
}
|
||||||
switch (in->header.opcode) {
|
switch (in.header.opcode) {
|
||||||
const char *name, *value;
|
const char *name, *value;
|
||||||
|
|
||||||
case FUSE_ACCESS:
|
case FUSE_ACCESS:
|
||||||
printf(" mask=%#x", in->body.access.mask);
|
printf(" mask=%#x", in.body.access.mask);
|
||||||
break;
|
break;
|
||||||
case FUSE_CREATE:
|
case FUSE_CREATE:
|
||||||
name = (const char*)in->body.bytes +
|
name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_open_in);
|
sizeof(fuse_open_in);
|
||||||
printf(" flags=%#x name=%s",
|
printf(" flags=%#x name=%s",
|
||||||
in->body.open.flags, name);
|
in.body.open.flags, name);
|
||||||
break;
|
break;
|
||||||
case FUSE_FLUSH:
|
case FUSE_FLUSH:
|
||||||
printf(" fh=%#" PRIx64 " lock_owner=%" PRIu64,
|
printf(" fh=%#" PRIx64 " lock_owner=%" PRIu64,
|
||||||
in->body.flush.fh,
|
in.body.flush.fh,
|
||||||
in->body.flush.lock_owner);
|
in.body.flush.lock_owner);
|
||||||
break;
|
break;
|
||||||
case FUSE_FORGET:
|
case FUSE_FORGET:
|
||||||
printf(" nlookup=%" PRIu64, in->body.forget.nlookup);
|
printf(" nlookup=%" PRIu64, in.body.forget.nlookup);
|
||||||
break;
|
break;
|
||||||
case FUSE_FSYNC:
|
case FUSE_FSYNC:
|
||||||
printf(" flags=%#x", in->body.fsync.fsync_flags);
|
printf(" flags=%#x", in.body.fsync.fsync_flags);
|
||||||
break;
|
break;
|
||||||
case FUSE_FSYNCDIR:
|
case FUSE_FSYNCDIR:
|
||||||
printf(" flags=%#x", in->body.fsyncdir.fsync_flags);
|
printf(" flags=%#x", in.body.fsyncdir.fsync_flags);
|
||||||
break;
|
break;
|
||||||
case FUSE_INTERRUPT:
|
case FUSE_INTERRUPT:
|
||||||
printf(" unique=%" PRIu64, in->body.interrupt.unique);
|
printf(" unique=%" PRIu64, in.body.interrupt.unique);
|
||||||
break;
|
break;
|
||||||
case FUSE_LINK:
|
case FUSE_LINK:
|
||||||
printf(" oldnodeid=%" PRIu64, in->body.link.oldnodeid);
|
printf(" oldnodeid=%" PRIu64, in.body.link.oldnodeid);
|
||||||
break;
|
break;
|
||||||
case FUSE_LOOKUP:
|
case FUSE_LOOKUP:
|
||||||
printf(" %s", in->body.lookup);
|
printf(" %s", in.body.lookup);
|
||||||
break;
|
break;
|
||||||
case FUSE_MKDIR:
|
case FUSE_MKDIR:
|
||||||
name = (const char*)in->body.bytes +
|
name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_mkdir_in);
|
sizeof(fuse_mkdir_in);
|
||||||
printf(" name=%s mode=%#o", name, in->body.mkdir.mode);
|
printf(" name=%s mode=%#o", name, in.body.mkdir.mode);
|
||||||
break;
|
break;
|
||||||
case FUSE_MKNOD:
|
case FUSE_MKNOD:
|
||||||
printf(" mode=%#o rdev=%x", in->body.mknod.mode,
|
printf(" mode=%#o rdev=%x", in.body.mknod.mode,
|
||||||
in->body.mknod.rdev);
|
in.body.mknod.rdev);
|
||||||
break;
|
break;
|
||||||
case FUSE_OPEN:
|
case FUSE_OPEN:
|
||||||
printf(" flags=%#x mode=%#o",
|
printf(" flags=%#x mode=%#o",
|
||||||
in->body.open.flags, in->body.open.mode);
|
in.body.open.flags, in.body.open.mode);
|
||||||
break;
|
break;
|
||||||
case FUSE_OPENDIR:
|
case FUSE_OPENDIR:
|
||||||
printf(" flags=%#x mode=%#o",
|
printf(" flags=%#x mode=%#o",
|
||||||
in->body.opendir.flags, in->body.opendir.mode);
|
in.body.opendir.flags, in.body.opendir.mode);
|
||||||
break;
|
break;
|
||||||
case FUSE_READ:
|
case FUSE_READ:
|
||||||
printf(" offset=%" PRIu64 " size=%u",
|
printf(" offset=%" PRIu64 " size=%u",
|
||||||
in->body.read.offset,
|
in.body.read.offset,
|
||||||
in->body.read.size);
|
in.body.read.size);
|
||||||
break;
|
break;
|
||||||
case FUSE_READDIR:
|
case FUSE_READDIR:
|
||||||
printf(" fh=%#" PRIx64 " offset=%" PRIu64 " size=%u",
|
printf(" fh=%#" PRIx64 " offset=%" PRIu64 " size=%u",
|
||||||
in->body.readdir.fh, in->body.readdir.offset,
|
in.body.readdir.fh, in.body.readdir.offset,
|
||||||
in->body.readdir.size);
|
in.body.readdir.size);
|
||||||
break;
|
break;
|
||||||
case FUSE_RELEASE:
|
case FUSE_RELEASE:
|
||||||
printf(" fh=%#" PRIx64 " flags=%#x lock_owner=%" PRIu64,
|
printf(" fh=%#" PRIx64 " flags=%#x lock_owner=%" PRIu64,
|
||||||
in->body.release.fh,
|
in.body.release.fh,
|
||||||
in->body.release.flags,
|
in.body.release.flags,
|
||||||
in->body.release.lock_owner);
|
in.body.release.lock_owner);
|
||||||
break;
|
break;
|
||||||
case FUSE_SETATTR:
|
case FUSE_SETATTR:
|
||||||
if (verbosity <= 1) {
|
if (verbosity <= 1) {
|
||||||
printf(" valid=%#x", in->body.setattr.valid);
|
printf(" valid=%#x", in.body.setattr.valid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (in->body.setattr.valid & FATTR_MODE)
|
if (in.body.setattr.valid & FATTR_MODE)
|
||||||
printf(" mode=%#o", in->body.setattr.mode);
|
printf(" mode=%#o", in.body.setattr.mode);
|
||||||
if (in->body.setattr.valid & FATTR_UID)
|
if (in.body.setattr.valid & FATTR_UID)
|
||||||
printf(" uid=%u", in->body.setattr.uid);
|
printf(" uid=%u", in.body.setattr.uid);
|
||||||
if (in->body.setattr.valid & FATTR_GID)
|
if (in.body.setattr.valid & FATTR_GID)
|
||||||
printf(" gid=%u", in->body.setattr.gid);
|
printf(" gid=%u", in.body.setattr.gid);
|
||||||
if (in->body.setattr.valid & FATTR_SIZE)
|
if (in.body.setattr.valid & FATTR_SIZE)
|
||||||
printf(" size=%" PRIu64, in->body.setattr.size);
|
printf(" size=%" PRIu64, in.body.setattr.size);
|
||||||
if (in->body.setattr.valid & FATTR_ATIME)
|
if (in.body.setattr.valid & FATTR_ATIME)
|
||||||
printf(" atime=%" PRIu64 ".%u",
|
printf(" atime=%" PRIu64 ".%u",
|
||||||
in->body.setattr.atime,
|
in.body.setattr.atime,
|
||||||
in->body.setattr.atimensec);
|
in.body.setattr.atimensec);
|
||||||
if (in->body.setattr.valid & FATTR_MTIME)
|
if (in.body.setattr.valid & FATTR_MTIME)
|
||||||
printf(" mtime=%" PRIu64 ".%u",
|
printf(" mtime=%" PRIu64 ".%u",
|
||||||
in->body.setattr.mtime,
|
in.body.setattr.mtime,
|
||||||
in->body.setattr.mtimensec);
|
in.body.setattr.mtimensec);
|
||||||
if (in->body.setattr.valid & FATTR_FH)
|
if (in.body.setattr.valid & FATTR_FH)
|
||||||
printf(" fh=%" PRIu64 "", in->body.setattr.fh);
|
printf(" fh=%" PRIu64 "", in.body.setattr.fh);
|
||||||
break;
|
break;
|
||||||
case FUSE_SETLK:
|
case FUSE_SETLK:
|
||||||
printf(" fh=%#" PRIx64 " owner=%" PRIu64
|
printf(" fh=%#" PRIx64 " owner=%" PRIu64
|
||||||
" type=%u pid=%u",
|
" type=%u pid=%u",
|
||||||
in->body.setlk.fh, in->body.setlk.owner,
|
in.body.setlk.fh, in.body.setlk.owner,
|
||||||
in->body.setlk.lk.type,
|
in.body.setlk.lk.type,
|
||||||
in->body.setlk.lk.pid);
|
in.body.setlk.lk.pid);
|
||||||
if (verbosity >= 2) {
|
if (verbosity >= 2) {
|
||||||
printf(" range=[%" PRIu64 "-%" PRIu64 "]",
|
printf(" range=[%" PRIu64 "-%" PRIu64 "]",
|
||||||
in->body.setlk.lk.start,
|
in.body.setlk.lk.start,
|
||||||
in->body.setlk.lk.end);
|
in.body.setlk.lk.end);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FUSE_SETXATTR:
|
case FUSE_SETXATTR:
|
||||||
@ -271,7 +271,7 @@ void debug_fuseop(const mockfs_buf_in *in)
|
|||||||
* In theory neither the xattr name and value need be
|
* In theory neither the xattr name and value need be
|
||||||
* ASCII, but in this test suite they always are.
|
* ASCII, but in this test suite they always are.
|
||||||
*/
|
*/
|
||||||
name = (const char*)in->body.bytes +
|
name = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_setxattr_in);
|
sizeof(fuse_setxattr_in);
|
||||||
value = name + strlen(name) + 1;
|
value = name + strlen(name) + 1;
|
||||||
printf(" %s=%s", name, value);
|
printf(" %s=%s", name, value);
|
||||||
@ -279,9 +279,9 @@ void debug_fuseop(const mockfs_buf_in *in)
|
|||||||
case FUSE_WRITE:
|
case FUSE_WRITE:
|
||||||
printf(" fh=%#" PRIx64 " offset=%" PRIu64
|
printf(" fh=%#" PRIx64 " offset=%" PRIu64
|
||||||
" size=%u flags=%u",
|
" size=%u flags=%u",
|
||||||
in->body.write.fh,
|
in.body.write.fh,
|
||||||
in->body.write.offset, in->body.write.size,
|
in.body.write.offset, in.body.write.size,
|
||||||
in->body.write.write_flags);
|
in.body.write.write_flags);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -392,15 +392,10 @@ MockFS::~MockFS() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MockFS::init(uint32_t flags) {
|
void MockFS::init(uint32_t flags) {
|
||||||
mockfs_buf_in *in;
|
std::unique_ptr<mockfs_buf_in> in(new mockfs_buf_in);
|
||||||
mockfs_buf_out *out;
|
std::unique_ptr<mockfs_buf_out> out(new mockfs_buf_out);
|
||||||
|
|
||||||
in = new mockfs_buf_in;
|
read_request(*in);
|
||||||
ASSERT_TRUE(in != NULL);
|
|
||||||
out = new mockfs_buf_out;
|
|
||||||
ASSERT_TRUE(out != NULL);
|
|
||||||
|
|
||||||
read_request(in);
|
|
||||||
ASSERT_EQ(FUSE_INIT, in->header.opcode);
|
ASSERT_EQ(FUSE_INIT, in->header.opcode);
|
||||||
|
|
||||||
out->header.unique = in->header.unique;
|
out->header.unique = in->header.unique;
|
||||||
@ -420,11 +415,8 @@ void MockFS::init(uint32_t flags) {
|
|||||||
out->body.init.max_write = m_max_write;
|
out->body.init.max_write = m_max_write;
|
||||||
|
|
||||||
out->body.init.max_readahead = m_maxreadahead;
|
out->body.init.max_readahead = m_maxreadahead;
|
||||||
SET_OUT_HEADER_LEN(out, init);
|
SET_OUT_HEADER_LEN(*out, init);
|
||||||
write(m_fuse_fd, out, out->header.len);
|
write(m_fuse_fd, out.get(), out->header.len);
|
||||||
|
|
||||||
delete out;
|
|
||||||
delete in;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockFS::kill_daemon() {
|
void MockFS::kill_daemon() {
|
||||||
@ -439,20 +431,19 @@ void MockFS::kill_daemon() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MockFS::loop() {
|
void MockFS::loop() {
|
||||||
mockfs_buf_in *in;
|
std::vector<std::unique_ptr<mockfs_buf_out>> out;
|
||||||
std::vector<mockfs_buf_out*> out;
|
|
||||||
|
|
||||||
in = (mockfs_buf_in*) malloc(sizeof(*in));
|
std::unique_ptr<mockfs_buf_in> in(new mockfs_buf_in);
|
||||||
ASSERT_TRUE(in != NULL);
|
ASSERT_TRUE(in != NULL);
|
||||||
while (!m_quit) {
|
while (!m_quit) {
|
||||||
bzero(in, sizeof(*in));
|
bzero(in.get(), sizeof(*in));
|
||||||
read_request(in);
|
read_request(*in);
|
||||||
if (m_quit)
|
if (m_quit)
|
||||||
break;
|
break;
|
||||||
if (verbosity > 0)
|
if (verbosity > 0)
|
||||||
debug_fuseop(in);
|
debug_fuseop(*in);
|
||||||
if (pid_ok((pid_t)in->header.pid)) {
|
if (pid_ok((pid_t)in->header.pid)) {
|
||||||
process(in, out);
|
process(*in, out);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Reject any requests from unknown processes. Because
|
* Reject any requests from unknown processes. Because
|
||||||
@ -462,15 +453,12 @@ void MockFS::loop() {
|
|||||||
if (verbosity > 1)
|
if (verbosity > 1)
|
||||||
printf("\tREJECTED (wrong pid %d)\n",
|
printf("\tREJECTED (wrong pid %d)\n",
|
||||||
in->header.pid);
|
in->header.pid);
|
||||||
process_default(in, out);
|
process_default(*in, out);
|
||||||
}
|
|
||||||
for (auto &it: out) {
|
|
||||||
write_response(it);
|
|
||||||
delete it;
|
|
||||||
}
|
}
|
||||||
|
for (auto &it: out)
|
||||||
|
write_response(*it);
|
||||||
out.clear();
|
out.clear();
|
||||||
}
|
}
|
||||||
free(in);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MockFS::pid_ok(pid_t pid) {
|
bool MockFS::pid_ok(pid_t pid) {
|
||||||
@ -496,17 +484,17 @@ bool MockFS::pid_ok(pid_t pid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockFS::process_default(const mockfs_buf_in *in,
|
void MockFS::process_default(const mockfs_buf_in& in,
|
||||||
std::vector<mockfs_buf_out*> &out)
|
std::vector<std::unique_ptr<mockfs_buf_out>> &out)
|
||||||
{
|
{
|
||||||
auto out0 = new mockfs_buf_out;
|
std::unique_ptr<mockfs_buf_out> out0(new mockfs_buf_out);
|
||||||
out0->header.unique = in->header.unique;
|
out0->header.unique = in.header.unique;
|
||||||
out0->header.error = -EOPNOTSUPP;
|
out0->header.error = -EOPNOTSUPP;
|
||||||
out0->header.len = sizeof(out0->header);
|
out0->header.len = sizeof(out0->header);
|
||||||
out.push_back(out0);
|
out.push_back(std::move(out0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockFS::read_request(mockfs_buf_in *in) {
|
void MockFS::read_request(mockfs_buf_in &in) {
|
||||||
ssize_t res;
|
ssize_t res;
|
||||||
int nready = 0;
|
int nready = 0;
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
@ -570,14 +558,14 @@ void MockFS::read_request(mockfs_buf_in *in) {
|
|||||||
default:
|
default:
|
||||||
FAIL() << "not yet implemented";
|
FAIL() << "not yet implemented";
|
||||||
}
|
}
|
||||||
res = read(m_fuse_fd, in, sizeof(*in));
|
res = read(m_fuse_fd, &in, sizeof(in));
|
||||||
|
|
||||||
if (res < 0 && !m_quit)
|
if (res < 0 && !m_quit)
|
||||||
perror("read");
|
perror("read");
|
||||||
ASSERT_TRUE(res >= (ssize_t)sizeof(in->header) || m_quit);
|
ASSERT_TRUE(res >= static_cast<ssize_t>(sizeof(in.header)) || m_quit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockFS::write_response(mockfs_buf_out *out) {
|
void MockFS::write_response(const mockfs_buf_out &out) {
|
||||||
fd_set writefds;
|
fd_set writefds;
|
||||||
pollfd fds[1];
|
pollfd fds[1];
|
||||||
int nready, nfds;
|
int nready, nfds;
|
||||||
@ -607,7 +595,7 @@ void MockFS::write_response(mockfs_buf_out *out) {
|
|||||||
default:
|
default:
|
||||||
FAIL() << "not yet implemented";
|
FAIL() << "not yet implemented";
|
||||||
}
|
}
|
||||||
r = write(m_fuse_fd, out, out->header.len);
|
r = write(m_fuse_fd, &out, out.header.len);
|
||||||
ASSERT_TRUE(r > 0 || errno == EAGAIN) << strerror(errno);
|
ASSERT_TRUE(r > 0 || errno == EAGAIN) << strerror(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ extern "C" {
|
|||||||
#define FUSE_NORESPONSE 9999
|
#define FUSE_NORESPONSE 9999
|
||||||
|
|
||||||
#define SET_OUT_HEADER_LEN(out, variant) { \
|
#define SET_OUT_HEADER_LEN(out, variant) { \
|
||||||
(out)->header.len = (sizeof((out)->header) + \
|
(out).header.len = (sizeof((out).header) + \
|
||||||
sizeof((out)->body.variant)); \
|
sizeof((out).body.variant)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -61,9 +61,9 @@ extern "C" {
|
|||||||
#define EXPECT_LOOKUP(parent, path) \
|
#define EXPECT_LOOKUP(parent, path) \
|
||||||
EXPECT_CALL(*m_mock, process( \
|
EXPECT_CALL(*m_mock, process( \
|
||||||
ResultOf([=](auto in) { \
|
ResultOf([=](auto in) { \
|
||||||
return (in->header.opcode == FUSE_LOOKUP && \
|
return (in.header.opcode == FUSE_LOOKUP && \
|
||||||
in->header.nodeid == (parent) && \
|
in.header.nodeid == (parent) && \
|
||||||
strcmp(in->body.lookup, (path)) == 0); \
|
strcmp(in.body.lookup, (path)) == 0); \
|
||||||
}, Eq(true)), \
|
}, Eq(true)), \
|
||||||
_) \
|
_) \
|
||||||
)
|
)
|
||||||
@ -165,8 +165,11 @@ union fuse_payloads_out {
|
|||||||
fuse_attr_out_7_8 attr_7_8;
|
fuse_attr_out_7_8 attr_7_8;
|
||||||
fuse_create_out create;
|
fuse_create_out create;
|
||||||
fuse_create_out_7_8 create_7_8;
|
fuse_create_out_7_8 create_7_8;
|
||||||
/* The protocol places no limits on the size of bytes */
|
/*
|
||||||
uint8_t bytes[0x20000];
|
* The protocol places no limits on the size of bytes. Choose
|
||||||
|
* a size big enough for anything we'll test.
|
||||||
|
*/
|
||||||
|
uint8_t bytes[0x20000];
|
||||||
fuse_entry_out entry;
|
fuse_entry_out entry;
|
||||||
fuse_entry_out_7_8 entry_7_8;
|
fuse_entry_out_7_8 entry_7_8;
|
||||||
fuse_lk_out getlk;
|
fuse_lk_out getlk;
|
||||||
@ -194,8 +197,8 @@ struct mockfs_buf_out {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* A function that can be invoked in place of MockFS::process */
|
/* A function that can be invoked in place of MockFS::process */
|
||||||
typedef std::function<void (const struct mockfs_buf_in *in,
|
typedef std::function<void (const mockfs_buf_in& in,
|
||||||
std::vector<struct mockfs_buf_out*> &out)>
|
std::vector<std::unique_ptr<mockfs_buf_out>> &out)>
|
||||||
ProcessMockerT;
|
ProcessMockerT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -209,8 +212,8 @@ ProcessMockerT ReturnNegativeCache(const struct timespec *entry_valid);
|
|||||||
|
|
||||||
/* Helper function used for returning a single immediate response */
|
/* Helper function used for returning a single immediate response */
|
||||||
ProcessMockerT ReturnImmediate(
|
ProcessMockerT ReturnImmediate(
|
||||||
std::function<void(const struct mockfs_buf_in *in,
|
std::function<void(const mockfs_buf_in& in,
|
||||||
struct mockfs_buf_out *out)> f);
|
struct mockfs_buf_out &out)> f);
|
||||||
|
|
||||||
/* How the daemon should check /dev/fuse for readiness */
|
/* How the daemon should check /dev/fuse for readiness */
|
||||||
enum poll_method {
|
enum poll_method {
|
||||||
@ -261,17 +264,17 @@ class MockFS {
|
|||||||
bool pid_ok(pid_t pid);
|
bool pid_ok(pid_t pid);
|
||||||
|
|
||||||
/* Default request handler */
|
/* Default request handler */
|
||||||
void process_default(const mockfs_buf_in*,
|
void process_default(const mockfs_buf_in&,
|
||||||
std::vector<mockfs_buf_out*>&);
|
std::vector<std::unique_ptr<mockfs_buf_out>>&);
|
||||||
|
|
||||||
/* Entry point for the daemon thread */
|
/* Entry point for the daemon thread */
|
||||||
static void* service(void*);
|
static void* service(void*);
|
||||||
|
|
||||||
/* Read, but do not process, a single request from the kernel */
|
/* Read, but do not process, a single request from the kernel */
|
||||||
void read_request(mockfs_buf_in*);
|
void read_request(mockfs_buf_in& in);
|
||||||
|
|
||||||
/* Write a single response back to the kernel */
|
/* Write a single response back to the kernel */
|
||||||
void write_response(mockfs_buf_out *out);
|
void write_response(const mockfs_buf_out &out);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* pid of child process, for two-process test cases */
|
/* pid of child process, for two-process test cases */
|
||||||
@ -312,8 +315,8 @@ class MockFS {
|
|||||||
* plus a delayed response to an earlier operation, push two bufs.
|
* plus a delayed response to an earlier operation, push two bufs.
|
||||||
* Test cases must define each response using Googlemock expectations
|
* Test cases must define each response using Googlemock expectations
|
||||||
*/
|
*/
|
||||||
MOCK_METHOD2(process, void(const mockfs_buf_in*,
|
MOCK_METHOD2(process, void(const mockfs_buf_in&,
|
||||||
std::vector<mockfs_buf_out*>&));
|
std::vector<std::unique_ptr<mockfs_buf_out>>&));
|
||||||
|
|
||||||
/* Gracefully unmount */
|
/* Gracefully unmount */
|
||||||
void unmount();
|
void unmount();
|
||||||
|
@ -79,10 +79,10 @@ TEST_P(UpdateOk, update)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_STATFS);
|
return (in.header.opcode == FUSE_STATFS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
/*
|
/*
|
||||||
* All of the fields except f_flags are don't care, and f_flags is set by
|
* All of the fields except f_flags are don't care, and f_flags is set by
|
||||||
* the VFS
|
* the VFS
|
||||||
@ -114,10 +114,10 @@ TEST_P(UpdateErr, update)
|
|||||||
flag = mntflag_from_string(GetParam());
|
flag = mntflag_from_string(GetParam());
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_STATFS);
|
return (in.header.opcode == FUSE_STATFS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
/*
|
/*
|
||||||
* All of the fields except f_flags are don't care, and f_flags is set by
|
* All of the fields except f_flags are don't care, and f_flags is set by
|
||||||
* the VFS
|
* the VFS
|
||||||
|
@ -80,24 +80,24 @@ TEST_F(Fhstat, estale)
|
|||||||
|
|
||||||
EXPECT_LOOKUP(1, RELDIRPATH)
|
EXPECT_LOOKUP(1, RELDIRPATH)
|
||||||
.InSequence(seq)
|
.InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.generation = 1;
|
out.body.entry.generation = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = 0;
|
out.body.entry.entry_valid = 0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_LOOKUP(ino, ".")
|
EXPECT_LOOKUP(ino, ".")
|
||||||
.InSequence(seq)
|
.InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.generation = 2;
|
out.body.entry.generation = 2;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = 0;
|
out.body.entry.entry_valid = 0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
||||||
@ -117,25 +117,25 @@ TEST_F(Fhstat, lookup_dot)
|
|||||||
const uid_t uid = 12345;
|
const uid_t uid = 12345;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELDIRPATH)
|
EXPECT_LOOKUP(1, RELDIRPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.generation = 1;
|
out.body.entry.generation = 1;
|
||||||
out->body.entry.attr.uid = uid;
|
out.body.entry.attr.uid = uid;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = 0;
|
out.body.entry.entry_valid = 0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_LOOKUP(ino, ".")
|
EXPECT_LOOKUP(ino, ".")
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.generation = 1;
|
out.body.entry.generation = 1;
|
||||||
out->body.entry.attr.uid = uid;
|
out.body.entry.attr.uid = uid;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = 0;
|
out.body.entry.entry_valid = 0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
||||||
@ -160,14 +160,14 @@ TEST_F(Fhstat, DISABLED_cached)
|
|||||||
const uid_t uid = 12345;
|
const uid_t uid = 12345;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELDIRPATH)
|
EXPECT_LOOKUP(1, RELDIRPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.generation = 1;
|
out.body.entry.generation = 1;
|
||||||
out->body.entry.attr.uid = uid;
|
out.body.entry.attr.uid = uid;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
||||||
@ -189,13 +189,13 @@ TEST_F(FhstatNotExportable, lookup_dot)
|
|||||||
const mode_t mode = S_IFDIR | 0755;
|
const mode_t mode = S_IFDIR | 0755;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELDIRPATH)
|
EXPECT_LOOKUP(1, RELDIRPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.generation = 1;
|
out.body.entry.generation = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = 0;
|
out.body.entry.entry_valid = 0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(-1, getfh(FULLPATH, &fhp));
|
ASSERT_EQ(-1, getfh(FULLPATH, &fhp));
|
||||||
@ -211,13 +211,13 @@ TEST_F(Getfh, eoverflow)
|
|||||||
uint64_t ino = 42;
|
uint64_t ino = 42;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELDIRPATH)
|
EXPECT_LOOKUP(1, RELDIRPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFDIR | 0755;
|
out.body.entry.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.generation = (uint64_t)UINT32_MAX + 1;
|
out.body.entry.generation = (uint64_t)UINT32_MAX + 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_NE(0, getfh(FULLPATH, &fhp));
|
ASSERT_NE(0, getfh(FULLPATH, &fhp));
|
||||||
@ -233,12 +233,12 @@ TEST_F(Getfh, ok)
|
|||||||
uint64_t ino = 42;
|
uint64_t ino = 42;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELDIRPATH)
|
EXPECT_LOOKUP(1, RELDIRPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFDIR | 0755;
|
out.body.entry.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
||||||
@ -264,37 +264,37 @@ TEST_F(Readdir, getdirentries)
|
|||||||
ssize_t r;
|
ssize_t r;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.generation = 1;
|
out.body.entry.generation = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = 0;
|
out.body.entry.entry_valid = 0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_LOOKUP(ino, ".")
|
EXPECT_LOOKUP(ino, ".")
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.generation = 1;
|
out.body.entry.generation = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = 0;
|
out.body.entry.entry_valid = 0;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
expect_opendir(ino);
|
expect_opendir(ino);
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READDIR &&
|
return (in.header.opcode == FUSE_READDIR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.readdir.size == sizeof(buf));
|
in.body.readdir.size == sizeof(buf));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.error = 0;
|
out.header.error = 0;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
ASSERT_EQ(0, getfh(FULLPATH, &fhp)) << strerror(errno);
|
||||||
|
@ -52,13 +52,13 @@ void test_ok(int os_flags, int fuse_flags) {
|
|||||||
FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->body.open.flags == (uint32_t)fuse_flags &&
|
in.body.open.flags == (uint32_t)fuse_flags &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
@ -80,13 +80,13 @@ TEST_F(Open, chr)
|
|||||||
uint64_t ino = 42;
|
uint64_t ino = 42;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFCHR | 0644;
|
out.body.entry.attr.mode = S_IFCHR | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.rdev = 44; /* /dev/zero's rdev */
|
out.body.entry.attr.rdev = 44; /* /dev/zero's rdev */
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(-1, open(FULLPATH, O_RDONLY));
|
ASSERT_EQ(-1, open(FULLPATH, O_RDONLY));
|
||||||
@ -107,8 +107,8 @@ TEST_F(Open, enoent)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
@ -129,8 +129,8 @@ TEST_F(Open, eperm)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(EPERM)));
|
).WillOnce(Invoke(ReturnErrno(EPERM)));
|
||||||
@ -157,29 +157,29 @@ TEST_F(Open, multiple_creds)
|
|||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 2);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 2);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.pid == (uint32_t)getpid() &&
|
in.header.pid == (uint32_t)getpid() &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(
|
).WillOnce(Invoke(
|
||||||
ReturnImmediate([](auto in __unused, auto out) {
|
ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
out->body.open.fh = fh0;
|
out.body.open.fh = fh0;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.pid != (uint32_t)getpid() &&
|
in.header.pid != (uint32_t)getpid() &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(
|
).WillOnce(Invoke(
|
||||||
ReturnImmediate([](auto in __unused, auto out) {
|
ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
out->body.open.fh = fh1;
|
out.body.open.fh = fh1;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
})));
|
})));
|
||||||
expect_flush(ino, 2, ReturnErrno(0));
|
expect_flush(ino, 2, ReturnErrno(0));
|
||||||
|
@ -50,18 +50,18 @@ void expect_opendir(uint64_t ino, uint32_t flags, ProcessMockerT r)
|
|||||||
/* opendir(3) calls fstatfs */
|
/* opendir(3) calls fstatfs */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_STATFS);
|
return (in.header.opcode == FUSE_STATFS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, statfs);
|
SET_OUT_HEADER_LEN(out, statfs);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPENDIR &&
|
return (in.header.opcode == FUSE_OPENDIR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.opendir.flags == flags);
|
in.body.opendir.flags == flags);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(r));
|
).WillOnce(Invoke(r));
|
||||||
@ -113,7 +113,7 @@ TEST_F(Opendir, open)
|
|||||||
|
|
||||||
expect_lookup(RELPATH, ino);
|
expect_lookup(RELPATH, ino);
|
||||||
expect_opendir(ino, O_RDONLY,
|
expect_opendir(ino, O_RDONLY,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ TEST_F(Opendir, open_exec)
|
|||||||
|
|
||||||
expect_lookup(RELPATH, ino);
|
expect_lookup(RELPATH, ino);
|
||||||
expect_opendir(ino, O_EXEC,
|
expect_opendir(ino, O_EXEC,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ TEST_F(Opendir, opendir)
|
|||||||
|
|
||||||
expect_lookup(RELPATH, ino);
|
expect_lookup(RELPATH, ino);
|
||||||
expect_opendir(ino, O_RDONLY,
|
expect_opendir(ino, O_RDONLY,
|
||||||
ReturnImmediate([=](auto in __unused, auto out) {
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -168,10 +168,10 @@ TEST_F(AioRead, async_read_disabled)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ &&
|
return (in.header.opcode == FUSE_READ &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.read.fh == FH &&
|
in.body.read.fh == FH &&
|
||||||
in->body.read.offset == (uint64_t)off0);
|
in.body.read.offset == (uint64_t)off0);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke([&](auto in __unused, auto &out __unused) {
|
).WillRepeatedly(Invoke([&](auto in __unused, auto &out __unused) {
|
||||||
@ -180,10 +180,10 @@ TEST_F(AioRead, async_read_disabled)
|
|||||||
}));
|
}));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ &&
|
return (in.header.opcode == FUSE_READ &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.read.fh == FH &&
|
in.body.read.fh == FH &&
|
||||||
in->body.read.offset == (uint64_t)off1);
|
in.body.read.offset == (uint64_t)off1);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke([&](auto in __unused, auto &out __unused) {
|
).WillRepeatedly(Invoke([&](auto in __unused, auto &out __unused) {
|
||||||
@ -250,10 +250,10 @@ TEST_F(AsyncRead, async_read)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ &&
|
return (in.header.opcode == FUSE_READ &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.read.fh == FH &&
|
in.body.read.fh == FH &&
|
||||||
in->body.read.offset == (uint64_t)off0);
|
in.body.read.offset == (uint64_t)off0);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
).WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
||||||
@ -262,10 +262,10 @@ TEST_F(AsyncRead, async_read)
|
|||||||
}));
|
}));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ &&
|
return (in.header.opcode == FUSE_READ &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.read.fh == FH &&
|
in.body.read.fh == FH &&
|
||||||
in->body.read.offset == (uint64_t)off1);
|
in.body.read.offset == (uint64_t)off1);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
).WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
||||||
@ -395,7 +395,7 @@ TEST_F(Read, eio)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ);
|
return (in.header.opcode == FUSE_READ);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(EIO)));
|
).WillOnce(Invoke(ReturnErrno(EIO)));
|
||||||
@ -496,16 +496,16 @@ TEST_F(ReadCacheable, mmap)
|
|||||||
/* mmap may legitimately try to read more data than is available */
|
/* mmap may legitimately try to read more data than is available */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ &&
|
return (in.header.opcode == FUSE_READ &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.read.fh == Read::FH &&
|
in.body.read.fh == Read::FH &&
|
||||||
in->body.read.offset == 0 &&
|
in.body.read.offset == 0 &&
|
||||||
in->body.read.size >= bufsize);
|
in.body.read.size >= bufsize);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.len = sizeof(struct fuse_out_header) + bufsize;
|
out.header.len = sizeof(struct fuse_out_header) + bufsize;
|
||||||
memmove(out->body.bytes, CONTENTS, bufsize);
|
memmove(out.body.bytes, CONTENTS, bufsize);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_RDONLY);
|
fd = open(FULLPATH, O_RDONLY);
|
||||||
@ -683,16 +683,16 @@ TEST_F(ReadCacheable, sendfile)
|
|||||||
/* Like mmap, sendfile may request more data than is available */
|
/* Like mmap, sendfile may request more data than is available */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ &&
|
return (in.header.opcode == FUSE_READ &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.read.fh == Read::FH &&
|
in.body.read.fh == Read::FH &&
|
||||||
in->body.read.offset == 0 &&
|
in.body.read.offset == 0 &&
|
||||||
in->body.read.size >= bufsize);
|
in.body.read.size >= bufsize);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.len = sizeof(struct fuse_out_header) + bufsize;
|
out.header.len = sizeof(struct fuse_out_header) + bufsize;
|
||||||
memmove(out->body.bytes, CONTENTS, bufsize);
|
memmove(out.body.bytes, CONTENTS, bufsize);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, socketpair(PF_LOCAL, SOCK_STREAM, 0, sp))
|
ASSERT_EQ(0, socketpair(PF_LOCAL, SOCK_STREAM, 0, sp))
|
||||||
@ -702,7 +702,7 @@ TEST_F(ReadCacheable, sendfile)
|
|||||||
|
|
||||||
ASSERT_EQ(0, sendfile(fd, sp[1], 0, bufsize, NULL, &sbytes, 0))
|
ASSERT_EQ(0, sendfile(fd, sp[1], 0, bufsize, NULL, &sbytes, 0))
|
||||||
<< strerror(errno);
|
<< strerror(errno);
|
||||||
ASSERT_EQ((ssize_t)bufsize, read(sp[0], buf, bufsize))
|
ASSERT_EQ(static_cast<ssize_t>(bufsize), read(sp[0], buf, bufsize))
|
||||||
<< strerror(errno);
|
<< strerror(errno);
|
||||||
ASSERT_EQ(0, memcmp(buf, CONTENTS, bufsize));
|
ASSERT_EQ(0, memcmp(buf, CONTENTS, bufsize));
|
||||||
|
|
||||||
@ -728,7 +728,7 @@ TEST_F(ReadCacheable, DISABLED_sendfile_eio)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ);
|
return (in.header.opcode == FUSE_READ);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(EIO)));
|
).WillOnce(Invoke(ReturnErrno(EIO)));
|
||||||
|
@ -132,9 +132,9 @@ TEST_F(Readdir, eio)
|
|||||||
expect_opendir(ino);
|
expect_opendir(ino);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READDIR &&
|
return (in.header.opcode == FUSE_READDIR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.readdir.offset == 0);
|
in.body.readdir.offset == 0);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(EIO)));
|
).WillOnce(Invoke(ReturnErrno(EIO)));
|
||||||
@ -166,14 +166,14 @@ TEST_F(Readdir, getdirentries)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READDIR &&
|
return (in.header.opcode == FUSE_READDIR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.readdir.size == 8192);
|
in.body.readdir.size == 8192);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.error = 0;
|
out.header.error = 0;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_DIRECTORY);
|
fd = open(FULLPATH, O_DIRECTORY);
|
||||||
@ -203,15 +203,15 @@ TEST_F(Readdir, getdirentries_concurrent)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READDIR &&
|
return (in.header.opcode == FUSE_READDIR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.readdir.size == 8192);
|
in.body.readdir.size == 8192);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(2)
|
).Times(2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.error = 0;
|
out.header.error = 0;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd0 = open(FULLPATH, O_DIRECTORY);
|
fd0 = open(FULLPATH, O_DIRECTORY);
|
||||||
@ -247,13 +247,13 @@ TEST_F(Readdir, nodots)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READDIR &&
|
return (in.header.opcode == FUSE_READDIR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.error = 0;
|
out.header.error = 0;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@ -354,13 +354,13 @@ TEST_F(Readdir_7_8, nodots)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READDIR &&
|
return (in.header.opcode == FUSE_READDIR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.error = 0;
|
out.header.error = 0;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -49,8 +49,8 @@ void expect_readlink(uint64_t ino, ProcessMockerT r)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READLINK &&
|
return (in.header.opcode == FUSE_READLINK &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(r));
|
).WillOnce(Invoke(r));
|
||||||
@ -88,12 +88,12 @@ TEST_F(Readlink, ok)
|
|||||||
char buf[80];
|
char buf[80];
|
||||||
|
|
||||||
expect_lookup(RELPATH, ino);
|
expect_lookup(RELPATH, ino);
|
||||||
expect_readlink(ino, ReturnImmediate([=](auto in __unused, auto out) {
|
expect_readlink(ino, ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
strlcpy(out->body.str, dst, sizeof(out->body.str));
|
strlcpy(out.body.str, dst, sizeof(out.body.str));
|
||||||
out->header.len = sizeof(out->header) + strlen(dst) + 1;
|
out.header.len = sizeof(out.header) + strlen(dst) + 1;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
EXPECT_EQ((ssize_t)strlen(dst) + 1,
|
EXPECT_EQ(static_cast<ssize_t>(strlen(dst)) + 1,
|
||||||
readlink(FULLPATH, buf, sizeof(buf)));
|
readlink(FULLPATH, buf, sizeof(buf)));
|
||||||
EXPECT_STREQ(dst, buf);
|
EXPECT_STREQ(dst, buf);
|
||||||
}
|
}
|
||||||
@ -108,15 +108,16 @@ TEST_F(PushSymlinksIn, readlink)
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
expect_lookup(RELPATH, ino);
|
expect_lookup(RELPATH, ino);
|
||||||
expect_readlink(ino, ReturnImmediate([=](auto in __unused, auto out) {
|
expect_readlink(ino, ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
strlcpy(out->body.str, dst, sizeof(out->body.str));
|
strlcpy(out.body.str, dst, sizeof(out.body.str));
|
||||||
out->header.len = sizeof(out->header) + strlen(dst) + 1;
|
out.header.len = sizeof(out.header) + strlen(dst) + 1;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
ASSERT_NE(NULL, getcwd(wd, sizeof(wd))) << strerror(errno);
|
ASSERT_NE(NULL, getcwd(wd, sizeof(wd))) << strerror(errno);
|
||||||
len = snprintf(want, sizeof(want), "%s/mountpoint%s", wd, dst);
|
len = snprintf(want, sizeof(want), "%s/mountpoint%s", wd, dst);
|
||||||
ASSERT_LE(0, len) << strerror(errno);
|
ASSERT_LE(0, len) << strerror(errno);
|
||||||
|
|
||||||
EXPECT_EQ((ssize_t)len + 1, readlink(FULLPATH, buf, sizeof(buf)));
|
EXPECT_EQ(static_cast<ssize_t>(len) + 1,
|
||||||
|
readlink(FULLPATH, buf, sizeof(buf)));
|
||||||
EXPECT_STREQ(want, buf);
|
EXPECT_STREQ(want, buf);
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,11 @@ void expect_release(uint64_t ino, uint64_t lock_owner,
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_RELEASE &&
|
return (in.header.opcode == FUSE_RELEASE &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.release.lock_owner == lock_owner &&
|
in.body.release.lock_owner == lock_owner &&
|
||||||
in->body.release.fh == FH &&
|
in.body.release.fh == FH &&
|
||||||
in->body.release.flags == flags);
|
in.body.release.flags == flags);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(error)))
|
).WillOnce(Invoke(ReturnErrno(error)))
|
||||||
@ -201,14 +201,14 @@ TEST_F(ReleaseWithLocks, unlock_on_close)
|
|||||||
expect_open(ino, 0, 1);
|
expect_open(ino, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETLK &&
|
return (in.header.opcode == FUSE_SETLK &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setlk.fh == FH);
|
in.body.setlk.fh == FH);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(0)));
|
).WillOnce(Invoke(ReturnErrno(0)));
|
||||||
expect_flush(ino, 1, ReturnErrno(0));
|
expect_flush(ino, 1, ReturnErrno(0));
|
||||||
expect_release(ino, (uint64_t)pid, O_RDWR, 0);
|
expect_release(ino, static_cast<uint64_t>(pid), O_RDWR, 0);
|
||||||
|
|
||||||
fd = open(FULLPATH, O_RDWR);
|
fd = open(FULLPATH, O_RDWR);
|
||||||
ASSERT_LE(0, fd) << strerror(errno);
|
ASSERT_LE(0, fd) << strerror(errno);
|
||||||
|
@ -59,14 +59,14 @@ TEST_F(ReleaseDir, dup)
|
|||||||
expect_opendir(ino);
|
expect_opendir(ino);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READDIR &&
|
return (in.header.opcode == FUSE_READDIR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.readdir.offset == 0);
|
in.body.readdir.offset == 0);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.error = 0;
|
out.header.error = 0;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
expect_releasedir(ino, ReturnErrno(0));
|
expect_releasedir(ino, ReturnErrno(0));
|
||||||
|
|
||||||
|
@ -56,16 +56,16 @@ class Rename: public FuseTest {
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(
|
).WillOnce(Invoke(
|
||||||
ReturnImmediate([=](auto i __unused, auto out) {
|
ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = mode;
|
out.body.attr.attr.mode = mode;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,11 +128,11 @@ TEST_F(Rename, entry_cache_negative)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *src = (const char*)in->body.bytes +
|
const char *src = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_rename_in);
|
sizeof(fuse_rename_in);
|
||||||
const char *dst = src + strlen(src) + 1;
|
const char *dst = src + strlen(src) + 1;
|
||||||
return (in->header.opcode == FUSE_RENAME &&
|
return (in.header.opcode == FUSE_RENAME &&
|
||||||
in->body.rename.newdir == dst_dir_ino &&
|
in.body.rename.newdir == dst_dir_ino &&
|
||||||
(0 == strcmp(RELDST, dst)) &&
|
(0 == strcmp(RELDST, dst)) &&
|
||||||
(0 == strcmp(RELSRC, src)));
|
(0 == strcmp(RELSRC, src)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
@ -164,11 +164,11 @@ TEST_F(Rename, entry_cache_negative_purge)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *src = (const char*)in->body.bytes +
|
const char *src = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_rename_in);
|
sizeof(fuse_rename_in);
|
||||||
const char *dst = src + strlen(src) + 1;
|
const char *dst = src + strlen(src) + 1;
|
||||||
return (in->header.opcode == FUSE_RENAME &&
|
return (in.header.opcode == FUSE_RENAME &&
|
||||||
in->body.rename.newdir == dst_dir_ino &&
|
in.body.rename.newdir == dst_dir_ino &&
|
||||||
(0 == strcmp(RELDST, dst)) &&
|
(0 == strcmp(RELDST, dst)) &&
|
||||||
(0 == strcmp(RELSRC, src)));
|
(0 == strcmp(RELSRC, src)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
@ -219,11 +219,11 @@ TEST_F(Rename, ok)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *src = (const char*)in->body.bytes +
|
const char *src = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_rename_in);
|
sizeof(fuse_rename_in);
|
||||||
const char *dst = src + strlen(src) + 1;
|
const char *dst = src + strlen(src) + 1;
|
||||||
return (in->header.opcode == FUSE_RENAME &&
|
return (in.header.opcode == FUSE_RENAME &&
|
||||||
in->body.rename.newdir == dst_dir_ino &&
|
in.body.rename.newdir == dst_dir_ino &&
|
||||||
(0 == strcmp(RELDST, dst)) &&
|
(0 == strcmp(RELDST, dst)) &&
|
||||||
(0 == strcmp(RELSRC, src)));
|
(0 == strcmp(RELSRC, src)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
@ -250,24 +250,24 @@ TEST_F(Rename, parent)
|
|||||||
expect_lookup(RELSRC, ino, S_IFDIR | 0755, 0, 1);
|
expect_lookup(RELSRC, ino, S_IFDIR | 0755, 0, 1);
|
||||||
expect_getattr(1, S_IFDIR | 0755);
|
expect_getattr(1, S_IFDIR | 0755);
|
||||||
EXPECT_LOOKUP(1, RELDSTDIR)
|
EXPECT_LOOKUP(1, RELDSTDIR)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.nodeid = dst_dir_ino;
|
out.body.entry.nodeid = dst_dir_ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.mode = S_IFDIR | 0755;
|
out.body.entry.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.entry.attr.ino = dst_dir_ino;
|
out.body.entry.attr.ino = dst_dir_ino;
|
||||||
})));
|
})));
|
||||||
EXPECT_LOOKUP(dst_dir_ino, RELDST)
|
EXPECT_LOOKUP(dst_dir_ino, RELDST)
|
||||||
.InSequence(seq)
|
.InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnErrno(ENOENT)));
|
.WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *src = (const char*)in->body.bytes +
|
const char *src = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_rename_in);
|
sizeof(fuse_rename_in);
|
||||||
const char *dst = src + strlen(src) + 1;
|
const char *dst = src + strlen(src) + 1;
|
||||||
return (in->header.opcode == FUSE_RENAME &&
|
return (in.header.opcode == FUSE_RENAME &&
|
||||||
in->body.rename.newdir == dst_dir_ino &&
|
in.body.rename.newdir == dst_dir_ino &&
|
||||||
(0 == strcmp(RELDST, dst)) &&
|
(0 == strcmp(RELDST, dst)) &&
|
||||||
(0 == strcmp(RELSRC, src)));
|
(0 == strcmp(RELSRC, src)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
@ -275,12 +275,12 @@ TEST_F(Rename, parent)
|
|||||||
).WillOnce(Invoke(ReturnErrno(0)));
|
).WillOnce(Invoke(ReturnErrno(0)));
|
||||||
EXPECT_LOOKUP(dst_dir_ino, RELDST)
|
EXPECT_LOOKUP(dst_dir_ino, RELDST)
|
||||||
.InSequence(seq)
|
.InSequence(seq)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFDIR | 0755;
|
out.body.entry.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(0, rename(FULLSRC, FULLDST)) << strerror(errno);
|
ASSERT_EQ(0, rename(FULLSRC, FULLDST)) << strerror(errno);
|
||||||
@ -306,11 +306,11 @@ TEST_F(Rename, overwrite)
|
|||||||
expect_lookup(RELDST, dst_ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELDST, dst_ino, S_IFREG | 0644, 0, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *src = (const char*)in->body.bytes +
|
const char *src = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_rename_in);
|
sizeof(fuse_rename_in);
|
||||||
const char *dst = src + strlen(src) + 1;
|
const char *dst = src + strlen(src) + 1;
|
||||||
return (in->header.opcode == FUSE_RENAME &&
|
return (in.header.opcode == FUSE_RENAME &&
|
||||||
in->body.rename.newdir == dst_dir_ino &&
|
in.body.rename.newdir == dst_dir_ino &&
|
||||||
(0 == strcmp(RELDST, dst)) &&
|
(0 == strcmp(RELDST, dst)) &&
|
||||||
(0 == strcmp(RELSRC, src)));
|
(0 == strcmp(RELSRC, src)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
|
@ -43,26 +43,26 @@ void expect_getattr(uint64_t ino, mode_t mode)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = mode;
|
out.body.attr.attr.mode = mode;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
void expect_lookup(const char *relpath, uint64_t ino)
|
void expect_lookup(const char *relpath, uint64_t ino)
|
||||||
{
|
{
|
||||||
EXPECT_LOOKUP(1, relpath)
|
EXPECT_LOOKUP(1, relpath)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFDIR | 0755;
|
out.body.entry.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 2;
|
out.body.entry.attr.nlink = 2;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +70,9 @@ void expect_rmdir(uint64_t parent, const char *relpath, int error)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_RMDIR &&
|
return (in.header.opcode == FUSE_RMDIR &&
|
||||||
0 == strcmp(relpath, in->body.rmdir) &&
|
0 == strcmp(relpath, in.body.rmdir) &&
|
||||||
in->header.nodeid == parent);
|
in.header.nodeid == parent);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(error)));
|
).WillOnce(Invoke(ReturnErrno(error)));
|
||||||
@ -92,16 +92,16 @@ TEST_F(Rmdir, clear_attr_cache)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == 1);
|
in.header.nodeid == 1);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(2)
|
).Times(2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFDIR | 0755;
|
out.body.attr.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
expect_lookup(RELPATH, ino);
|
expect_lookup(RELPATH, ino);
|
||||||
expect_rmdir(1, RELPATH, 0);
|
expect_rmdir(1, RELPATH, 0);
|
||||||
|
@ -71,28 +71,28 @@ TEST_F(Setattr, attr_cache)
|
|||||||
const mode_t newmode = 0644;
|
const mode_t newmode = 0644;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | newmode;
|
out.body.attr.attr.mode = S_IFREG | newmode;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR);
|
return (in.header.opcode == FUSE_GETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(0);
|
).Times(0);
|
||||||
@ -115,26 +115,26 @@ TEST_F(Setattr, chmod)
|
|||||||
const mode_t newmode = 0644;
|
const mode_t newmode = 0644;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | oldmode;
|
out.body.entry.attr.mode = S_IFREG | oldmode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
/* In protocol 7.23, ctime will be changed too */
|
/* In protocol 7.23, ctime will be changed too */
|
||||||
uint32_t valid = FATTR_MODE;
|
uint32_t valid = FATTR_MODE;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.mode == newmode);
|
in.body.setattr.mode == newmode);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | newmode;
|
out.body.attr.attr.mode = S_IFREG | newmode;
|
||||||
})));
|
})));
|
||||||
EXPECT_EQ(0, chmod(FULLPATH, newmode)) << strerror(errno);
|
EXPECT_EQ(0, chmod(FULLPATH, newmode)) << strerror(errno);
|
||||||
}
|
}
|
||||||
@ -155,40 +155,40 @@ TEST_F(Setattr, chmod_multiply_linked)
|
|||||||
const mode_t newmode = 0666;
|
const mode_t newmode = 0666;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH0)
|
EXPECT_LOOKUP(1, RELPATH0)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | oldmode;
|
out.body.entry.attr.mode = S_IFREG | oldmode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 2;
|
out.body.entry.attr.nlink = 2;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH1)
|
EXPECT_LOOKUP(1, RELPATH1)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | oldmode;
|
out.body.entry.attr.mode = S_IFREG | oldmode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 2;
|
out.body.entry.attr.nlink = 2;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
uint32_t valid = FATTR_MODE;
|
uint32_t valid = FATTR_MODE;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.mode == newmode);
|
in.body.setattr.mode == newmode);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino;
|
out.body.attr.attr.ino = ino;
|
||||||
out->body.attr.attr.mode = S_IFREG | newmode;
|
out.body.attr.attr.mode = S_IFREG | newmode;
|
||||||
out->body.attr.attr.nlink = 2;
|
out.body.attr.attr.nlink = 2;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
/* For a lookup of the 2nd file to get it into the cache*/
|
/* For a lookup of the 2nd file to get it into the cache*/
|
||||||
@ -215,31 +215,31 @@ TEST_F(Setattr, chown)
|
|||||||
const uid_t newuser = 44;
|
const uid_t newuser = 44;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.gid = oldgroup;
|
out.body.entry.attr.gid = oldgroup;
|
||||||
out->body.entry.attr.uid = olduser;
|
out.body.entry.attr.uid = olduser;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
/* In protocol 7.23, ctime will be changed too */
|
/* In protocol 7.23, ctime will be changed too */
|
||||||
uint32_t valid = FATTR_GID | FATTR_UID;
|
uint32_t valid = FATTR_GID | FATTR_UID;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.uid == newuser &&
|
in.body.setattr.uid == newuser &&
|
||||||
in->body.setattr.gid == newgroup);
|
in.body.setattr.gid == newgroup);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
out->body.attr.attr.uid = newuser;
|
out.body.attr.attr.uid = newuser;
|
||||||
out->body.attr.attr.gid = newgroup;
|
out.body.attr.attr.gid = newgroup;
|
||||||
})));
|
})));
|
||||||
EXPECT_EQ(0, chown(FULLPATH, newuser, newgroup)) << strerror(errno);
|
EXPECT_EQ(0, chown(FULLPATH, newuser, newgroup)) << strerror(errno);
|
||||||
}
|
}
|
||||||
@ -258,18 +258,18 @@ TEST_F(Setattr, eperm)
|
|||||||
const uint64_t ino = 42;
|
const uint64_t ino = 42;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0777;
|
out.body.entry.attr.mode = S_IFREG | 0777;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.uid = in->header.uid;
|
out.body.entry.attr.uid = in.header.uid;
|
||||||
out->body.entry.attr.gid = in->header.gid;
|
out.body.entry.attr.gid = in.header.gid;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(EPERM)));
|
).WillOnce(Invoke(ReturnErrno(EPERM)));
|
||||||
@ -288,21 +288,21 @@ TEST_F(Setattr, fchmod)
|
|||||||
const mode_t newmode = 0644;
|
const mode_t newmode = 0644;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | oldmode;
|
out.body.entry.attr.mode = S_IFREG | oldmode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
@ -310,16 +310,16 @@ TEST_F(Setattr, fchmod)
|
|||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
/* In protocol 7.23, ctime will be changed too */
|
/* In protocol 7.23, ctime will be changed too */
|
||||||
uint32_t valid = FATTR_MODE;
|
uint32_t valid = FATTR_MODE;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.mode == newmode);
|
in.body.setattr.mode == newmode);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | newmode;
|
out.body.attr.attr.mode = S_IFREG | newmode;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_RDONLY);
|
fd = open(FULLPATH, O_RDONLY);
|
||||||
@ -340,41 +340,41 @@ TEST_F(Setattr, ftruncate)
|
|||||||
const off_t newsize = 12345;
|
const off_t newsize = 12345;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0755;
|
out.body.entry.attr.mode = S_IFREG | 0755;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.size = oldsize;
|
out.body.entry.attr.size = oldsize;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
out->body.open.fh = fh;
|
out.body.open.fh = fh;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
/* In protocol 7.23, ctime will be changed too */
|
/* In protocol 7.23, ctime will be changed too */
|
||||||
uint32_t valid = FATTR_SIZE | FATTR_FH;
|
uint32_t valid = FATTR_SIZE | FATTR_FH;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.fh == fh);
|
in.body.setattr.fh == fh);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0755;
|
out.body.attr.attr.mode = S_IFREG | 0755;
|
||||||
out->body.attr.attr.size = newsize;
|
out.body.attr.attr.size = newsize;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_RDWR);
|
fd = open(FULLPATH, O_RDWR);
|
||||||
@ -392,28 +392,28 @@ TEST_F(Setattr, truncate) {
|
|||||||
const uint64_t newsize = 20'000'000;
|
const uint64_t newsize = 20'000'000;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.size = oldsize;
|
out.body.entry.attr.size = oldsize;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
/* In protocol 7.23, ctime will be changed too */
|
/* In protocol 7.23, ctime will be changed too */
|
||||||
uint32_t valid = FATTR_SIZE;
|
uint32_t valid = FATTR_SIZE;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.size == newsize);
|
in.body.setattr.size == newsize);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
out->body.attr.attr.size = newsize;
|
out.body.attr.attr.size = newsize;
|
||||||
})));
|
})));
|
||||||
EXPECT_EQ(0, truncate(FULLPATH, newsize)) << strerror(errno);
|
EXPECT_EQ(0, truncate(FULLPATH, newsize)) << strerror(errno);
|
||||||
}
|
}
|
||||||
@ -471,15 +471,15 @@ TEST_F(Setattr, truncate_discards_cached_data) {
|
|||||||
expect_open(ino, O_RDWR, 1);
|
expect_open(ino, O_RDWR, 1);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([&](auto i __unused, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([&](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino;
|
out.body.attr.attr.ino = ino;
|
||||||
out->body.attr.attr.mode = mode;
|
out.body.attr.attr.mode = mode;
|
||||||
out->body.attr.attr.size = cur_size;
|
out.body.attr.attr.size = cur_size;
|
||||||
})));
|
})));
|
||||||
/*
|
/*
|
||||||
* The exact pattern of FUSE_WRITE operations depends on the setting of
|
* The exact pattern of FUSE_WRITE operations depends on the setting of
|
||||||
@ -488,64 +488,68 @@ TEST_F(Setattr, truncate_discards_cached_data) {
|
|||||||
*/
|
*/
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_WRITE);
|
return (in.header.opcode == FUSE_WRITE);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, write);
|
SET_OUT_HEADER_LEN(out, write);
|
||||||
out->body.attr.attr.ino = ino;
|
out.body.attr.attr.ino = ino;
|
||||||
out->body.write.size = in->body.write.size;
|
out.body.write.size = in.body.write.size;
|
||||||
cur_size = std::max((uint64_t)cur_size,
|
cur_size = std::max(static_cast<uint64_t>(cur_size),
|
||||||
in->body.write.size + in->body.write.offset);
|
in.body.write.size + in.body.write.offset);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
(in->body.setattr.valid & FATTR_SIZE));
|
(in.body.setattr.valid & FATTR_SIZE));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto& out) {
|
||||||
auto trunc_size = in->body.setattr.size;
|
auto trunc_size = in.body.setattr.size;
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino;
|
out.body.attr.attr.ino = ino;
|
||||||
out->body.attr.attr.mode = mode;
|
out.body.attr.attr.mode = mode;
|
||||||
out->body.attr.attr.size = trunc_size;
|
out.body.attr.attr.size = trunc_size;
|
||||||
cur_size = trunc_size;
|
cur_size = trunc_size;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
/* exact pattern of FUSE_READ depends on vfs.fusefs.data_cache_mode */
|
/* exact pattern of FUSE_READ depends on vfs.fusefs.data_cache_mode */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ);
|
return (in.header.opcode == FUSE_READ);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto& out) {
|
||||||
auto osize = std::min((uint64_t)cur_size - in->body.read.offset,
|
auto osize = std::min(
|
||||||
(uint64_t)in->body.read.size);
|
static_cast<uint64_t>(cur_size) - in.body.read.offset,
|
||||||
out->header.len = sizeof(struct fuse_out_header) + osize;
|
static_cast<uint64_t>(in.body.read.size));
|
||||||
|
out.header.len = sizeof(struct fuse_out_header) + osize;
|
||||||
if (should_have_data)
|
if (should_have_data)
|
||||||
memset(out->body.bytes, 'X', osize);
|
memset(out.body.bytes, 'X', osize);
|
||||||
else
|
else
|
||||||
bzero(out->body.bytes, osize);
|
bzero(out.body.bytes, osize);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
fd = open(FULLPATH, O_RDWR, 0644);
|
fd = open(FULLPATH, O_RDWR, 0644);
|
||||||
ASSERT_LE(0, fd) << strerror(errno);
|
ASSERT_LE(0, fd) << strerror(errno);
|
||||||
|
|
||||||
/* Fill the file with Xs */
|
/* Fill the file with Xs */
|
||||||
ASSERT_EQ((ssize_t)w0_size, pwrite(fd, w0buf, w0_size, w0_offset));
|
ASSERT_EQ(static_cast<ssize_t>(w0_size),
|
||||||
|
pwrite(fd, w0buf, w0_size, w0_offset));
|
||||||
should_have_data = true;
|
should_have_data = true;
|
||||||
/* Fill the cache, if data_cache_mode == 1 */
|
/* Fill the cache, if data_cache_mode == 1 */
|
||||||
ASSERT_EQ((ssize_t)r0_size, pread(fd, r0buf, r0_size, r0_offset));
|
ASSERT_EQ(static_cast<ssize_t>(r0_size),
|
||||||
|
pread(fd, r0buf, r0_size, r0_offset));
|
||||||
/* 1st truncate should discard cached data */
|
/* 1st truncate should discard cached data */
|
||||||
EXPECT_EQ(0, ftruncate(fd, trunc0_size)) << strerror(errno);
|
EXPECT_EQ(0, ftruncate(fd, trunc0_size)) << strerror(errno);
|
||||||
should_have_data = false;
|
should_have_data = false;
|
||||||
/* 2nd truncate extends file into previously cached data */
|
/* 2nd truncate extends file into previously cached data */
|
||||||
EXPECT_EQ(0, ftruncate(fd, trunc1_size)) << strerror(errno);
|
EXPECT_EQ(0, ftruncate(fd, trunc1_size)) << strerror(errno);
|
||||||
/* Read should return all zeros */
|
/* Read should return all zeros */
|
||||||
ASSERT_EQ((ssize_t)r1_size, pread(fd, r1buf, r1_size, r1_offset));
|
ASSERT_EQ(static_cast<ssize_t>(r1_size),
|
||||||
|
pread(fd, r1buf, r1_size, r1_offset));
|
||||||
|
|
||||||
r = memcmp(expected, r1buf, r1_size);
|
r = memcmp(expected, r1buf, r1_size);
|
||||||
ASSERT_EQ(0, r);
|
ASSERT_EQ(0, r);
|
||||||
@ -571,40 +575,40 @@ TEST_F(Setattr, utimensat) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.atime = oldtimes[0].tv_sec;
|
out.body.entry.attr.atime = oldtimes[0].tv_sec;
|
||||||
out->body.entry.attr.atimensec = oldtimes[0].tv_nsec;
|
out.body.entry.attr.atimensec = oldtimes[0].tv_nsec;
|
||||||
out->body.entry.attr.mtime = oldtimes[1].tv_sec;
|
out.body.entry.attr.mtime = oldtimes[1].tv_sec;
|
||||||
out->body.entry.attr.mtimensec = oldtimes[1].tv_nsec;
|
out.body.entry.attr.mtimensec = oldtimes[1].tv_nsec;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
/* In protocol 7.23, ctime will be changed too */
|
/* In protocol 7.23, ctime will be changed too */
|
||||||
uint32_t valid = FATTR_ATIME | FATTR_MTIME;
|
uint32_t valid = FATTR_ATIME | FATTR_MTIME;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.atime == newtimes[0].tv_sec &&
|
in.body.setattr.atime == newtimes[0].tv_sec &&
|
||||||
in->body.setattr.atimensec ==
|
in.body.setattr.atimensec ==
|
||||||
newtimes[0].tv_nsec &&
|
newtimes[0].tv_nsec &&
|
||||||
in->body.setattr.mtime == newtimes[1].tv_sec &&
|
in.body.setattr.mtime == newtimes[1].tv_sec &&
|
||||||
in->body.setattr.mtimensec ==
|
in.body.setattr.mtimensec ==
|
||||||
newtimes[1].tv_nsec);
|
newtimes[1].tv_nsec);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
out->body.attr.attr.atime = newtimes[0].tv_sec;
|
out.body.attr.attr.atime = newtimes[0].tv_sec;
|
||||||
out->body.attr.attr.atimensec = newtimes[0].tv_nsec;
|
out.body.attr.attr.atimensec = newtimes[0].tv_nsec;
|
||||||
out->body.attr.attr.mtime = newtimes[1].tv_sec;
|
out.body.attr.attr.mtime = newtimes[1].tv_sec;
|
||||||
out->body.attr.attr.mtimensec = newtimes[1].tv_nsec;
|
out.body.attr.attr.mtimensec = newtimes[1].tv_nsec;
|
||||||
})));
|
})));
|
||||||
EXPECT_EQ(0, utimensat(AT_FDCWD, FULLPATH, &newtimes[0], 0))
|
EXPECT_EQ(0, utimensat(AT_FDCWD, FULLPATH, &newtimes[0], 0))
|
||||||
<< strerror(errno);
|
<< strerror(errno);
|
||||||
@ -625,37 +629,37 @@ TEST_F(Setattr, utimensat_mtime_only) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.atime = oldtimes[0].tv_sec;
|
out.body.entry.attr.atime = oldtimes[0].tv_sec;
|
||||||
out->body.entry.attr.atimensec = oldtimes[0].tv_nsec;
|
out.body.entry.attr.atimensec = oldtimes[0].tv_nsec;
|
||||||
out->body.entry.attr.mtime = oldtimes[1].tv_sec;
|
out.body.entry.attr.mtime = oldtimes[1].tv_sec;
|
||||||
out->body.entry.attr.mtimensec = oldtimes[1].tv_nsec;
|
out.body.entry.attr.mtimensec = oldtimes[1].tv_nsec;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
/* In protocol 7.23, ctime will be changed too */
|
/* In protocol 7.23, ctime will be changed too */
|
||||||
uint32_t valid = FATTR_MTIME;
|
uint32_t valid = FATTR_MTIME;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.mtime == newtimes[1].tv_sec &&
|
in.body.setattr.mtime == newtimes[1].tv_sec &&
|
||||||
in->body.setattr.mtimensec ==
|
in.body.setattr.mtimensec ==
|
||||||
newtimes[1].tv_nsec);
|
newtimes[1].tv_nsec);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
out->body.attr.attr.atime = oldtimes[0].tv_sec;
|
out.body.attr.attr.atime = oldtimes[0].tv_sec;
|
||||||
out->body.attr.attr.atimensec = oldtimes[0].tv_nsec;
|
out.body.attr.attr.atimensec = oldtimes[0].tv_nsec;
|
||||||
out->body.attr.attr.mtime = newtimes[1].tv_sec;
|
out.body.attr.attr.mtime = newtimes[1].tv_sec;
|
||||||
out->body.attr.attr.mtimensec = newtimes[1].tv_nsec;
|
out.body.attr.attr.mtimensec = newtimes[1].tv_nsec;
|
||||||
})));
|
})));
|
||||||
EXPECT_EQ(0, utimensat(AT_FDCWD, FULLPATH, &newtimes[0], 0))
|
EXPECT_EQ(0, utimensat(AT_FDCWD, FULLPATH, &newtimes[0], 0))
|
||||||
<< strerror(errno);
|
<< strerror(errno);
|
||||||
@ -687,16 +691,16 @@ TEST_F(Setattr, utimensat_utime_now) {
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | 0644;
|
out.body.entry.attr.mode = S_IFREG | 0644;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr.atime = oldtimes[0].tv_sec;
|
out.body.entry.attr.atime = oldtimes[0].tv_sec;
|
||||||
out->body.entry.attr.atimensec = oldtimes[0].tv_nsec;
|
out.body.entry.attr.atimensec = oldtimes[0].tv_nsec;
|
||||||
out->body.entry.attr.mtime = oldtimes[1].tv_sec;
|
out.body.entry.attr.mtime = oldtimes[1].tv_sec;
|
||||||
out->body.entry.attr.mtimensec = oldtimes[1].tv_nsec;
|
out.body.entry.attr.mtimensec = oldtimes[1].tv_nsec;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
@ -704,20 +708,20 @@ TEST_F(Setattr, utimensat_utime_now) {
|
|||||||
/* In protocol 7.23, ctime will be changed too */
|
/* In protocol 7.23, ctime will be changed too */
|
||||||
uint32_t valid = FATTR_ATIME | FATTR_ATIME_NOW |
|
uint32_t valid = FATTR_ATIME | FATTR_ATIME_NOW |
|
||||||
FATTR_MTIME | FATTR_MTIME_NOW;
|
FATTR_MTIME | FATTR_MTIME_NOW;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid);
|
in.body.setattr.valid == valid);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
out->body.attr.attr.atime = now[0].tv_sec;
|
out.body.attr.attr.atime = now[0].tv_sec;
|
||||||
out->body.attr.attr.atimensec = now[0].tv_nsec;
|
out.body.attr.attr.atimensec = now[0].tv_nsec;
|
||||||
out->body.attr.attr.mtime = now[1].tv_sec;
|
out.body.attr.attr.mtime = now[1].tv_sec;
|
||||||
out->body.attr.attr.mtimensec = now[1].tv_nsec;
|
out.body.attr.attr.mtimensec = now[1].tv_nsec;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
ASSERT_EQ(0, utimensat(AT_FDCWD, FULLPATH, &newtimes[0], 0))
|
ASSERT_EQ(0, utimensat(AT_FDCWD, FULLPATH, &newtimes[0], 0))
|
||||||
<< strerror(errno);
|
<< strerror(errno);
|
||||||
@ -738,10 +742,10 @@ TEST_F(RofsSetattr, erofs)
|
|||||||
const mode_t newmode = 0644;
|
const mode_t newmode = 0644;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFREG | oldmode;
|
out.body.entry.attr.mode = S_IFREG | oldmode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_EQ(-1, chmod(FULLPATH, newmode));
|
ASSERT_EQ(-1, chmod(FULLPATH, newmode));
|
||||||
@ -758,26 +762,26 @@ TEST_F(Setattr_7_8, chmod)
|
|||||||
const mode_t newmode = 0644;
|
const mode_t newmode = 0644;
|
||||||
|
|
||||||
EXPECT_LOOKUP(1, RELPATH)
|
EXPECT_LOOKUP(1, RELPATH)
|
||||||
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry_7_8);
|
SET_OUT_HEADER_LEN(out, entry_7_8);
|
||||||
out->body.entry.attr.mode = S_IFREG | oldmode;
|
out.body.entry.attr.mode = S_IFREG | oldmode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
/* In protocol 7.23, ctime will be changed too */
|
/* In protocol 7.23, ctime will be changed too */
|
||||||
uint32_t valid = FATTR_MODE;
|
uint32_t valid = FATTR_MODE;
|
||||||
return (in->header.opcode == FUSE_SETATTR &&
|
return (in.header.opcode == FUSE_SETATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.setattr.valid == valid &&
|
in.body.setattr.valid == valid &&
|
||||||
in->body.setattr.mode == newmode);
|
in.body.setattr.mode == newmode);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr_7_8);
|
SET_OUT_HEADER_LEN(out, attr_7_8);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | newmode;
|
out.body.attr.attr.mode = S_IFREG | newmode;
|
||||||
})));
|
})));
|
||||||
EXPECT_EQ(0, chmod(FULLPATH, newmode)) << strerror(errno);
|
EXPECT_EQ(0, chmod(FULLPATH, newmode)) << strerror(errno);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ TEST_F(Statfs, eio)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_STATFS);
|
return (in.header.opcode == FUSE_STATFS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(EIO)));
|
).WillOnce(Invoke(ReturnErrno(EIO)));
|
||||||
@ -104,7 +104,7 @@ TEST_F(Statfs, enotconn_while_blocked)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_STATFS);
|
return (in.header.opcode == FUSE_STATFS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
).WillOnce(Invoke([&](auto in __unused, auto &out __unused) {
|
||||||
@ -136,18 +136,18 @@ TEST_F(Statfs, ok)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_STATFS);
|
return (in.header.opcode == FUSE_STATFS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, statfs);
|
SET_OUT_HEADER_LEN(out, statfs);
|
||||||
out->body.statfs.st.blocks = 1000;
|
out.body.statfs.st.blocks = 1000;
|
||||||
out->body.statfs.st.bfree = 100;
|
out.body.statfs.st.bfree = 100;
|
||||||
out->body.statfs.st.bavail = 200;
|
out.body.statfs.st.bavail = 200;
|
||||||
out->body.statfs.st.files = 5;
|
out.body.statfs.st.files = 5;
|
||||||
out->body.statfs.st.ffree = 6;
|
out.body.statfs.st.ffree = 6;
|
||||||
out->body.statfs.st.namelen = 128;
|
out.body.statfs.st.namelen = 128;
|
||||||
out->body.statfs.st.frsize = 1024;
|
out.body.statfs.st.frsize = 1024;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
ASSERT_NE(NULL, getcwd(mp, PATH_MAX)) << strerror(errno);
|
ASSERT_NE(NULL, getcwd(mp, PATH_MAX)) << strerror(errno);
|
||||||
|
@ -44,19 +44,19 @@ void expect_symlink(uint64_t ino, const char *target, const char *relpath)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes;
|
const char *name = (const char*)in.body.bytes;
|
||||||
const char *linkname = name + strlen(name) + 1;
|
const char *linkname = name + strlen(name) + 1;
|
||||||
return (in->header.opcode == FUSE_SYMLINK &&
|
return (in.header.opcode == FUSE_SYMLINK &&
|
||||||
(0 == strcmp(linkname, target)) &&
|
(0 == strcmp(linkname, target)) &&
|
||||||
(0 == strcmp(name, relpath)));
|
(0 == strcmp(name, relpath)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = S_IFLNK | 0777;
|
out.body.entry.attr.mode = S_IFLNK | 0777;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,19 +73,19 @@ void expect_symlink(uint64_t ino, const char *target, const char *relpath)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes;
|
const char *name = (const char*)in.body.bytes;
|
||||||
const char *linkname = name + strlen(name) + 1;
|
const char *linkname = name + strlen(name) + 1;
|
||||||
return (in->header.opcode == FUSE_SYMLINK &&
|
return (in.header.opcode == FUSE_SYMLINK &&
|
||||||
(0 == strcmp(linkname, target)) &&
|
(0 == strcmp(linkname, target)) &&
|
||||||
(0 == strcmp(name, relpath)));
|
(0 == strcmp(name, relpath)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry_7_8);
|
SET_OUT_HEADER_LEN(out, entry_7_8);
|
||||||
out->body.entry.attr.mode = S_IFLNK | 0777;
|
out.body.entry.attr.mode = S_IFLNK | 0777;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.entry_valid = UINT64_MAX;
|
out.body.entry.entry_valid = UINT64_MAX;
|
||||||
out->body.entry.attr_valid = UINT64_MAX;
|
out.body.entry.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,16 +106,16 @@ TEST_F(Symlink, clear_attr_cache)
|
|||||||
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
EXPECT_LOOKUP(1, RELPATH).WillOnce(Invoke(ReturnErrno(ENOENT)));
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == 1);
|
in.header.nodeid == 1);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(2)
|
).Times(2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = 1;
|
out.body.attr.attr.ino = 1;
|
||||||
out->body.attr.attr.mode = S_IFDIR | 0755;
|
out.body.attr.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
expect_symlink(ino, dst, RELPATH);
|
expect_symlink(ino, dst, RELPATH);
|
||||||
|
|
||||||
@ -134,9 +134,9 @@ TEST_F(Symlink, enospc)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *name = (const char*)in->body.bytes;
|
const char *name = (const char*)in.body.bytes;
|
||||||
const char *linkname = name + strlen(name) + 1;
|
const char *linkname = name + strlen(name) + 1;
|
||||||
return (in->header.opcode == FUSE_SYMLINK &&
|
return (in.header.opcode == FUSE_SYMLINK &&
|
||||||
(0 == strcmp(linkname, dst)) &&
|
(0 == strcmp(linkname, dst)) &&
|
||||||
(0 == strcmp(name, RELPATH)));
|
(0 == strcmp(name, RELPATH)));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
|
@ -42,15 +42,15 @@ void expect_getattr(uint64_t ino, mode_t mode)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = mode;
|
out.body.attr.attr.mode = mode;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,16 +74,16 @@ TEST_F(Unlink, clear_attr_cache)
|
|||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == 1);
|
in.header.nodeid == 1);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(2)
|
).Times(2)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFDIR | 0755;
|
out.body.attr.attr.mode = S_IFDIR | 0755;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
expect_lookup(RELPATH, ino, 1);
|
expect_lookup(RELPATH, ino, 1);
|
||||||
expect_unlink(1, RELPATH, 0);
|
expect_unlink(1, RELPATH, 0);
|
||||||
|
@ -108,7 +108,7 @@ void FuseTest::SetUp() {
|
|||||||
*/
|
*/
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_ACCESS);
|
return (in.header.opcode == FUSE_ACCESS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(AnyNumber())
|
).Times(AnyNumber())
|
||||||
@ -123,9 +123,9 @@ FuseTest::expect_access(uint64_t ino, mode_t access_mode, int error)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_ACCESS &&
|
return (in.header.opcode == FUSE_ACCESS &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.access.mask == access_mode);
|
in.body.access.mask == access_mode);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(error)));
|
).WillOnce(Invoke(ReturnErrno(error)));
|
||||||
@ -136,14 +136,14 @@ FuseTest::expect_destroy(int error)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_DESTROY);
|
return (in.header.opcode == FUSE_DESTROY);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke( ReturnImmediate([&](auto in, auto out) {
|
).WillOnce(Invoke( ReturnImmediate([&](auto in, auto& out) {
|
||||||
m_mock->m_quit = true;
|
m_mock->m_quit = true;
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
out->header.unique = in->header.unique;
|
out.header.unique = in.header.unique;
|
||||||
out->header.error = -error;
|
out.header.error = -error;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +152,8 @@ FuseTest::expect_flush(uint64_t ino, int times, ProcessMockerT r)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_FLUSH &&
|
return (in.header.opcode == FUSE_FLUSH &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(times)
|
).Times(times)
|
||||||
@ -165,9 +165,9 @@ FuseTest::expect_forget(uint64_t ino, uint64_t nlookup)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_FORGET &&
|
return (in.header.opcode == FUSE_FORGET &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.forget.nlookup == nlookup);
|
in.body.forget.nlookup == nlookup);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke([](auto in __unused, auto &out __unused) {
|
).WillOnce(Invoke([](auto in __unused, auto &out __unused) {
|
||||||
@ -179,16 +179,16 @@ void FuseTest::expect_getattr(uint64_t ino, uint64_t size)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_GETATTR &&
|
return (in.header.opcode == FUSE_GETATTR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
out->body.attr.attr.mode = S_IFREG | 0644;
|
out.body.attr.attr.mode = S_IFREG | 0644;
|
||||||
out->body.attr.attr.size = size;
|
out.body.attr.attr.size = size;
|
||||||
out->body.attr.attr_valid = UINT64_MAX;
|
out.body.attr.attr_valid = UINT64_MAX;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,15 +197,16 @@ void FuseTest::expect_lookup(const char *relpath, uint64_t ino, mode_t mode,
|
|||||||
{
|
{
|
||||||
EXPECT_LOOKUP(1, relpath)
|
EXPECT_LOOKUP(1, relpath)
|
||||||
.Times(times)
|
.Times(times)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(
|
||||||
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry);
|
SET_OUT_HEADER_LEN(out, entry);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr_valid = attr_valid;
|
out.body.entry.attr_valid = attr_valid;
|
||||||
out->body.entry.attr.size = size;
|
out.body.entry.attr.size = size;
|
||||||
out->body.entry.attr.uid = uid;
|
out.body.entry.attr.uid = uid;
|
||||||
out->body.entry.attr.gid = gid;
|
out.body.entry.attr.gid = gid;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,15 +215,16 @@ void FuseTest::expect_lookup_7_8(const char *relpath, uint64_t ino, mode_t mode,
|
|||||||
{
|
{
|
||||||
EXPECT_LOOKUP(1, relpath)
|
EXPECT_LOOKUP(1, relpath)
|
||||||
.Times(times)
|
.Times(times)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(
|
||||||
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, entry_7_8);
|
SET_OUT_HEADER_LEN(out, entry_7_8);
|
||||||
out->body.entry.attr.mode = mode;
|
out.body.entry.attr.mode = mode;
|
||||||
out->body.entry.nodeid = ino;
|
out.body.entry.nodeid = ino;
|
||||||
out->body.entry.attr.nlink = 1;
|
out.body.entry.attr.nlink = 1;
|
||||||
out->body.entry.attr_valid = attr_valid;
|
out.body.entry.attr_valid = attr_valid;
|
||||||
out->body.entry.attr.size = size;
|
out.body.entry.attr.size = size;
|
||||||
out->body.entry.attr.uid = uid;
|
out.body.entry.attr.uid = uid;
|
||||||
out->body.entry.attr.gid = gid;
|
out.body.entry.attr.gid = gid;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,16 +232,17 @@ void FuseTest::expect_open(uint64_t ino, uint32_t flags, int times)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPEN &&
|
return (in.header.opcode == FUSE_OPEN &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).Times(times)
|
).Times(times)
|
||||||
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
.WillRepeatedly(Invoke(
|
||||||
out->header.len = sizeof(out->header);
|
ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
|
out.header.len = sizeof(out.header);
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
out->body.open.fh = FH;
|
out.body.open.fh = FH;
|
||||||
out->body.open.open_flags = flags;
|
out.body.open.open_flags = flags;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,23 +251,24 @@ void FuseTest::expect_opendir(uint64_t ino)
|
|||||||
/* opendir(3) calls fstatfs */
|
/* opendir(3) calls fstatfs */
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([](auto in) {
|
ResultOf([](auto in) {
|
||||||
return (in->header.opcode == FUSE_STATFS);
|
return (in.header.opcode == FUSE_STATFS);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
).WillRepeatedly(Invoke(
|
||||||
|
ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, statfs);
|
SET_OUT_HEADER_LEN(out, statfs);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_OPENDIR &&
|
return (in.header.opcode == FUSE_OPENDIR &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.len = sizeof(out->header);
|
out.header.len = sizeof(out.header);
|
||||||
SET_OUT_HEADER_LEN(out, open);
|
SET_OUT_HEADER_LEN(out, open);
|
||||||
out->body.open.fh = FH;
|
out.body.open.fh = FH;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,16 +277,16 @@ void FuseTest::expect_read(uint64_t ino, uint64_t offset, uint64_t isize,
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READ &&
|
return (in.header.opcode == FUSE_READ &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.read.fh == FH &&
|
in.body.read.fh == FH &&
|
||||||
in->body.read.offset == offset &&
|
in.body.read.offset == offset &&
|
||||||
in->body.read.size == isize);
|
in.body.read.size == isize);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
out->header.len = sizeof(struct fuse_out_header) + osize;
|
out.header.len = sizeof(struct fuse_out_header) + osize;
|
||||||
memmove(out->body.bytes, contents, osize);
|
memmove(out.body.bytes, contents, osize);
|
||||||
}))).RetiresOnSaturation();
|
}))).RetiresOnSaturation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,18 +295,18 @@ void FuseTest::expect_readdir(uint64_t ino, uint64_t off,
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_READDIR &&
|
return (in.header.opcode == FUSE_READDIR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.readdir.fh == FH &&
|
in.body.readdir.fh == FH &&
|
||||||
in->body.readdir.offset == off);
|
in.body.readdir.offset == off);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in, auto& out) {
|
||||||
struct fuse_dirent *fde = (struct fuse_dirent*)&(out->body);
|
struct fuse_dirent *fde = (struct fuse_dirent*)&(out.body);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
out->header.error = 0;
|
out.header.error = 0;
|
||||||
out->header.len = 0;
|
out.header.len = 0;
|
||||||
|
|
||||||
for (const auto& it: ents) {
|
for (const auto& it: ents) {
|
||||||
size_t entlen, entsize;
|
size_t entlen, entsize;
|
||||||
@ -322,17 +326,17 @@ void FuseTest::expect_readdir(uint64_t ino, uint64_t off,
|
|||||||
* kernel
|
* kernel
|
||||||
*/
|
*/
|
||||||
memset(fde->name + fde->namelen, 0, entsize - entlen);
|
memset(fde->name + fde->namelen, 0, entsize - entlen);
|
||||||
if (out->header.len + entsize > in->body.read.size) {
|
if (out.header.len + entsize > in.body.read.size) {
|
||||||
printf("Overflow in readdir expectation: i=%d\n"
|
printf("Overflow in readdir expectation: i=%d\n"
|
||||||
, i);
|
, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out->header.len += entsize;
|
out.header.len += entsize;
|
||||||
fde = (struct fuse_dirent*)
|
fde = (struct fuse_dirent*)
|
||||||
((long*)fde + entsize / sizeof(long));
|
((long*)fde + entsize / sizeof(long));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
out->header.len += sizeof(out->header);
|
out.header.len += sizeof(out.header);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -340,9 +344,9 @@ void FuseTest::expect_release(uint64_t ino, uint64_t fh)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_RELEASE &&
|
return (in.header.opcode == FUSE_RELEASE &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.release.fh == fh);
|
in.body.release.fh == fh);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(0)));
|
).WillOnce(Invoke(ReturnErrno(0)));
|
||||||
@ -352,9 +356,9 @@ void FuseTest::expect_releasedir(uint64_t ino, ProcessMockerT r)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_RELEASEDIR &&
|
return (in.header.opcode == FUSE_RELEASEDIR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.release.fh == FH);
|
in.body.release.fh == FH);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(r));
|
).WillOnce(Invoke(r));
|
||||||
@ -364,9 +368,9 @@ void FuseTest::expect_unlink(uint64_t parent, const char *path, int error)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_UNLINK &&
|
return (in.header.opcode == FUSE_UNLINK &&
|
||||||
0 == strcmp(path, in->body.unlink) &&
|
0 == strcmp(path, in.body.unlink) &&
|
||||||
in->header.nodeid == parent);
|
in.header.nodeid == parent);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnErrno(error)));
|
).WillOnce(Invoke(ReturnErrno(error)));
|
||||||
@ -377,28 +381,28 @@ void FuseTest::expect_write(uint64_t ino, uint64_t offset, uint64_t isize,
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *buf = (const char*)in->body.bytes +
|
const char *buf = (const char*)in.body.bytes +
|
||||||
sizeof(struct fuse_write_in);
|
sizeof(struct fuse_write_in);
|
||||||
bool pid_ok;
|
bool pid_ok;
|
||||||
|
|
||||||
if (in->body.write.write_flags & FUSE_WRITE_CACHE)
|
if (in.body.write.write_flags & FUSE_WRITE_CACHE)
|
||||||
pid_ok = true;
|
pid_ok = true;
|
||||||
else
|
else
|
||||||
pid_ok = (pid_t)in->header.pid == getpid();
|
pid_ok = (pid_t)in.header.pid == getpid();
|
||||||
|
|
||||||
return (in->header.opcode == FUSE_WRITE &&
|
return (in.header.opcode == FUSE_WRITE &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.write.fh == FH &&
|
in.body.write.fh == FH &&
|
||||||
in->body.write.offset == offset &&
|
in.body.write.offset == offset &&
|
||||||
in->body.write.size == isize &&
|
in.body.write.size == isize &&
|
||||||
pid_ok &&
|
pid_ok &&
|
||||||
in->body.write.write_flags == flags &&
|
in.body.write.write_flags == flags &&
|
||||||
0 == bcmp(buf, contents, isize));
|
0 == bcmp(buf, contents, isize));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, write);
|
SET_OUT_HEADER_LEN(out, write);
|
||||||
out->body.write.size = osize;
|
out.body.write.size = osize;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,22 +411,22 @@ void FuseTest::expect_write_7_8(uint64_t ino, uint64_t offset, uint64_t isize,
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *buf = (const char*)in->body.bytes +
|
const char *buf = (const char*)in.body.bytes +
|
||||||
FUSE_COMPAT_WRITE_IN_SIZE;
|
FUSE_COMPAT_WRITE_IN_SIZE;
|
||||||
bool pid_ok = (pid_t)in->header.pid == getpid();
|
bool pid_ok = (pid_t)in.header.pid == getpid();
|
||||||
return (in->header.opcode == FUSE_WRITE &&
|
return (in.header.opcode == FUSE_WRITE &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.write.fh == FH &&
|
in.body.write.fh == FH &&
|
||||||
in->body.write.offset == offset &&
|
in.body.write.offset == offset &&
|
||||||
in->body.write.size == isize &&
|
in.body.write.size == isize &&
|
||||||
pid_ok &&
|
pid_ok &&
|
||||||
in->body.write.write_flags == flags &&
|
in.body.write.write_flags == flags &&
|
||||||
0 == bcmp(buf, contents, isize));
|
0 == bcmp(buf, contents, isize));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) {
|
).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, write);
|
SET_OUT_HEADER_LEN(out, write);
|
||||||
out->body.write.size = osize;
|
out.body.write.size = osize;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@ void expect_release(uint64_t ino, ProcessMockerT r)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_RELEASE &&
|
return (in.header.opcode == FUSE_RELEASE &&
|
||||||
in->header.nodeid == ino);
|
in.header.nodeid == ino);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(r));
|
).WillRepeatedly(Invoke(r));
|
||||||
@ -585,12 +585,12 @@ TEST_F(WriteBack, close)
|
|||||||
expect_write(ino, 0, bufsize, bufsize, 0, CONTENTS);
|
expect_write(ino, 0, bufsize, bufsize, 0, CONTENTS);
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_SETATTR);
|
return (in.header.opcode == FUSE_SETATTR);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) {
|
).WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, attr);
|
SET_OUT_HEADER_LEN(out, attr);
|
||||||
out->body.attr.attr.ino = ino; // Must match nodeid
|
out.body.attr.attr.ino = ino; // Must match nodeid
|
||||||
})));
|
})));
|
||||||
expect_flush(ino, 1, ReturnErrno(0));
|
expect_flush(ino, 1, ReturnErrno(0));
|
||||||
expect_release(ino, ReturnErrno(0));
|
expect_release(ino, ReturnErrno(0));
|
||||||
|
@ -49,10 +49,10 @@ void expect_getxattr(uint64_t ino, const char *attr, ProcessMockerT r)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *a = (const char*)in->body.bytes +
|
const char *a = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_getxattr_in);
|
sizeof(fuse_getxattr_in);
|
||||||
return (in->header.opcode == FUSE_GETXATTR &&
|
return (in.header.opcode == FUSE_GETXATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
0 == strcmp(attr, a));
|
0 == strcmp(attr, a));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
@ -63,9 +63,9 @@ void expect_listxattr(uint64_t ino, uint32_t size, ProcessMockerT r)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
return (in->header.opcode == FUSE_LISTXATTR &&
|
return (in.header.opcode == FUSE_LISTXATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
in->body.listxattr.size == size);
|
in.body.listxattr.size == size);
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
).WillOnce(Invoke(r))
|
).WillOnce(Invoke(r))
|
||||||
@ -76,9 +76,9 @@ void expect_removexattr(uint64_t ino, const char *attr, int error)
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *a = (const char*)in->body.bytes;
|
const char *a = (const char*)in.body.bytes;
|
||||||
return (in->header.opcode == FUSE_REMOVEXATTR &&
|
return (in.header.opcode == FUSE_REMOVEXATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
0 == strcmp(attr, a));
|
0 == strcmp(attr, a));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
_)
|
_)
|
||||||
@ -90,11 +90,11 @@ void expect_setxattr(uint64_t ino, const char *attr, const char *value,
|
|||||||
{
|
{
|
||||||
EXPECT_CALL(*m_mock, process(
|
EXPECT_CALL(*m_mock, process(
|
||||||
ResultOf([=](auto in) {
|
ResultOf([=](auto in) {
|
||||||
const char *a = (const char*)in->body.bytes +
|
const char *a = (const char*)in.body.bytes +
|
||||||
sizeof(fuse_setxattr_in);
|
sizeof(fuse_setxattr_in);
|
||||||
const char *v = a + strlen(a) + 1;
|
const char *v = a + strlen(a) + 1;
|
||||||
return (in->header.opcode == FUSE_SETXATTR &&
|
return (in.header.opcode == FUSE_SETXATTR &&
|
||||||
in->header.nodeid == ino &&
|
in.header.nodeid == ino &&
|
||||||
0 == strcmp(attr, a) &&
|
0 == strcmp(attr, a) &&
|
||||||
0 == strcmp(value, v));
|
0 == strcmp(value, v));
|
||||||
}, Eq(true)),
|
}, Eq(true)),
|
||||||
@ -199,9 +199,9 @@ TEST_F(Getxattr, size_only)
|
|||||||
|
|
||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
expect_getxattr(ino, "user.foo",
|
expect_getxattr(ino, "user.foo",
|
||||||
ReturnImmediate([](auto in __unused, auto out) {
|
ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
SET_OUT_HEADER_LEN(out, getxattr);
|
SET_OUT_HEADER_LEN(out, getxattr);
|
||||||
out->body.getxattr.size = 99;
|
out.body.getxattr.size = 99;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -223,9 +223,9 @@ TEST_F(Getxattr, system)
|
|||||||
|
|
||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
expect_getxattr(ino, "system.foo",
|
expect_getxattr(ino, "system.foo",
|
||||||
ReturnImmediate([&](auto in __unused, auto out) {
|
ReturnImmediate([&](auto in __unused, auto& out) {
|
||||||
memcpy((void*)out->body.bytes, value, value_len);
|
memcpy((void*)out.body.bytes, value, value_len);
|
||||||
out->header.len = sizeof(out->header) + value_len;
|
out.header.len = sizeof(out.header) + value_len;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -248,9 +248,9 @@ TEST_F(Getxattr, user)
|
|||||||
|
|
||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
expect_getxattr(ino, "user.foo",
|
expect_getxattr(ino, "user.foo",
|
||||||
ReturnImmediate([&](auto in __unused, auto out) {
|
ReturnImmediate([&](auto in __unused, auto& out) {
|
||||||
memcpy((void*)out->body.bytes, value, value_len);
|
memcpy((void*)out.body.bytes, value, value_len);
|
||||||
out->header.len = sizeof(out->header) + value_len;
|
out.header.len = sizeof(out.header) + value_len;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -329,8 +329,8 @@ TEST_F(Listxattr, size_only_empty)
|
|||||||
int ns = EXTATTR_NAMESPACE_USER;
|
int ns = EXTATTR_NAMESPACE_USER;
|
||||||
|
|
||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
expect_listxattr(ino, 0, ReturnImmediate([](auto i __unused, auto out) {
|
expect_listxattr(ino, 0, ReturnImmediate([](auto i __unused, auto& out) {
|
||||||
out->body.listxattr.size = 0;
|
out.body.listxattr.size = 0;
|
||||||
SET_OUT_HEADER_LEN(out, listxattr);
|
SET_OUT_HEADER_LEN(out, listxattr);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -350,19 +350,19 @@ TEST_F(Listxattr, size_only_nonempty)
|
|||||||
int ns = EXTATTR_NAMESPACE_USER;
|
int ns = EXTATTR_NAMESPACE_USER;
|
||||||
|
|
||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
expect_listxattr(ino, 0, ReturnImmediate([](auto i __unused, auto out) {
|
expect_listxattr(ino, 0, ReturnImmediate([](auto i __unused, auto& out) {
|
||||||
out->body.listxattr.size = 45;
|
out.body.listxattr.size = 45;
|
||||||
SET_OUT_HEADER_LEN(out, listxattr);
|
SET_OUT_HEADER_LEN(out, listxattr);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO: fix the expected size after fixing the size calculation bug in
|
// TODO: fix the expected size after fixing the size calculation bug in
|
||||||
// fuse_vnop_listextattr. It should be exactly 45.
|
// fuse_vnop_listextattr. It should be exactly 45.
|
||||||
expect_listxattr(ino, 53,
|
expect_listxattr(ino, 53,
|
||||||
ReturnImmediate([](auto in __unused, auto out) {
|
ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
const char l[] = "user.foo";
|
const char l[] = "user.foo";
|
||||||
strlcpy((char*)out->body.bytes, l,
|
strlcpy((char*)out.body.bytes, l,
|
||||||
sizeof(out->body.bytes));
|
sizeof(out.body.bytes));
|
||||||
out->header.len = sizeof(fuse_out_header) + sizeof(l);
|
out.header.len = sizeof(fuse_out_header) + sizeof(l);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -376,20 +376,20 @@ TEST_F(Listxattr, size_only_really_big)
|
|||||||
int ns = EXTATTR_NAMESPACE_USER;
|
int ns = EXTATTR_NAMESPACE_USER;
|
||||||
|
|
||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
expect_listxattr(ino, 0, ReturnImmediate([](auto i __unused, auto out) {
|
expect_listxattr(ino, 0, ReturnImmediate([](auto i __unused, auto& out) {
|
||||||
out->body.listxattr.size = 16000;
|
out.body.listxattr.size = 16000;
|
||||||
SET_OUT_HEADER_LEN(out, listxattr);
|
SET_OUT_HEADER_LEN(out, listxattr);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO: fix the expected size after fixing the size calculation bug in
|
// TODO: fix the expected size after fixing the size calculation bug in
|
||||||
// fuse_vnop_listextattr. It should be exactly 16000.
|
// fuse_vnop_listextattr. It should be exactly 16000.
|
||||||
expect_listxattr(ino, 16008,
|
expect_listxattr(ino, 16008,
|
||||||
ReturnImmediate([](auto in __unused, auto out) {
|
ReturnImmediate([](auto in __unused, auto& out) {
|
||||||
const char l[16] = "user.foobarbang";
|
const char l[16] = "user.foobarbang";
|
||||||
for (int i=0; i < 1000; i++) {
|
for (int i=0; i < 1000; i++) {
|
||||||
memcpy(&out->body.bytes[16 * i], l, 16);
|
memcpy(&out.body.bytes[16 * i], l, 16);
|
||||||
}
|
}
|
||||||
out->header.len = sizeof(fuse_out_header) + 16000;
|
out.header.len = sizeof(fuse_out_header) + 16000;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -411,8 +411,8 @@ TEST_F(Listxattr, user)
|
|||||||
|
|
||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
expect_listxattr(ino, 0,
|
expect_listxattr(ino, 0,
|
||||||
ReturnImmediate([&](auto in __unused, auto out) {
|
ReturnImmediate([&](auto in __unused, auto& out) {
|
||||||
out->body.listxattr.size = sizeof(attrs);
|
out.body.listxattr.size = sizeof(attrs);
|
||||||
SET_OUT_HEADER_LEN(out, listxattr);
|
SET_OUT_HEADER_LEN(out, listxattr);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -420,12 +420,12 @@ TEST_F(Listxattr, user)
|
|||||||
// TODO: fix the expected size after fixing the size calculation bug in
|
// TODO: fix the expected size after fixing the size calculation bug in
|
||||||
// fuse_vnop_listextattr.
|
// fuse_vnop_listextattr.
|
||||||
expect_listxattr(ino, sizeof(attrs) + 8,
|
expect_listxattr(ino, sizeof(attrs) + 8,
|
||||||
ReturnImmediate([&](auto in __unused, auto out) {
|
ReturnImmediate([&](auto in __unused, auto& out) {
|
||||||
memcpy((void*)out->body.bytes, attrs, sizeof(attrs));
|
memcpy((void*)out.body.bytes, attrs, sizeof(attrs));
|
||||||
out->header.len = sizeof(fuse_out_header) + sizeof(attrs);
|
out.header.len = sizeof(fuse_out_header) + sizeof(attrs);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
ASSERT_EQ((ssize_t)sizeof(expected),
|
ASSERT_EQ(static_cast<ssize_t>(sizeof(expected)),
|
||||||
extattr_list_file(FULLPATH, ns, data, sizeof(data)))
|
extattr_list_file(FULLPATH, ns, data, sizeof(data)))
|
||||||
<< strerror(errno);
|
<< strerror(errno);
|
||||||
ASSERT_EQ(0, memcmp(expected, data, sizeof(expected)));
|
ASSERT_EQ(0, memcmp(expected, data, sizeof(expected)));
|
||||||
@ -445,8 +445,8 @@ TEST_F(Listxattr, system)
|
|||||||
|
|
||||||
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
|
||||||
expect_listxattr(ino, 0,
|
expect_listxattr(ino, 0,
|
||||||
ReturnImmediate([&](auto in __unused, auto out) {
|
ReturnImmediate([&](auto in __unused, auto& out) {
|
||||||
out->body.listxattr.size = sizeof(attrs);
|
out.body.listxattr.size = sizeof(attrs);
|
||||||
SET_OUT_HEADER_LEN(out, listxattr);
|
SET_OUT_HEADER_LEN(out, listxattr);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -454,12 +454,12 @@ TEST_F(Listxattr, system)
|
|||||||
// TODO: fix the expected size after fixing the size calculation bug in
|
// TODO: fix the expected size after fixing the size calculation bug in
|
||||||
// fuse_vnop_listextattr.
|
// fuse_vnop_listextattr.
|
||||||
expect_listxattr(ino, sizeof(attrs) + 8,
|
expect_listxattr(ino, sizeof(attrs) + 8,
|
||||||
ReturnImmediate([&](auto in __unused, auto out) {
|
ReturnImmediate([&](auto in __unused, auto& out) {
|
||||||
memcpy((void*)out->body.bytes, attrs, sizeof(attrs));
|
memcpy((void*)out.body.bytes, attrs, sizeof(attrs));
|
||||||
out->header.len = sizeof(fuse_out_header) + sizeof(attrs);
|
out.header.len = sizeof(fuse_out_header) + sizeof(attrs);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
ASSERT_EQ((ssize_t)sizeof(expected),
|
ASSERT_EQ(static_cast<ssize_t>(sizeof(expected)),
|
||||||
extattr_list_file(FULLPATH, ns, data, sizeof(data)))
|
extattr_list_file(FULLPATH, ns, data, sizeof(data)))
|
||||||
<< strerror(errno);
|
<< strerror(errno);
|
||||||
ASSERT_EQ(0, memcmp(expected, data, sizeof(expected)));
|
ASSERT_EQ(0, memcmp(expected, data, sizeof(expected)));
|
||||||
|
Loading…
Reference in New Issue
Block a user