svn commit: r362114 - stable/12/tests/sys/fs/fusefs
Alan Somers
asomers at FreeBSD.org
Fri Jun 12 20:11:26 UTC 2020
Author: asomers
Date: Fri Jun 12 20:11:25 2020
New Revision: 362114
URL: https://svnweb.freebsd.org/changeset/base/362114
Log:
MFC r361223:
fusefs: fix intermittency in some ENOENT tests
When a FUSE operation other than LOOKUP returns ENOENT, the kernel will
reclaim that vnode, resuling in a FUSE_FORGET being sent a short while
later. Many of the ENOENT tests weren't expecting those FUSE_FORGET
operations. They usually passed by luck since FUSE_FORGET is often delayed.
This commit adds appropriate expectations.
Modified:
stable/12/tests/sys/fs/fusefs/getattr.cc
stable/12/tests/sys/fs/fusefs/open.cc
stable/12/tests/sys/fs/fusefs/opendir.cc
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/tests/sys/fs/fusefs/getattr.cc
==============================================================================
--- stable/12/tests/sys/fs/fusefs/getattr.cc Fri Jun 12 19:56:19 2020 (r362113)
+++ stable/12/tests/sys/fs/fusefs/getattr.cc Fri Jun 12 20:11:25 2020 (r362114)
@@ -32,6 +32,8 @@
extern "C" {
#include <sys/param.h>
+
+#include <semaphore.h>
}
#include "mockfs.hh"
@@ -172,7 +174,10 @@ TEST_F(Getattr, enoent)
const char RELPATH[] = "some_file.txt";
struct stat sb;
const uint64_t ino = 42;
+ sem_t sem;
+ ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1, 0, 0);
EXPECT_CALL(*m_mock, process(
ResultOf([](auto in) {
@@ -181,8 +186,15 @@ TEST_F(Getattr, enoent)
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(ENOENT)));
+ // Since FUSE_GETATTR returns ENOENT, the kernel will reclaim the vnode
+ // and send a FUSE_FORGET
+ expect_forget(ino, 1, &sem);
+
EXPECT_NE(0, stat(FULLPATH, &sb));
EXPECT_EQ(ENOENT, errno);
+
+ sem_wait(&sem);
+ sem_destroy(&sem);
}
TEST_F(Getattr, ok)
Modified: stable/12/tests/sys/fs/fusefs/open.cc
==============================================================================
--- stable/12/tests/sys/fs/fusefs/open.cc Fri Jun 12 19:56:19 2020 (r362113)
+++ stable/12/tests/sys/fs/fusefs/open.cc Fri Jun 12 20:11:25 2020 (r362114)
@@ -32,7 +32,9 @@
extern "C" {
#include <sys/wait.h>
+
#include <fcntl.h>
+#include <semaphore.h>
}
#include "mockfs.hh"
@@ -105,7 +107,10 @@ TEST_F(Open, enoent)
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
+ sem_t sem;
+ ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
@@ -114,8 +119,15 @@ TEST_F(Open, enoent)
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnErrno(ENOENT)));
+ // Since FUSE_OPEN returns ENOENT, the kernel will reclaim the vnode
+ // and send a FUSE_FORGET
+ expect_forget(ino, 1, &sem);
+
ASSERT_EQ(-1, open(FULLPATH, O_RDONLY));
EXPECT_EQ(ENOENT, errno);
+
+ sem_wait(&sem);
+ sem_destroy(&sem);
}
/*
Modified: stable/12/tests/sys/fs/fusefs/opendir.cc
==============================================================================
--- stable/12/tests/sys/fs/fusefs/opendir.cc Fri Jun 12 19:56:19 2020 (r362113)
+++ stable/12/tests/sys/fs/fusefs/opendir.cc Fri Jun 12 20:11:25 2020 (r362114)
@@ -32,7 +32,9 @@
extern "C" {
#include <dirent.h>
+
#include <fcntl.h>
+#include <semaphore.h>
}
#include "mockfs.hh"
@@ -82,12 +84,21 @@ TEST_F(Opendir, enoent)
const char FULLPATH[] = "mountpoint/some_dir";
const char RELPATH[] = "some_dir";
uint64_t ino = 42;
+ sem_t sem;
+ ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno);
+
expect_lookup(RELPATH, ino);
expect_opendir(ino, O_RDONLY, ReturnErrno(ENOENT));
+ // Since FUSE_OPENDIR returns ENOENT, the kernel will reclaim the vnode
+ // and send a FUSE_FORGET
+ expect_forget(ino, 1, &sem);
ASSERT_EQ(-1, open(FULLPATH, O_DIRECTORY));
EXPECT_EQ(ENOENT, errno);
+
+ sem_wait(&sem);
+ sem_destroy(&sem);
}
/*
More information about the svn-src-all
mailing list