3 Commits

Author SHA1 Message Date
f5993d472c winfsp unit tests and fixes
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
2024-11-04 14:17:59 -06:00
0d01862441 winfsp unit tests and fixes 2024-11-04 13:54:04 -06:00
ec2ff87ac7 winfsp unit tests and fixes 2024-11-04 13:43:59 -06:00
2 changed files with 71 additions and 0 deletions

View File

@ -154,6 +154,7 @@ oleaut32
openal_version
openssldir
pkgconfig
plarge_integer
plex
project_enable_fontconfig
project_enable_gtkmm

View File

@ -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);
@ -103,6 +106,73 @@ TYPED_TEST(winfsp_test, info_can_get_standard_info) {
::CloseHandle(handle);
}
TYPED_TEST(winfsp_test, info_can_get_file_name_info) {
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);
std::array<std::uint8_t, sizeof(FILE_NAME_INFO) + MAX_PATH> name_info{};
EXPECT_TRUE(
::GetFileInformationByHandleEx(handle, FileNameInfo, name_info.data(),
static_cast<DWORD>(name_info.size())));
auto *info = reinterpret_cast<FILE_NAME_INFO *>(name_info.data());
auto expected_name{
std::string{"\\repertory\\"} +
utils::string::to_lower(this->mount_location).at(0U) +
"\\test_file_2",
};
EXPECT_EQ(info->FileNameLength,
static_cast<DWORD>(expected_name.size() * 2U));
EXPECT_STREQ(expected_name.c_str(),
utils::string::to_utf8(info->FileName).c_str());
::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)