winfsp unit tests and fixes
This commit is contained in:
parent
73afdaedb9
commit
20ab95380a
@ -128,6 +128,133 @@ TYPED_TEST(winfsp_test, rename_succeeds_if_dest_exists_and_replace_is_true) {
|
||||
EXPECT_TRUE(::DeleteFileA(file_path2.c_str()));
|
||||
EXPECT_TRUE(::RemoveDirectoryA(dir_path.c_str()));
|
||||
}
|
||||
|
||||
TYPED_TEST(winfsp_test, rename_can_rename_dir_if_dest_does_not_exist) {
|
||||
if (this->current_provider == provider_type::s3) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto dir_path{
|
||||
utils::path::combine(this->mount_location, {"test_dir_4"}),
|
||||
};
|
||||
auto dir_path2{
|
||||
utils::path::combine(this->mount_location, {"test_dir2_4"}),
|
||||
};
|
||||
|
||||
ASSERT_TRUE(::CreateDirectoryA(dir_path.c_str(), nullptr));
|
||||
|
||||
EXPECT_TRUE(::MoveFileExA(dir_path.c_str(), dir_path2.c_str(), 0));
|
||||
|
||||
EXPECT_TRUE(::RemoveDirectoryA(dir2_path.c_str()));
|
||||
}
|
||||
|
||||
TYPED_TEST(winfsp_test, rename_dir_fails_if_dest_exists_and_replace_is_false) {
|
||||
if (this->current_provider == provider_type::s3) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto dir_path{
|
||||
utils::path::combine(this->mount_location, {"test_dir_4"}),
|
||||
};
|
||||
auto dir_path2{
|
||||
utils::path::combine(this->mount_location, {"test_dir2_4"}),
|
||||
};
|
||||
|
||||
ASSERT_TRUE(::CreateDirectoryA(dir_path.c_str(), nullptr));
|
||||
ASSERT_TRUE(::CreateDirectoryA(dir_path2.c_str(), nullptr));
|
||||
|
||||
EXPECT_FALSE(::MoveFileExA(dir_path.c_str(), dir_path2.c_str(), 0));
|
||||
EXPECT_EQ(ERROR_ACCESS_DENIED, ::GetLastError());
|
||||
|
||||
EXPECT_TRUE(::RemoveDirectoryA(dir_path.c_str()));
|
||||
EXPECT_TRUE(::RemoveDirectoryA(dir2_path.c_str()));
|
||||
}
|
||||
|
||||
TYPED_TEST(winfsp_test, rename_dir_fails_if_dest_exists_and_replace_is_true) {
|
||||
if (this->current_provider == provider_type::s3) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto dir_path{
|
||||
utils::path::combine(this->mount_location, {"test_dir_4"}),
|
||||
};
|
||||
auto dir_path2{
|
||||
utils::path::combine(this->mount_location, {"test_dir2_4"}),
|
||||
};
|
||||
|
||||
ASSERT_TRUE(::CreateDirectoryA(dir_path.c_str(), nullptr));
|
||||
ASSERT_TRUE(::CreateDirectoryA(dir_path2.c_str(), nullptr));
|
||||
|
||||
EXPECT_FALSE(::MoveFileExA(dir_path.c_str(), dir_path2.c_str(),
|
||||
MOVEFILE_REPLACE_EXISTING));
|
||||
EXPECT_EQ(ERROR_ACCESS_DENIED, ::GetLastError());
|
||||
|
||||
EXPECT_TRUE(::RemoveDirectoryA(dir_path.c_str()));
|
||||
EXPECT_TRUE(::RemoveDirectoryA(dir2_path.c_str()));
|
||||
}
|
||||
|
||||
TYPED_TEST(winfsp_test,
|
||||
rename_dir_fails_directory_is_not_empty_and_replace_is_false) {
|
||||
if (this->current_provider == provider_type::s3) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto dir_path{
|
||||
utils::path::combine(this->mount_location, {"test_dir_4"}),
|
||||
};
|
||||
auto dir_path2{
|
||||
utils::path::combine(this->mount_location, {"test_dir2_4"}),
|
||||
};
|
||||
auto file_path{
|
||||
utils::path::combine(dir_path, {"test_file_4"}),
|
||||
};
|
||||
|
||||
ASSERT_TRUE(::CreateDirectoryA(dir_path.c_str(), nullptr));
|
||||
|
||||
auto handle = ::CreateFileA(file_path.c_str(), GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
|
||||
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
ASSERT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
::CloseHandle(handle);
|
||||
|
||||
EXPECT_FALSE(::MoveFileExA(dir_path.c_str(), dir_path2.c_str(), 0));
|
||||
EXPECT_EQ(ERROR_ACCESS_DENIED, ::GetLastError());
|
||||
|
||||
EXPECT_TRUE(::DeleteFileA(file_path.c_str()));
|
||||
EXPECT_TRUE(::RemoveDirectoryA(dir_path.c_str()));
|
||||
}
|
||||
|
||||
TYPED_TEST(winfsp_test, winfsp_test,
|
||||
rename_dir_fails_directory_is_not_empty_and_replace_is_true) {
|
||||
if (this->current_provider == provider_type::s3) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto dir_path{
|
||||
utils::path::combine(this->mount_location, {"test_dir_4"}),
|
||||
};
|
||||
auto dir_path2{
|
||||
utils::path::combine(this->mount_location, {"test_dir2_4"}),
|
||||
};
|
||||
auto file_path{
|
||||
utils::path::combine(dir_path, {"test_file_4"}),
|
||||
};
|
||||
|
||||
ASSERT_TRUE(::CreateDirectoryA(dir_path.c_str(), nullptr));
|
||||
|
||||
auto handle = ::CreateFileA(file_path.c_str(), GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
|
||||
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
ASSERT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
::CloseHandle(handle);
|
||||
|
||||
EXPECT_FALSE(::MoveFileExA(dir_path.c_str(), dir_path2.c_str(),
|
||||
MOVEFILE_REPLACE_EXISTING));
|
||||
EXPECT_EQ(ERROR_ACCESS_DENIED, ::GetLastError());
|
||||
|
||||
EXPECT_TRUE(::DeleteFileA(file_path.c_str()));
|
||||
EXPECT_TRUE(::RemoveDirectoryA(dir_path.c_str()));
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif // defined(_WIN32)
|
||||
|
@ -31,6 +31,7 @@
|
||||
// TODO revisit delete_access_test
|
||||
// TODO revisit getfileattr_test
|
||||
// TODO revisit delete_ex_test
|
||||
// TODO revisit rename_backslash_dotest
|
||||
|
||||
//
|
||||
// Implemented test cases based on WinFsp tests:
|
||||
|
Loading…
x
Reference in New Issue
Block a user