fuse unit tests and fixes

This commit is contained in:
Scott E. Graves 2024-11-10 10:25:53 -06:00
parent c276cb8979
commit eec286845e

View File

@ -85,6 +85,27 @@ TYPED_TEST(fuse_test, access_can_check_directory_does_not_have_write_access) {
this->rmdir_and_test(dir_path); this->rmdir_and_test(dir_path);
} }
TYPED_TEST(fuse_test, access_can_check_directory_execute_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(), X_OK));
this->rmdir_and_test(dir_path);
}
TYPED_TEST(fuse_test, access_can_check_directory_does_not_have_execute_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(), X_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) { TYPED_TEST(fuse_test, access_can_check_if_file_exists) {
std::string file_name{"access_test"}; std::string file_name{"access_test"};
auto file_path = this->create_file_and_test(file_name); auto file_path = this->create_file_and_test(file_name);
@ -135,6 +156,27 @@ TYPED_TEST(fuse_test, access_can_check_file_does_not_have_write_access) {
this->unlink_file_and_test(file_path); this->unlink_file_and_test(file_path);
} }
TYPED_TEST(fuse_test, access_can_check_file_execute_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(), X_OK));
this->unlink_file_and_test(file_path);
}
TYPED_TEST(fuse_test, access_can_check_file_does_not_have_execute_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(), X_OK));
EXPECT_EQ(EACCES, utils::get_last_error_code());
this->unlink_file_and_test(file_path);
}
} // namespace repertory } // namespace repertory
#endif // !defined(_WIN32) #endif // !defined(_WIN32)