fusefs: fix the tests for non-default values of MAXPHYS

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Alan Somers 2019-06-25 21:21:34 +00:00
parent 6ca3b02b1b
commit f2704f05cb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=349394
5 changed files with 34 additions and 23 deletions

View File

@ -99,8 +99,8 @@ TEST_F(Bmap, bmap)
arg.runb = -1; arg.runb = -1;
ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno); ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno);
EXPECT_EQ(arg.bn, pbn); EXPECT_EQ(arg.bn, pbn);
EXPECT_EQ(arg.runp, MAXPHYS / m_maxbcachebuf - 1); EXPECT_EQ(arg.runp, m_maxphys / m_maxbcachebuf - 1);
EXPECT_EQ(arg.runb, MAXPHYS / m_maxbcachebuf - 1); EXPECT_EQ(arg.runb, m_maxphys / m_maxbcachebuf - 1);
} }
/* /*
@ -134,7 +134,7 @@ TEST_F(Bmap, default_)
arg.runb = -1; arg.runb = -1;
ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno); ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno);
EXPECT_EQ(arg.bn, 0); EXPECT_EQ(arg.bn, 0);
EXPECT_EQ(arg.runp, MAXPHYS / m_maxbcachebuf - 1); EXPECT_EQ(arg.runp, m_maxphys / m_maxbcachebuf - 1);
EXPECT_EQ(arg.runb, 0); EXPECT_EQ(arg.runb, 0);
/* In the middle */ /* In the middle */
@ -144,8 +144,8 @@ TEST_F(Bmap, default_)
arg.runb = -1; arg.runb = -1;
ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno); ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno);
EXPECT_EQ(arg.bn, lbn * m_maxbcachebuf / DEV_BSIZE); EXPECT_EQ(arg.bn, lbn * m_maxbcachebuf / DEV_BSIZE);
EXPECT_EQ(arg.runp, MAXPHYS / m_maxbcachebuf - 1); EXPECT_EQ(arg.runp, m_maxphys / m_maxbcachebuf - 1);
EXPECT_EQ(arg.runb, MAXPHYS / m_maxbcachebuf - 1); EXPECT_EQ(arg.runb, m_maxphys / m_maxbcachebuf - 1);
/* Last block */ /* Last block */
lbn = filesize / m_maxbcachebuf - 1; lbn = filesize / m_maxbcachebuf - 1;
@ -155,5 +155,5 @@ TEST_F(Bmap, default_)
ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno); ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno);
EXPECT_EQ(arg.bn, lbn * m_maxbcachebuf / DEV_BSIZE); EXPECT_EQ(arg.bn, lbn * m_maxbcachebuf / DEV_BSIZE);
EXPECT_EQ(arg.runp, 0); EXPECT_EQ(arg.runp, 0);
EXPECT_EQ(arg.runb, MAXPHYS / m_maxbcachebuf - 1); EXPECT_EQ(arg.runb, m_maxphys / m_maxbcachebuf - 1);
} }

View File

@ -110,10 +110,16 @@ virtual void SetUp() {
}; };
class ReadAhead: public ReadCacheable, class ReadAhead: public ReadCacheable,
public WithParamInterface<tuple<bool, uint32_t>> public WithParamInterface<tuple<bool, int>>
{ {
virtual void SetUp() { virtual void SetUp() {
m_maxreadahead = get<1>(GetParam()); int val;
const char *node = "vfs.maxbcachebuf";
size_t size = sizeof(val);
ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0))
<< strerror(errno);
m_maxreadahead = val * get<1>(GetParam());
m_noclusterr = get<0>(GetParam()); m_noclusterr = get<0>(GetParam());
ReadCacheable::SetUp(); ReadCacheable::SetUp();
} }
@ -892,8 +898,8 @@ TEST_P(ReadAhead, readahead) {
expect_lookup(RELPATH, ino, filesize); expect_lookup(RELPATH, ino, filesize);
expect_open(ino, 0, 1); expect_open(ino, 0, 1);
maxcontig = m_noclusterr ? m_maxbcachebuf : maxcontig = m_noclusterr ? m_maxbcachebuf :
m_maxbcachebuf + (int)get<1>(GetParam()); m_maxbcachebuf + m_maxreadahead;
clustersize = MIN(maxcontig, MAXPHYS); clustersize = MIN(maxcontig, m_maxphys);
for (offs = 0; offs < bufsize; offs += clustersize) { for (offs = 0; offs < bufsize; offs += clustersize) {
len = std::min((size_t)clustersize, (size_t)(filesize - offs)); len = std::min((size_t)clustersize, (size_t)(filesize - offs));
expect_read(ino, offs, len, len, contents + offs); expect_read(ino, offs, len, len, contents + offs);
@ -912,10 +918,10 @@ TEST_P(ReadAhead, readahead) {
} }
INSTANTIATE_TEST_CASE_P(RA, ReadAhead, INSTANTIATE_TEST_CASE_P(RA, ReadAhead,
Values(tuple<bool, int>(false, 0u), Values(tuple<bool, int>(false, 0),
tuple<bool, int>(false, 0x10000), tuple<bool, int>(false, 1),
tuple<bool, int>(false, 0x20000), tuple<bool, int>(false, 2),
tuple<bool, int>(false, 0x30000), tuple<bool, int>(false, 3),
tuple<bool, int>(true, 0u), tuple<bool, int>(true, 0),
tuple<bool, int>(true, 0x10000), tuple<bool, int>(true, 1),
tuple<bool, int>(true, 0x20000))); tuple<bool, int>(true, 2)));

View File

@ -93,7 +93,8 @@ class FuseEnv: public Environment {
}; };
void FuseTest::SetUp() { void FuseTest::SetUp() {
const char *node = "vfs.maxbcachebuf"; const char *maxbcachebuf_node = "vfs.maxbcachebuf";
const char *maxphys_node = "kern.maxphys";
int val = 0; int val = 0;
size_t size = sizeof(val); size_t size = sizeof(val);
@ -105,9 +106,12 @@ void FuseTest::SetUp() {
if (IsSkipped()) if (IsSkipped())
return; return;
ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0)) ASSERT_EQ(0, sysctlbyname(maxbcachebuf_node, &val, &size, NULL, 0))
<< strerror(errno); << strerror(errno);
m_maxbcachebuf = val; m_maxbcachebuf = val;
ASSERT_EQ(0, sysctlbyname(maxphys_node, &val, &size, NULL, 0))
<< strerror(errno);
m_maxphys = val;
try { try {
m_mock = new MockFS(m_maxreadahead, m_allow_other, m_mock = new MockFS(m_maxreadahead, m_allow_other,

View File

@ -60,6 +60,7 @@ class FuseTest : public ::testing::Test {
public: public:
int m_maxbcachebuf; int m_maxbcachebuf;
int m_maxphys;
FuseTest(): FuseTest():
m_maxreadahead(0), m_maxreadahead(0),

View File

@ -233,13 +233,13 @@ virtual void SetUp() {
class WriteCluster: public WriteBack { class WriteCluster: public WriteBack {
public: public:
virtual void SetUp() { virtual void SetUp() {
if (MAXPHYS < 2 * DFLTPHYS) 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";
m_async = true; m_async = true;
m_maxwrite = MAXPHYS; m_maxwrite = m_maxphys;
WriteBack::SetUp(); WriteBack::SetUp();
if (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";
} }
@ -678,7 +678,7 @@ TEST_F(Write, write_large)
expect_lookup(RELPATH, ino, 0); expect_lookup(RELPATH, ino, 0);
expect_open(ino, 0, 1); expect_open(ino, 0, 1);
expect_write(ino, 0, halfbufsize, halfbufsize, contents); maybe_expect_write(ino, 0, halfbufsize, contents);
maybe_expect_write(ino, halfbufsize, halfbufsize, maybe_expect_write(ino, halfbufsize, halfbufsize,
&contents[halfbufsize / sizeof(int)]); &contents[halfbufsize / sizeof(int)]);