Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/fs/fusefs/write.cc
Show First 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | FuseTest::expect_write(ino, offset, isize, osize, FUSE_WRITE_CACHE, 0, | ||||
contents); | contents); | ||||
} | } | ||||
}; | }; | ||||
class WriteBackAsync: public WriteBack { | class WriteBackAsync: public WriteBack { | ||||
public: | public: | ||||
virtual void SetUp() { | virtual void SetUp() { | ||||
m_async = true; | m_async = true; | ||||
m_maxwrite = 65536; | |||||
WriteBack::SetUp(); | WriteBack::SetUp(); | ||||
} | } | ||||
}; | }; | ||||
class TimeGran: public WriteBackAsync, public WithParamInterface<unsigned> { | class TimeGran: public WriteBackAsync, public WithParamInterface<unsigned> { | ||||
public: | public: | ||||
virtual void SetUp() { | virtual void SetUp() { | ||||
m_time_gran = 1 << GetParam(); | m_time_gran = 1 << GetParam(); | ||||
Show All 12 Lines | if (m_maxphys < 2 * DFLTPHYS) | ||||
GTEST_SKIP() << "MAXPHYS must be at least twice DFLTPHYS" | GTEST_SKIP() << "MAXPHYS must be at least twice DFLTPHYS" | ||||
<< " for this test"; | << " for this test"; | ||||
if (m_maxphys < 2 * m_maxbcachebuf) | if (m_maxphys < 2 * m_maxbcachebuf) | ||||
GTEST_SKIP() << "MAXPHYS must be at least twice maxbcachebuf" | GTEST_SKIP() << "MAXPHYS must be at least twice maxbcachebuf" | ||||
<< " for this test"; | << " for this test"; | ||||
} | } | ||||
}; | }; | ||||
/* Tests relating to the server's max_write property */ | |||||
class WriteMaxWrite: public Write { | |||||
public: | |||||
virtual void SetUp() { | |||||
/* | |||||
* For this test, m_maxwrite must be less than either m_maxbcachebuf or | |||||
* maxphys. | |||||
*/ | |||||
m_maxwrite = 32768; | |||||
Write::SetUp(); | |||||
} | |||||
}; | |||||
void sigxfsz_handler(int __unused sig) { | void sigxfsz_handler(int __unused sig) { | ||||
Write::s_sigxfsz = 1; | Write::s_sigxfsz = 1; | ||||
} | } | ||||
/* AIO writes need to set the header's pid field correctly */ | /* AIO writes need to set the header's pid field correctly */ | ||||
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236379 */ | /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236379 */ | ||||
TEST_F(AioWrite, DISABLED_aio_write) | TEST_F(AioWrite, DISABLED_aio_write) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 433 Lines • ▼ Show 20 Lines | TEST_F(Write, write) | ||||
fd = open(FULLPATH, O_WRONLY); | fd = open(FULLPATH, O_WRONLY); | ||||
ASSERT_LE(0, fd) << strerror(errno); | ASSERT_LE(0, fd) << strerror(errno); | ||||
ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno); | ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno); | ||||
leak(fd); | leak(fd); | ||||
} | } | ||||
/* fuse(4) should not issue writes of greater size than the daemon requests */ | /* fuse(4) should not issue writes of greater size than the daemon requests */ | ||||
TEST_F(Write, write_large) | TEST_F(WriteMaxWrite, write) | ||||
{ | { | ||||
const char FULLPATH[] = "mountpoint/some_file.txt"; | const char FULLPATH[] = "mountpoint/some_file.txt"; | ||||
const char RELPATH[] = "some_file.txt"; | const char RELPATH[] = "some_file.txt"; | ||||
int *contents; | int *contents; | ||||
uint64_t ino = 42; | uint64_t ino = 42; | ||||
int fd; | int fd; | ||||
ssize_t halfbufsize, bufsize; | ssize_t halfbufsize, bufsize; | ||||
halfbufsize = m_mock->m_maxwrite; | halfbufsize = m_mock->m_maxwrite; | ||||
if (halfbufsize >= m_maxbcachebuf || halfbufsize >= m_maxphys) | |||||
GTEST_SKIP() << "Must lower m_maxwrite for this test"; | |||||
bufsize = halfbufsize * 2; | bufsize = halfbufsize * 2; | ||||
contents = (int*)malloc(bufsize); | contents = (int*)malloc(bufsize); | ||||
ASSERT_NE(nullptr, contents); | ASSERT_NE(nullptr, contents); | ||||
for (int i = 0; i < (int)bufsize / (int)sizeof(i); i++) { | for (int i = 0; i < (int)bufsize / (int)sizeof(i); i++) { | ||||
contents[i] = i; | contents[i] = i; | ||||
} | } | ||||
expect_lookup(RELPATH, ino, 0); | expect_lookup(RELPATH, ino, 0); | ||||
▲ Show 20 Lines • Show All 726 Lines • Show Last 20 Lines |