aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/fs/fusefs/fallocate.cc16
-rw-r--r--tests/sys/fs/fusefs/xattr.cc67
-rw-r--r--tests/sys/netpfil/pf/table.sh62
3 files changed, 122 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;
diff --git a/tests/sys/netpfil/pf/table.sh b/tests/sys/netpfil/pf/table.sh
index 69fe12fc9804..6761ce652beb 100644
--- a/tests/sys/netpfil/pf/table.sh
+++ b/tests/sys/netpfil/pf/table.sh
@@ -747,6 +747,67 @@ in_anchor_cleanup()
pft_cleanup
}
+atf_test_case "replace" "cleanup"
+replace_head()
+{
+ atf_set descr 'Test table replace command'
+ atf_set require.user root
+}
+
+replace_body()
+{
+ pft_init
+ pwd=$(pwd)
+
+ epair_send=$(vnet_mkepair)
+ ifconfig ${epair_send}a 192.0.2.1/24 up
+
+ vnet_mkjail alcatraz ${epair_send}b
+ jexec alcatraz ifconfig ${epair_send}b 192.0.2.2/24 up
+ jexec alcatraz pfctl -e
+
+ pft_set_rules alcatraz \
+ "table <foo> counters { 192.0.2.1 }" \
+ "block all" \
+ "pass in from <foo> to any" \
+ "pass out from any to <foo>" \
+ "set skip on lo"
+
+ atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2
+
+ # Replace the address
+ atf_check -s exit:0 -e "match:1 addresses added." -e "match:1 addresses deleted." \
+ jexec alcatraz pfctl -t foo -T replace 192.0.2.3
+ atf_check -s exit:0 -o "match:192.0.2.3" \
+ jexec alcatraz pfctl -t foo -T show
+ atf_check -s exit:2 -o ignore ping -c 3 192.0.2.2
+
+ # Negated address
+ atf_check -s exit:0 -e "match:1 addresses changed." \
+ jexec alcatraz pfctl -t foo -T replace "!192.0.2.3"
+
+ # Now add 500 addresses
+ for i in `seq 1 2`; do
+ for j in `seq 1 250`; do
+ echo "1.${i}.${j}.1" >> ${pwd}/foo.lst
+ done
+ done
+ atf_check -s exit:0 -e "match:500 addresses added." -e "match:1 addresses deleted." \
+ jexec alcatraz pfctl -t foo -T replace -f ${pwd}/foo.lst
+
+ atf_check -s exit:0 -o "not-match:192.0.2.3" \
+ jexec alcatraz pfctl -t foo -T show
+
+ # Loading the same list produces no changes.
+ atf_check -s exit:0 -e "match:no changes." \
+ jexec alcatraz pfctl -t foo -T replace -f ${pwd}/foo.lst
+}
+
+replace_cleanup()
+{
+ pft_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "v4_counters"
@@ -765,4 +826,5 @@ atf_init_test_cases()
atf_add_test_case "large"
atf_add_test_case "show_recursive"
atf_add_test_case "in_anchor"
+ atf_add_test_case "replace"
}