From a9125196cead2e4e978d17e918f95090d801d90e Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 8 Nov 2024 14:35:55 -0600 Subject: [PATCH] winfsp unit tests and fixes --- .../src/winfsp_drive_read_write_test.cpp | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/repertory/repertory_test/src/winfsp_drive_read_write_test.cpp b/repertory/repertory_test/src/winfsp_drive_read_write_test.cpp index e6ce4e93..f3a07912 100644 --- a/repertory/repertory_test/src/winfsp_drive_read_write_test.cpp +++ b/repertory/repertory_test/src/winfsp_drive_read_write_test.cpp @@ -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(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)