Skip to content

Commit

Permalink
fusefs: make the tests more robust to changes to maxphys
Browse files Browse the repository at this point in the history
Remove assumptions in two test cases that maxphys won't be huge.

Reported by:	kib
MFC after:	2 weeks
Sponsored by:	Axcient
  • Loading branch information
asomers committed May 9, 2024
1 parent 0d15140 commit b2792a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions tests/sys/fs/fusefs/bmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ class BmapEof: public Bmap, public WithParamInterface<int> {};

/*
* Test FUSE_BMAP
* XXX The FUSE protocol does not include the runp and runb variables, so those
* must be guessed in-kernel.
*/
TEST_F(Bmap, bmap)
{
Expand All @@ -105,8 +103,19 @@ TEST_F(Bmap, bmap)
arg.runb = -1;
ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno);
EXPECT_EQ(arg.bn, pbn);
EXPECT_EQ((unsigned long)arg.runp, m_maxphys / m_maxbcachebuf - 1);
EXPECT_EQ((unsigned long)arg.runb, m_maxphys / m_maxbcachebuf - 1);
/*
* XXX The FUSE protocol does not include the runp and runb variables,
* so those must be guessed in-kernel. There's no "right" answer, so
* just check that they're within reasonable limits.
*/
EXPECT_LE(arg.runb, lbn);
EXPECT_LE((unsigned long)arg.runb, m_maxreadahead / m_maxbcachebuf);
EXPECT_LE((unsigned long)arg.runb, m_maxphys / m_maxbcachebuf);
EXPECT_GT(arg.runb, 0);
EXPECT_LE(arg.runp, filesize / m_maxbcachebuf - lbn);
EXPECT_LE((unsigned long)arg.runp, m_maxreadahead / m_maxbcachebuf);
EXPECT_LE((unsigned long)arg.runp, m_maxphys / m_maxbcachebuf);
EXPECT_GT(arg.runp, 0);

leak(fd);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/sys/fs/fusefs/write.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class WriteCluster: public WriteBack {
public:
virtual void SetUp() {
m_async = true;
m_maxwrite = 1 << 25; // Anything larger than MAXPHYS will suffice
m_maxwrite = UINT32_MAX; // Anything larger than MAXPHYS will suffice
WriteBack::SetUp();
if (m_maxphys < 2 * DFLTPHYS)
GTEST_SKIP() << "MAXPHYS must be at least twice DFLTPHYS"
Expand Down

0 comments on commit b2792a3

Please sign in to comment.