continue refactor drive tests
This commit is contained in:
		| @@ -151,11 +151,9 @@ protected: | |||||||
|   } |   } | ||||||
|  |  | ||||||
| public: | public: | ||||||
|   static auto create_file_and_test(std::string name) -> std::string { |   static auto create_file_and_test(std::string &file_name) -> std::string { | ||||||
|     auto file_path = |     file_name += std::to_string(++idx); | ||||||
|         utils::path::combine(mount_location, { |     auto file_path = utils::path::combine(mount_location, {file_name}); | ||||||
|                                                  name + std::to_string(++idx), |  | ||||||
|                                              }); |  | ||||||
|  |  | ||||||
|     auto fd = |     auto fd = | ||||||
|         open(file_path.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP); |         open(file_path.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP); | ||||||
| @@ -174,11 +172,10 @@ public: | |||||||
|     return file_path; |     return file_path; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static auto create_root_file(std::string name) -> std::string { |   static auto create_root_file(std::string &file_name) -> std::string { | ||||||
|     auto file_path = create_file_and_test(name); |     auto file_path = create_file_and_test(file_name); | ||||||
|  |     auto api_path = utils::path::create_api_path(file_name); | ||||||
|  |  | ||||||
|     auto api_path = |  | ||||||
|         utils::path::create_api_path(utils::path::strip_to_filename(file_path)); |  | ||||||
|     provider->set_item_meta(api_path, { |     provider->set_item_meta(api_path, { | ||||||
|                                           {META_UID, "0"}, |                                           {META_UID, "0"}, | ||||||
|                                           {META_GID, "0"}, |                                           {META_GID, "0"}, | ||||||
| @@ -213,16 +210,9 @@ public: | |||||||
|     EXPECT_TRUE(unmounted); |     EXPECT_TRUE(unmounted); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static void unlink_file_and_test(const std::string &file_path) { |   static void unlink_file_and_test(std::string_view file_path) { | ||||||
|     int ret = 0; |     EXPECT_TRUE(utils::file::file(file_path).remove()); | ||||||
|     for (auto i = 0; ((ret = unlink(file_path.c_str())) != 0) && (i < 20); |     EXPECT_FALSE(utils::file::file(file_path).exists()); | ||||||
|          i++) { |  | ||||||
|       std::this_thread::sleep_for(100ms); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     EXPECT_EQ(0, ret); |  | ||||||
|  |  | ||||||
|     std::this_thread::sleep_for(SLEEP_SECONDS); |  | ||||||
|     EXPECT_FALSE(utils::file::directory(file_path).exists()); |     EXPECT_FALSE(utils::file::directory(file_path).exists()); | ||||||
|     EXPECT_FALSE(utils::file::file(file_path).exists()); |     EXPECT_FALSE(utils::file::file(file_path).exists()); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -29,10 +29,10 @@ | |||||||
| #include "comm/curl/curl_comm.hpp" | #include "comm/curl/curl_comm.hpp" | ||||||
| #include "drives/winfsp/winfsp_drive.hpp" | #include "drives/winfsp/winfsp_drive.hpp" | ||||||
| #include "platform/platform.hpp" | #include "platform/platform.hpp" | ||||||
|  | #include "providers/i_provider.hpp" | ||||||
| #include "providers/s3/s3_provider.hpp" | #include "providers/s3/s3_provider.hpp" | ||||||
| #include "providers/sia/sia_provider.hpp" | #include "providers/sia/sia_provider.hpp" | ||||||
| #include "types/repertory.hpp" | #include "types/repertory.hpp" | ||||||
| #include "utils/event_capture.hpp" |  | ||||||
| #include "utils/file_utils.hpp" | #include "utils/file_utils.hpp" | ||||||
| #include "utils/path.hpp" | #include "utils/path.hpp" | ||||||
|  |  | ||||||
| @@ -153,12 +153,37 @@ protected: | |||||||
|   } |   } | ||||||
|  |  | ||||||
| public: | public: | ||||||
|   static void delete_file_and_test(const std::string &file) { |   [[nodiscard]] static auto create_file_and_test(std::string &file_name) | ||||||
|     event_capture ec({"file_removed"}); |       -> std::string { | ||||||
|     EXPECT_TRUE(utils::file::file(file).remove()); |     file_name += std::to_string(++idx); | ||||||
|     ec.wait_for_empty(); |     auto api_path = utils::path::create_api_path(file_name); | ||||||
|  |     auto file_path = utils::path::combine(mount_location, {file_name}); | ||||||
|  |  | ||||||
|     EXPECT_FALSE(utils::file::file(file).exists()); |     auto handle = | ||||||
|  |         ::CreateFileA(file_path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, | ||||||
|  |                       CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); | ||||||
|  |     EXPECT_NE(INVALID_HANDLE_VALUE, handle); | ||||||
|  |     EXPECT_TRUE(::CloseHandle(handle)); | ||||||
|  |  | ||||||
|  |     EXPECT_TRUE(utils::file::file(file_path).exists()); | ||||||
|  |  | ||||||
|  |     auto opt_size = utils::file::file(file_path).size(); | ||||||
|  |     EXPECT_TRUE(opt_size.has_value()); | ||||||
|  |     EXPECT_EQ(0, opt_size.value()); | ||||||
|  |  | ||||||
|  |     std::string attr; | ||||||
|  |     EXPECT_EQ(api_error::success, | ||||||
|  |               provider->get_item_meta(api_path, META_ATTRIBUTES, attr)); | ||||||
|  |     EXPECT_EQ(FILE_ATTRIBUTE_NORMAL, utils::string::to_uint32(attr)); | ||||||
|  |  | ||||||
|  |     return file_path; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   static void delete_file_and_test(std::string_view file_path) { | ||||||
|  |     EXPECT_TRUE(utils::file::file(file_path).remove()); | ||||||
|  |     EXPECT_FALSE(utils::file::file(file_path).exists()); | ||||||
|  |     EXPECT_FALSE(utils::file::directory(file_path).exists()); | ||||||
|  |     EXPECT_FALSE(utils::file::file(file_path).exists()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static void execute_mount(auto &&drive_args) { |   static void execute_mount(auto &&drive_args) { | ||||||
|   | |||||||
| @@ -518,7 +518,9 @@ namespace repertory { | |||||||
| TYPED_TEST_CASE(fuse_test, fuse_provider_types); | TYPED_TEST_CASE(fuse_test, fuse_provider_types); | ||||||
|  |  | ||||||
| TYPED_TEST(fuse_test, can_chmod_if_owner) { | TYPED_TEST(fuse_test, can_chmod_if_owner) { | ||||||
|   auto file_path = this->create_file_and_test("chmod_test"); |   std::string file_name{"chmod_test"}; | ||||||
|  |   auto file_path = this->create_file_and_test(file_name); | ||||||
|  |  | ||||||
|   EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR)); |   EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR)); | ||||||
|   std::this_thread::sleep_for(SLEEP_SECONDS); |   std::this_thread::sleep_for(SLEEP_SECONDS); | ||||||
|  |  | ||||||
| @@ -531,7 +533,9 @@ TYPED_TEST(fuse_test, can_chmod_if_owner) { | |||||||
| } | } | ||||||
|  |  | ||||||
| TYPED_TEST(fuse_test, can_not_chmod_if_not_owner) { | TYPED_TEST(fuse_test, can_not_chmod_if_not_owner) { | ||||||
|   auto file_path = this->create_root_file("chmod_test"); |   std::string file_name{"chmod_test"}; | ||||||
|  |   auto file_path = this->create_root_file(file_name); | ||||||
|  |  | ||||||
|   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR)); |   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR)); | ||||||
|   EXPECT_EQ(EPERM, errno); |   EXPECT_EQ(EPERM, errno); | ||||||
|  |  | ||||||
| @@ -539,7 +543,9 @@ TYPED_TEST(fuse_test, can_not_chmod_if_not_owner) { | |||||||
| } | } | ||||||
|  |  | ||||||
| TYPED_TEST(fuse_test, can_not_chmod_setgid_if_not_root) { | TYPED_TEST(fuse_test, can_not_chmod_setgid_if_not_root) { | ||||||
|   auto file_path = this->create_file_and_test("chown_test"); |   std::string file_name{"chmod_test"}; | ||||||
|  |   auto file_path = this->create_file_and_test(file_name); | ||||||
|  |  | ||||||
|   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_IGID)); |   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_IGID)); | ||||||
|   EXPECT_EQ(EPERM, errno); |   EXPECT_EQ(EPERM, errno); | ||||||
|  |  | ||||||
| @@ -547,7 +553,9 @@ TYPED_TEST(fuse_test, can_not_chmod_setgid_if_not_root) { | |||||||
| } | } | ||||||
|  |  | ||||||
| TYPED_TEST(fuse_test, can_not_chmod_setuid_if_not_root) { | TYPED_TEST(fuse_test, can_not_chmod_setuid_if_not_root) { | ||||||
|   auto file_path = this->create_file_and_test("chown_test"); |   std::string file_name{"chmod_test"}; | ||||||
|  |   auto file_path = this->create_file_and_test(file_name); | ||||||
|  |  | ||||||
|   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_IUID)); |   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_IUID)); | ||||||
|   EXPECT_EQ(EPERM, errno); |   EXPECT_EQ(EPERM, errno); | ||||||
|  |  | ||||||
| @@ -555,7 +563,9 @@ TYPED_TEST(fuse_test, can_not_chmod_setuid_if_not_root) { | |||||||
| } | } | ||||||
|  |  | ||||||
| TYPED_TEST(fuse_test, can_not_chmod_set_sticky_if_not_root) { | TYPED_TEST(fuse_test, can_not_chmod_set_sticky_if_not_root) { | ||||||
|   auto file_path = this->create_file_and_test("chown_test"); |   std::string file_name{"chown_test"}; | ||||||
|  |   auto file_path = this->create_file_and_test(file_name); | ||||||
|  |  | ||||||
|   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISVTX)); |   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISVTX)); | ||||||
|   EXPECT_EQ(EPERM, errno); |   EXPECT_EQ(EPERM, errno); | ||||||
|  |  | ||||||
| @@ -563,7 +573,8 @@ TYPED_TEST(fuse_test, can_not_chmod_set_sticky_if_not_root) { | |||||||
| } | } | ||||||
|  |  | ||||||
| TYPED_TEST(fuse_test, can_chown_group_if_owner_and_a_member_of_the_group) { | TYPED_TEST(fuse_test, can_chown_group_if_owner_and_a_member_of_the_group) { | ||||||
|   auto file_path = this->create_file_and_test("chown_test"); |   std::string file_name{"chown_test"}; | ||||||
|  |   auto file_path = this->create_file_and_test(file_name); | ||||||
|  |  | ||||||
|   struct stat64 unix_st{}; |   struct stat64 unix_st{}; | ||||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); |   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||||
| @@ -581,7 +592,8 @@ TYPED_TEST(fuse_test, can_chown_group_if_owner_and_a_member_of_the_group) { | |||||||
|  |  | ||||||
| TYPED_TEST(fuse_test, | TYPED_TEST(fuse_test, | ||||||
|            can_not_chown_group_if_owner_but_not_a_member_of_the_group) { |            can_not_chown_group_if_owner_but_not_a_member_of_the_group) { | ||||||
|   auto file_path = this->create_file_and_test("chown_test"); |   std::string file_name{"chown_test"}; | ||||||
|  |   auto file_path = this->create_file_and_test(file_name); | ||||||
|  |  | ||||||
|   struct stat64 unix_st{}; |   struct stat64 unix_st{}; | ||||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); |   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||||
| @@ -598,7 +610,8 @@ TYPED_TEST(fuse_test, | |||||||
| } | } | ||||||
|  |  | ||||||
| TYPED_TEST(fuse_test, can_not_chown_group_if_not_the_owner) { | TYPED_TEST(fuse_test, can_not_chown_group_if_not_the_owner) { | ||||||
|   auto file_path = this->create_root_file("chown_test"); |   std::string file_name{"chown_test"}; | ||||||
|  |   auto file_path = this->create_root_file(file_name); | ||||||
|  |  | ||||||
|   struct stat64 unix_st{}; |   struct stat64 unix_st{}; | ||||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); |   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||||
| @@ -615,7 +628,8 @@ TYPED_TEST(fuse_test, can_not_chown_group_if_not_the_owner) { | |||||||
| } | } | ||||||
|  |  | ||||||
| TYPED_TEST(fuse_test, can_not_chown_user_if_not_root) { | TYPED_TEST(fuse_test, can_not_chown_user_if_not_root) { | ||||||
|   auto file_path = this->create_file_and_test("chown_test"); |   std::string file_name{"chown_test"}; | ||||||
|  |   auto file_path = this->create_file_and_test(file_name); | ||||||
|  |  | ||||||
|   struct stat64 unix_st{}; |   struct stat64 unix_st{}; | ||||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); |   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||||
|   | |||||||
| @@ -19,101 +19,11 @@ | |||||||
|   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|   SOFTWARE. |   SOFTWARE. | ||||||
| */ | */ | ||||||
| #if 0 |  | ||||||
| #if defined(_WIN32) | #if defined(_WIN32) | ||||||
|  |  | ||||||
| #include "fixtures/winfsp_fixture.hpp" | #include "fixtures/winfsp_fixture.hpp" | ||||||
|  |  | ||||||
| namespace repertory { | namespace repertory { | ||||||
| // void launch_app(std::string cmd) { |  | ||||||
| //   PROCESS_INFORMATION pi{}; |  | ||||||
| //   STARTUPINFO si{}; |  | ||||||
| //   si.cb = sizeof(si); |  | ||||||
| // |  | ||||||
| //   if (!::CreateProcessA(nullptr, (LPSTR)cmd.c_str(), nullptr, nullptr, FALSE, |  | ||||||
| //                         CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP, nullptr, |  | ||||||
| //                         nullptr, &si, &pi)) { |  | ||||||
| //     throw std::runtime_error("CreateProcess failed (" + |  | ||||||
| //                              std::to_string(::GetLastError()) + ")"); |  | ||||||
| //   } |  | ||||||
| // |  | ||||||
| //   ::WaitForSingleObject(pi.hProcess, INFINITE); |  | ||||||
| //   DWORD code{}; |  | ||||||
| //   ::GetExitCodeProcess(pi.hProcess, &code); |  | ||||||
| // |  | ||||||
| //   ::CloseHandle(pi.hProcess); |  | ||||||
| //   ::CloseHandle(pi.hThread); |  | ||||||
| //   EXPECT_EQ(0, code); |  | ||||||
| // } |  | ||||||
| // |  | ||||||
| // E_SIMPLE1(test_begin, info, false, std::string, test_name, TN, E_FROM_STRING); |  | ||||||
| // #define TEST_HEADER(func)                                                      \ |  | ||||||
| //   event_system::instance().raise<test_begin>(                                  \ |  | ||||||
| //       std::string(func) +                                                      \ |  | ||||||
| //       "\r\n***********************\r\n***********************") |  | ||||||
| // |  | ||||||
| // static auto mount_setup(std::string &mount_point) { |  | ||||||
| //   mount_point = "U:"; |  | ||||||
| //   return std::vector<std::string>({"unittests", "-f", mount_point}); |  | ||||||
| // } |  | ||||||
| // |  | ||||||
| // static void execute_mount(winfsp_test *test, |  | ||||||
| //                           const std::vector<std::string> &drive_args, |  | ||||||
| //                           std::thread &th) { |  | ||||||
| //   ASSERT_EQ(0, test->drive->mount(drive_args)); |  | ||||||
| //   th.join(); |  | ||||||
| // } |  | ||||||
| // |  | ||||||
| // static void unmount(winfsp_test *test, const std::string &mount_point) { |  | ||||||
| //   test->drive->shutdown(); |  | ||||||
| //   auto mounted = utils::file::directory(mount_point).exists(); |  | ||||||
| //   for (auto i = 0; mounted && (i < 50); i++) { |  | ||||||
| //     std::this_thread::sleep_for(100ms); |  | ||||||
| //     mounted = utils::file::directory(mount_point).exists(); |  | ||||||
| //   } |  | ||||||
| //   EXPECT_FALSE(utils::file::directory(mount_point).exists()); |  | ||||||
| // } |  | ||||||
| // |  | ||||||
| // static void root_creation_test(const std::string &mount_point) { |  | ||||||
| //   TEST_HEADER(__FUNCTION__); |  | ||||||
| //   WIN32_FILE_ATTRIBUTE_DATA ad{}; |  | ||||||
| //   EXPECT_TRUE( |  | ||||||
| //       ::GetFileAttributesEx(mount_point.c_str(), GetFileExInfoStandard, &ad)); |  | ||||||
| //   EXPECT_EQ(FILE_ATTRIBUTE_DIRECTORY, ad.dwFileAttributes); |  | ||||||
| //   EXPECT_EQ(0, ad.nFileSizeHigh); |  | ||||||
| //   EXPECT_EQ(0, ad.nFileSizeLow); |  | ||||||
| // } |  | ||||||
| // |  | ||||||
| // static auto create_test(winfsp_test *test, const std::string &mount_point) { |  | ||||||
| //   TEST_HEADER(__FUNCTION__); |  | ||||||
| // |  | ||||||
| //   auto file = utils::path::combine(mount_point, {{"test_create.txt"}}); |  | ||||||
| //   auto handle = ::CreateFileA(&file[0], GENERIC_READ, FILE_SHARE_READ, nullptr, |  | ||||||
| //                               CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); |  | ||||||
| //   EXPECT_NE(INVALID_HANDLE_VALUE, handle); |  | ||||||
| //   EXPECT_TRUE(::CloseHandle(handle)); |  | ||||||
| // |  | ||||||
| //   EXPECT_TRUE(utils::file::file(file).exists()); |  | ||||||
| // |  | ||||||
| //   auto opt_size = utils::file::file(file).size(); |  | ||||||
| //   EXPECT_TRUE(opt_size.has_value()); |  | ||||||
| //   EXPECT_EQ(0, opt_size.value()); |  | ||||||
| // |  | ||||||
| //   std::string attr; |  | ||||||
| //   EXPECT_EQ(api_error::success, test->provider->get_item_meta( |  | ||||||
| //                                     "/test_create.txt", META_ATTRIBUTES, attr)); |  | ||||||
| //   EXPECT_EQ(FILE_ATTRIBUTE_NORMAL, utils::string::to_uint32(attr)); |  | ||||||
| // |  | ||||||
| //   return file; |  | ||||||
| // } |  | ||||||
| // |  | ||||||
| // static void delete_file_test(const std::string &file) { |  | ||||||
| //   TEST_HEADER(__FUNCTION__); |  | ||||||
| //   event_capture ec({"file_removed"}); |  | ||||||
| //   EXPECT_TRUE(utils::file::file(file).remove()); |  | ||||||
| //   EXPECT_FALSE(utils::file::file(file).exists()); |  | ||||||
| // } |  | ||||||
| // |  | ||||||
| // static void create_directory_test(const std::string &directory) { | // static void create_directory_test(const std::string &directory) { | ||||||
| //   TEST_HEADER(__FUNCTION__); | //   TEST_HEADER(__FUNCTION__); | ||||||
| // | // | ||||||
| @@ -184,7 +94,8 @@ namespace repertory { | |||||||
| //                              const std::string &mount_point) { | //                              const std::string &mount_point) { | ||||||
| //   TEST_HEADER(__FUNCTION__); | //   TEST_HEADER(__FUNCTION__); | ||||||
| //   const auto file = utils::path::combine(mount_point, {"rename_file.txt"}); | //   const auto file = utils::path::combine(mount_point, {"rename_file.txt"}); | ||||||
| //   auto handle = ::CreateFileA(&file[0], GENERIC_READ, FILE_SHARE_READ, nullptr, | //   auto handle = ::CreateFileA(&file[0], GENERIC_READ, FILE_SHARE_READ, | ||||||
|  | //   nullptr, | ||||||
| //                               CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); | //                               CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); | ||||||
| //   EXPECT_NE(INVALID_HANDLE_VALUE, handle); | //   EXPECT_NE(INVALID_HANDLE_VALUE, handle); | ||||||
| //   EXPECT_TRUE(::CloseHandle(handle)); | //   EXPECT_TRUE(::CloseHandle(handle)); | ||||||
| @@ -224,7 +135,8 @@ namespace repertory { | |||||||
| //   std::string directory = "rename_dir"; | //   std::string directory = "rename_dir"; | ||||||
| //   const auto full_directory = utils::path::combine(mount_point, {directory}); | //   const auto full_directory = utils::path::combine(mount_point, {directory}); | ||||||
| //   std::string directory2 = "rename_dir2"; | //   std::string directory2 = "rename_dir2"; | ||||||
| //   const auto full_directory2 = utils::path::combine(mount_point, {directory2}); | //   const auto full_directory2 = utils::path::combine(mount_point, | ||||||
|  | //   {directory2}); | ||||||
| // | // | ||||||
| //   EXPECT_FALSE(::PathIsDirectory(&full_directory[0])); | //   EXPECT_FALSE(::PathIsDirectory(&full_directory[0])); | ||||||
| //   EXPECT_TRUE(::CreateDirectoryA(&full_directory[0], nullptr)); | //   EXPECT_TRUE(::CreateDirectoryA(&full_directory[0], nullptr)); | ||||||
| @@ -282,10 +194,12 @@ namespace repertory { | |||||||
| //   EXPECT_EQ(0, memcmp(&fbi, &fbi2, sizeof(FILE_BASIC_INFO))); | //   EXPECT_EQ(0, memcmp(&fbi, &fbi2, sizeof(FILE_BASIC_INFO))); | ||||||
| // | // | ||||||
| //   std::cout << fbi.FileAttributes << " " << fbi.ChangeTime.QuadPart << " " | //   std::cout << fbi.FileAttributes << " " << fbi.ChangeTime.QuadPart << " " | ||||||
| //             << fbi.CreationTime.QuadPart << " " << fbi.LastAccessTime.QuadPart | //             << fbi.CreationTime.QuadPart << " " << | ||||||
|  | //             fbi.LastAccessTime.QuadPart | ||||||
| //             << " " << fbi.LastWriteTime.QuadPart << std::endl; | //             << " " << fbi.LastWriteTime.QuadPart << std::endl; | ||||||
| //   std::cout << fbi2.FileAttributes << " " << fbi2.ChangeTime.QuadPart << " " | //   std::cout << fbi2.FileAttributes << " " << fbi2.ChangeTime.QuadPart << " " | ||||||
| //             << fbi2.CreationTime.QuadPart << " " << fbi2.LastAccessTime.QuadPart | //             << fbi2.CreationTime.QuadPart << " " << | ||||||
|  | //             fbi2.LastAccessTime.QuadPart | ||||||
| //             << " " << fbi2.LastWriteTime.QuadPart << std::endl; | //             << " " << fbi2.LastWriteTime.QuadPart << std::endl; | ||||||
| // | // | ||||||
| //   EXPECT_TRUE(::CloseHandle(handle)); | //   EXPECT_TRUE(::CloseHandle(handle)); | ||||||
| @@ -302,7 +216,8 @@ namespace repertory { | |||||||
| //   if (handle != INVALID_HANDLE_VALUE) { | //   if (handle != INVALID_HANDLE_VALUE) { | ||||||
| //     const std::string data = "0123456789"; | //     const std::string data = "0123456789"; | ||||||
| //     DWORD bytes_written = 0; | //     DWORD bytes_written = 0; | ||||||
| //     EXPECT_TRUE(::WriteFile(handle, &data[0], static_cast<DWORD>(data.size()), | //     EXPECT_TRUE(::WriteFile(handle, &data[0], | ||||||
|  | //     static_cast<DWORD>(data.size()), | ||||||
| //                             &bytes_written, nullptr)); | //                             &bytes_written, nullptr)); | ||||||
| //     EXPECT_EQ(10, bytes_written); | //     EXPECT_EQ(10, bytes_written); | ||||||
| //     EXPECT_TRUE(::CloseHandle(handle)); | //     EXPECT_TRUE(::CloseHandle(handle)); | ||||||
| @@ -380,34 +295,18 @@ TYPED_TEST_CASE(winfsp_test, winfsp_provider_types); | |||||||
|  |  | ||||||
| TYPED_TEST(winfsp_test, root_is_created) { | TYPED_TEST(winfsp_test, root_is_created) { | ||||||
|   WIN32_FILE_ATTRIBUTE_DATA ad{}; |   WIN32_FILE_ATTRIBUTE_DATA ad{}; | ||||||
|   ASSERT_TRUE( |   ASSERT_TRUE(::GetFileAttributesEx(mount_location.c_str(), | ||||||
|       ::GetFileAttributesEx(mount_location.c_str(), GetFileExInfoStandard, &ad)); |                                     GetFileExInfoStandard, &ad)); | ||||||
|   EXPECT_EQ(FILE_ATTRIBUTE_DIRECTORY, ad.dwFileAttributes); |   EXPECT_EQ(FILE_ATTRIBUTE_DIRECTORY, ad.dwFileAttributes); | ||||||
|   EXPECT_EQ(0, ad.nFileSizeHigh); |   EXPECT_EQ(0, ad.nFileSizeHigh); | ||||||
|   EXPECT_EQ(0, ad.nFileSizeLow); |   EXPECT_EQ(0, ad.nFileSizeLow); | ||||||
| } | } | ||||||
|  |  | ||||||
| TYPED_TEST(winfsp_test, can_create_and_delete_file) { | TYPED_TEST(winfsp_test, can_create_and_delete_file) { | ||||||
|   auto file = utils::path::combine(mount_location, {"test_create.txt"}); |   std::string file_name{"test_create_and_delete"}; | ||||||
|   auto handle = ::CreateFileA(file.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, |   auto file_path = create_file_and_test(file_name); | ||||||
|                               CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); |   delete_file_and_test(file_path); | ||||||
|   EXPECT_NE(INVALID_HANDLE_VALUE, handle); |  | ||||||
|   EXPECT_TRUE(::CloseHandle(handle)); |  | ||||||
|  |  | ||||||
|   EXPECT_TRUE(utils::file::file(file).exists()); |  | ||||||
|  |  | ||||||
|   auto opt_size = utils::file::file(file).size(); |  | ||||||
|   EXPECT_TRUE(opt_size.has_value()); |  | ||||||
|   EXPECT_EQ(0, opt_size.value()); |  | ||||||
|  |  | ||||||
|   std::string attr; |  | ||||||
|   EXPECT_EQ(api_error::success, provider->get_item_meta( |  | ||||||
|                                     "/test_create.txt", META_ATTRIBUTES, attr)); |  | ||||||
|   EXPECT_EQ(FILE_ATTRIBUTE_NORMAL, utils::string::to_uint32(attr)); |  | ||||||
|  |  | ||||||
|   delete_file_and_test(file); |  | ||||||
| } | } | ||||||
| } // namespace repertory | } // namespace repertory | ||||||
|  |  | ||||||
| #endif // defined(_WIN32) | #endif // defined(_WIN32) | ||||||
| #endif // 0 |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user