From f3b5de2918519b47f67f3af321b6eb8fd441e784 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sat, 30 Mar 2019 00:35:59 +0000 Subject: [PATCH] fusefs: fix tests when data caching is disabled VOP_GETPAGES is disabled when vfs.fusefs.data_cache_mode=0, causing mmap to return success but accessing the mapped memory will subsequently segfault. Sponsored by: The FreeBSD Foundation --- tests/sys/fs/fusefs/read.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/sys/fs/fusefs/read.cc b/tests/sys/fs/fusefs/read.cc index a1145c29a4ad..07b532ca4a13 100644 --- a/tests/sys/fs/fusefs/read.cc +++ b/tests/sys/fs/fusefs/read.cc @@ -78,6 +78,23 @@ class AsyncRead: public AioRead { } }; +class ReadMmap: public Read { +public: +virtual void SetUp() { + const char *node = "vfs.fusefs.data_cache_mode"; + int val = 0; + size_t size = sizeof(val); + + FuseTest::SetUp(); + + ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0)) + << strerror(errno); + if (val == 0) + GTEST_SKIP() << + "fusefs data caching must be enabled for this test"; +} +}; + class ReadAhead: public Read, public WithParamInterface { virtual void SetUp() { m_maxreadahead = GetParam(); @@ -450,7 +467,7 @@ TEST_F(Read, keep_cache_disabled) /* Deliberately leak fd0 and fd1. */ } -TEST_F(Read, mmap) +TEST_F(ReadMmap, mmap) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; @@ -621,7 +638,7 @@ TEST_F(Read, default_readahead) } /* Reading with sendfile should work (though it obviously won't be 0-copy) */ -TEST_F(Read, sendfile) +TEST_F(ReadMmap, sendfile) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; @@ -668,7 +685,7 @@ TEST_F(Read, sendfile) /* sendfile should fail gracefully if fuse declines the read */ /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236466 */ -TEST_F(Read, DISABLED_sendfile_eio) +TEST_F(ReadMmap, DISABLED_sendfile_eio) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt";