fuse unit tests and fixes

This commit is contained in:
Scott E. Graves 2024-11-10 10:18:08 -06:00
parent eb4c8c6cc0
commit 58107e6ed8

View File

@ -64,6 +64,27 @@ TYPED_TEST(fuse_test, access_can_check_directory_does_not_have_read_access) {
this->rmdir_and_test(dir_path);
}
TYPED_TEST(fuse_test, access_can_check_directory_write_access) {
std::string dir_name{"access_test"};
auto dir_path = this->create_directory_and_test(dir_name);
EXPECT_EQ(0, access(dir_path.c_str(), W_OK));
this->rmdir_and_test(dir_path);
}
TYPED_TEST(fuse_test, access_can_check_directory_does_not_have_write_access) {
std::string dir_name{"access_test"};
auto dir_path = this->create_directory_and_test(dir_name);
EXPECT_EQ(0, chmod(dir_path.c_str(), 0000));
EXPECT_EQ(-1, access(dir_path.c_str(), W_OK));
EXPECT_EQ(EACCES, utils::get_last_error_code());
this->rmdir_and_test(dir_path);
}
TYPED_TEST(fuse_test, access_can_check_if_file_exists) {
std::string file_name{"access_test"};
auto file_path = this->create_file_and_test(file_name);
@ -72,6 +93,48 @@ TYPED_TEST(fuse_test, access_can_check_if_file_exists) {
this->unlink_file_and_test(file_path);
}
TYPED_TEST(fuse_test, access_can_check_file_read_access) {
std::string file_name{"access_test"};
auto file_path = this->create_file_and_test(file_name);
EXPECT_EQ(0, access(file_path.c_str(), R_OK));
this->unlink_file_and_test(file_path);
}
TYPED_TEST(fuse_test, access_can_check_file_does_not_have_read_access) {
std::string file_name{"access_test"};
auto file_path = this->create_file_and_test(file_name);
EXPECT_EQ(0, chmod(file_path.c_str(), 0000));
EXPECT_EQ(-1, access(file_path.c_str(), R_OK));
EXPECT_EQ(EACCES, utils::get_last_error_code());
this->unlink_file_and_test(file_path);
}
TYPED_TEST(fuse_test, access_can_check_file_write_access) {
std::string file_name{"access_test"};
auto file_path = this->create_file_and_test(file_name);
EXPECT_EQ(0, access(file_path.c_str(), W_OK));
this->unlink_file_and_test(file_path);
}
TYPED_TEST(fuse_test, access_can_check_file_does_not_have_write_access) {
std::string file_name{"access_test"};
auto file_path = this->create_file_and_test(file_name);
EXPECT_EQ(0, chmod(file_path.c_str(), 0000));
EXPECT_EQ(-1, access(file_path.c_str(), W_OK));
EXPECT_EQ(EACCES, utils::get_last_error_code());
this->unlink_file_and_test(file_path);
}
} // namespace repertory
#endif // !defined(_WIN32)