diff --git a/tests/sys/fs/fusefs/getattr.cc b/tests/sys/fs/fusefs/getattr.cc index 4c7ab543ab7e..fb91f8c049d0 100644 --- a/tests/sys/fs/fusefs/getattr.cc +++ b/tests/sys/fs/fusefs/getattr.cc @@ -32,6 +32,8 @@ extern "C" { #include + +#include } #include "mockfs.hh" @@ -172,6 +174,9 @@ 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( @@ -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) diff --git a/tests/sys/fs/fusefs/open.cc b/tests/sys/fs/fusefs/open.cc index 8aef5bedf2ec..430c78041128 100644 --- a/tests/sys/fs/fusefs/open.cc +++ b/tests/sys/fs/fusefs/open.cc @@ -32,7 +32,9 @@ extern "C" { #include + #include +#include } #include "mockfs.hh" @@ -105,6 +107,9 @@ 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( @@ -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); } /* diff --git a/tests/sys/fs/fusefs/opendir.cc b/tests/sys/fs/fusefs/opendir.cc index d59feb63fd67..a50e679f0add 100644 --- a/tests/sys/fs/fusefs/opendir.cc +++ b/tests/sys/fs/fusefs/opendir.cc @@ -32,7 +32,9 @@ extern "C" { #include + #include +#include } #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); } /*