1
0
mirror of https://github.com/falk-werner/webfuse synced 2026-10-17 00:50:46 +00:00

add readdir test

This commit is contained in:
Falk Werner
2023-01-01 14:48:19 +01:00
parent 0e0bb74872
commit 2234f69d2d
4 changed files with 123 additions and 4 deletions

View File

@@ -36,16 +36,36 @@ int fs_getattr (std::string const & path, struct stat * attr)
}
}
TEST(access, ok_NO_MEMCHECK)
TEST(readdir, existing_file)
{
webfuse::filesystem_mock fs;
EXPECT_CALL(fs, access("/",_)).Times(AnyNumber()).WillRepeatedly(Return(0));
EXPECT_CALL(fs, access("/foo",_)).WillOnce(Return(0));
EXPECT_CALL(fs, access("/foo", F_OK)).WillOnce(Return(0));
EXPECT_CALL(fs, access("/foo", R_OK)).WillOnce(Return(0));
EXPECT_CALL(fs, access("/foo", W_OK)).WillOnce(Return(0));
EXPECT_CALL(fs, access("/foo", X_OK)).WillOnce(Return(-EACCES));
EXPECT_CALL(fs, getattr(_,_)).WillRepeatedly(Invoke(fs_getattr));
webfuse::fixture fixture(fs);
auto const path = fixture.get_path() + "/foo";
int const rc = ::access(path.c_str(), F_OK);
ASSERT_EQ(0, rc);
ASSERT_EQ(0, ::access(path.c_str(), F_OK));
ASSERT_EQ(0, ::access(path.c_str(), R_OK));
ASSERT_EQ(0, ::access(path.c_str(), W_OK));
ASSERT_EQ(-1, ::access(path.c_str(), X_OK));
ASSERT_EQ(EACCES, errno);
}
TEST(access, non_existing_file)
{
webfuse::filesystem_mock fs;
EXPECT_CALL(fs, access("/",_)).Times(AnyNumber()).WillRepeatedly(Return(0));
EXPECT_CALL(fs, access("/foo", F_OK)).WillOnce(Return(-ENOENT));
EXPECT_CALL(fs, getattr(_,_)).WillRepeatedly(Invoke(fs_getattr));
webfuse::fixture fixture(fs);
auto const path = fixture.get_path() + "/foo";
ASSERT_EQ(-1, ::access(path.c_str(), F_OK));
ASSERT_EQ(ENOENT, errno);
}