From f5993d472cec398c3b980d03dbe466631044cad3 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 4 Nov 2024 14:17:59 -0600 Subject: [PATCH] winfsp unit tests and fixes --- .cspell/words.txt | 1 + .../src/winfsp_drive_info_test.cpp | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/.cspell/words.txt b/.cspell/words.txt index 3214d34a..e3694394 100644 --- a/.cspell/words.txt +++ b/.cspell/words.txt @@ -154,6 +154,7 @@ oleaut32 openal_version openssldir pkgconfig +plarge_integer plex project_enable_fontconfig project_enable_gtkmm diff --git a/repertory/repertory_test/src/winfsp_drive_info_test.cpp b/repertory/repertory_test/src/winfsp_drive_info_test.cpp index 13d5d985..9f968bca 100644 --- a/repertory/repertory_test/src/winfsp_drive_info_test.cpp +++ b/repertory/repertory_test/src/winfsp_drive_info_test.cpp @@ -69,13 +69,16 @@ TYPED_TEST(winfsp_test, info_can_get_basic_info) { EXPECT_TRUE(::GetFileInformationByHandleEx(handle, FileBasicInfo, &basic_info, sizeof basic_info)); EXPECT_EQ(FILE_ATTRIBUTE_ARCHIVE, basic_info.FileAttributes); + EXPECT_LE(time_low, basic_info.CreationTime.QuadPart); EXPECT_GT(time_high, basic_info.CreationTime.QuadPart); EXPECT_LE(time_low, basic_info.LastAccessTime.QuadPart); EXPECT_GT(time_high, basic_info.LastAccessTime.QuadPart); + EXPECT_LE(time_low, basic_info.LastWriteTime.QuadPart); EXPECT_GT(time_high, basic_info.LastWriteTime.QuadPart); + EXPECT_LE(time_low, basic_info.ChangeTime.QuadPart); EXPECT_GT(time_high, basic_info.ChangeTime.QuadPart); @@ -133,6 +136,43 @@ TYPED_TEST(winfsp_test, info_can_get_file_name_info) { ::CloseHandle(handle); } + +TYPED_TEST(winfsp_test, info_can_get_file_info) { + auto time_low = ((PLARGE_INTEGER)&file_time)->QuadPart; + auto time_high = time_low + 10000 * 10000 /* 10 seconds */; + + auto file_path{ + utils::path::combine(this->mount_location, {"test_file_2"}), + }; + auto handle = + ::CreateFileA(file_path.c_str(), GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, 0); + ASSERT_NE(INVALID_HANDLE_VALUE, handle); + + BY_HANDLE_FILE_INFORMATION file_info{}; + EXPECT_TRUE(::GetFileInformationByHandle(handle, &file_info)); + + EXPECT_LE(time_low, file_info.ftCreationTime.QuadPart); + EXPECT_GT(time_high, file_info.ftCreationTime.QuadPart); + + EXPECT_LE(time_low, file_info.ftLastAccessTime.QuadPart); + EXPECT_GT(time_high, file_info.ftLastAccessTime.QuadPart); + + EXPECT_LE(time_low, file_info.ftLastWriteTime.QuadPart); + EXPECT_GT(time_high, file_info.ftLastWriteTime.QuadPart); + + EXPECT_EQ(0U, file_info.nFileSizeHigh); + EXPECT_EQ(0U, file_info.nFileSizeLow); + + EXPECT_EQ(1U, file_info.nNumberOfLinks); + + EXPECT_EQ(FILE_ATTRIBUTE_ARCHIVE, file_info.dwFileAttributes); + + EXPECT_EQ(0U, file_info.dwVolumeSerialNumber) + + ::CloseHandle(handle); +} } // namespace repertory #endif // defined(_WIN32)