diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/sys/fs/fusefs/fallocate.cc | 16 | ||||
| -rw-r--r-- | tests/sys/fs/fusefs/xattr.cc | 67 |
2 files changed, 60 insertions, 23 deletions
diff --git a/tests/sys/fs/fusefs/fallocate.cc b/tests/sys/fs/fusefs/fallocate.cc index 4e5b047b78b7..1a3a0af36236 100644 --- a/tests/sys/fs/fusefs/fallocate.cc +++ b/tests/sys/fs/fusefs/fallocate.cc @@ -205,7 +205,7 @@ TEST_F(Fspacectl, enosys) EXPECT_EQ(0, fspacectl(fd, SPACECTL_DEALLOC, &rqsr, 0, NULL)); /* Neither should posix_fallocate query the daemon */ - EXPECT_EQ(EINVAL, posix_fallocate(fd, off1, len1)); + EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, off1, len1)); leak(fd); } @@ -548,7 +548,7 @@ INSTANTIATE_TEST_SUITE_P(FspacectlCache, FspacectlCache, /* * If the server returns ENOSYS, it indicates that the server does not support - * FUSE_FALLOCATE. This and future calls should return EINVAL. + * FUSE_FALLOCATE. This and future calls should return EOPNOTSUPP. */ TEST_F(PosixFallocate, enosys) { @@ -570,10 +570,10 @@ TEST_F(PosixFallocate, enosys) fd = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd) << strerror(errno); - EXPECT_EQ(EINVAL, posix_fallocate(fd, off0, len0)); + EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, off0, len0)); /* Subsequent calls shouldn't query the daemon*/ - EXPECT_EQ(EINVAL, posix_fallocate(fd, off0, len0)); + EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, off0, len0)); /* Neither should VOP_DEALLOCATE query the daemon */ EXPECT_EQ(0, fspacectl(fd, SPACECTL_DEALLOC, &rqsr, 0, NULL)); @@ -607,10 +607,10 @@ TEST_F(PosixFallocate, eopnotsupp) fd = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd) << strerror(errno); - EXPECT_EQ(EINVAL, posix_fallocate(fd, fsize, length)); + EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, fsize, length)); /* Subsequent calls should still query the daemon*/ - EXPECT_EQ(EINVAL, posix_fallocate(fd, offset, length)); + EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, offset, length)); /* And subsequent VOP_DEALLOCATE calls should also query the daemon */ rqsr.r_len = length; @@ -759,7 +759,7 @@ TEST_F(PosixFallocate, rlimit_fsize) } /* With older servers, no FUSE_FALLOCATE should be attempted */ -TEST_F(PosixFallocate_7_18, einval) +TEST_F(PosixFallocate_7_18, eopnotsupp) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; @@ -773,7 +773,7 @@ TEST_F(PosixFallocate_7_18, einval) fd = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd) << strerror(errno); - EXPECT_EQ(EINVAL, posix_fallocate(fd, offset, length)); + EXPECT_EQ(EOPNOTSUPP, posix_fallocate(fd, offset, length)); leak(fd); } diff --git a/tests/sys/fs/fusefs/xattr.cc b/tests/sys/fs/fusefs/xattr.cc index 0ab203c96254..afeacd4a249e 100644 --- a/tests/sys/fs/fusefs/xattr.cc +++ b/tests/sys/fs/fusefs/xattr.cc @@ -100,7 +100,11 @@ void expect_removexattr(uint64_t ino, const char *attr, int error) ).WillOnce(Invoke(ReturnErrno(error))); } -void expect_setxattr(uint64_t ino, const char *attr, const char *value, +/* + * Expect a FUSE_SETXATTR request in the format used by protocol 7.33 and + * later, with the FUSE_SETXATTR_EXT bit set. + */ +void expect_setxattr_ext(uint64_t ino, const char *attr, const char *value, ProcessMockerT r) { EXPECT_CALL(*m_mock, process( @@ -119,16 +123,10 @@ void expect_setxattr(uint64_t ino, const char *attr, const char *value, ).WillOnce(Invoke(r)); } -}; - -class Xattr_7_32:public FuseTest { -public: -virtual void SetUp() -{ - m_kernel_minor_version = 32; - FuseTest::SetUp(); -} - +/* + * Expect a FUSE_SETXATTR request in the format used by protocol 7.32 and + * earlier. + */ void expect_setxattr_7_32(uint64_t ino, const char *attr, const char *value, ProcessMockerT r) { @@ -148,6 +146,15 @@ void expect_setxattr_7_32(uint64_t ino, const char *attr, const char *value, } }; +class Xattr_7_32: public Xattr { +public: +virtual void SetUp() +{ + m_kernel_minor_version = 32; + Xattr::SetUp(); +} +}; + class Getxattr: public Xattr {}; class Listxattr: public Xattr {}; @@ -182,6 +189,13 @@ void TearDown() { class Removexattr: public Xattr {}; class Setxattr: public Xattr {}; +class SetxattrExt: public Setxattr { +public: +virtual void SetUp() { + m_init_flags |= FUSE_SETXATTR_EXT; + Setxattr::SetUp(); +} +}; class Setxattr_7_32:public Xattr_7_32 {}; class RofsXattr: public Xattr { public: @@ -773,7 +787,7 @@ TEST_F(Setxattr, enosys) ssize_t r; expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 2); - expect_setxattr(ino, "user.foo", value, ReturnErrno(ENOSYS)); + expect_setxattr_7_32(ino, "user.foo", value, ReturnErrno(ENOSYS)); r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, value_len); @@ -800,7 +814,7 @@ TEST_F(Setxattr, enotsup) ssize_t r; expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); - expect_setxattr(ino, "user.foo", value, ReturnErrno(ENOTSUP)); + expect_setxattr_7_32(ino, "user.foo", value, ReturnErrno(ENOTSUP)); r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, value_len); @@ -820,7 +834,7 @@ TEST_F(Setxattr, user) ssize_t r; expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); - expect_setxattr(ino, "user.foo", value, ReturnErrno(0)); + expect_setxattr_7_32(ino, "user.foo", value, ReturnErrno(0)); r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, value_len); @@ -839,7 +853,7 @@ TEST_F(Setxattr, system) ssize_t r; expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); - expect_setxattr(ino, "system.foo", value, ReturnErrno(0)); + expect_setxattr_7_32(ino, "system.foo", value, ReturnErrno(0)); r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, value_len); @@ -847,6 +861,10 @@ TEST_F(Setxattr, system) } +/* + * For servers using protocol 7.32 and older, the kernel should use the older + * FUSE_SETXATTR format. + */ TEST_F(Setxattr_7_32, ok) { uint64_t ino = 42; @@ -863,6 +881,25 @@ TEST_F(Setxattr_7_32, ok) ASSERT_EQ(value_len, r) << strerror(errno); } +/* + * Successfully set a user attribute using the extended format + */ +TEST_F(SetxattrExt, user) +{ + uint64_t ino = 42; + const char value[] = "whatever"; + ssize_t value_len = strlen(value) + 1; + int ns = EXTATTR_NAMESPACE_USER; + ssize_t r; + + expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); + expect_setxattr_ext(ino, "user.foo", value, ReturnErrno(0)); + + r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len); + ASSERT_EQ(value_len, r) << strerror(errno); +} + TEST_F(RofsXattr, deleteextattr_erofs) { uint64_t ino = 42; |
