winfsp unit tests and fixes

This commit is contained in:
Scott E. Graves 2024-11-08 14:35:55 -06:00
parent ab9765582a
commit a9125196ce

View File

@ -68,10 +68,10 @@ static void test_file(auto &&file_path, auto &&flags) {
EXPECT_TRUE(::ReadFile(handle, read_buffer.data(), read_buffer.size(),
&bytes_read, nullptr));
// ASSERT(BytesPerSector == BytesTransferred);
// ASSERT(FilePointer + BytesTransferred ==
// SetFilePointer(Handle, 0, 0, FILE_CURRENT));
// ASSERT(0 == memcmp(Buffer[0], Buffer[1], BytesTransferred));
EXPECT_EQ(static_cast<DWORD>(16U), bytes_read);
EXPECT_EQ(pointer + bytes_read, ::SetFilePointer(handle, 0, 0, FILE_CURRENT));
EXPECT_EQ(0,
std::memcmp(write_buffer.data(), read_buffer.data(), bytes_read));
//
// FilePointer = SetFilePointer(Handle, 2 * BytesPerSector, 0, FILE_BEGIN);
// ASSERT(2 * BytesPerSector == FilePointer);
@ -197,12 +197,26 @@ static void test_file(auto &&file_path, auto &&flags) {
ASSERT_EQ(ERROR_FILE_NOT_FOUND, ::GetLastError());
}
TYPED_TEST(winfsp_test, rdrw_can_read_and_write_file_no_cache) {
TYPED_TEST(winfsp_test, rdrw_can_read_and_write_file_no_flags) {
auto file_path{
utils::path::combine(this->mount_location, {"test_file_5"}),
};
test_file(file_path, 0U);
}
TYPED_TEST(winfsp_test, rdrw_can_read_and_write_file_no_buffering) {
auto file_path{
utils::path::combine(this->mount_location, {"test_file_5"}),
};
test_file(file_path, FILE_FLAG_NO_BUFFERING);
}
TYPED_TEST(winfsp_test, rdrw_can_read_and_write_file_write_through) {
auto file_path{
utils::path::combine(this->mount_location, {"test_file_5"}),
};
test_file(file_path, FILE_FLAG_WRITE_THROUGH);
}
} // namespace repertory
#endif // defined(_WIN32)