2.0.0-rc (#9)
Some checks failed
BlockStorage/repertory_osx/pipeline/head This commit looks good
BlockStorage/repertory_windows/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head There was a failure building this commit
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good
BlockStorage/repertory_osx_builds/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory_osx/pipeline/head This commit looks good
BlockStorage/repertory_windows/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head There was a failure building this commit
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good
BlockStorage/repertory_osx_builds/pipeline/head There was a failure building this commit
### Issues * \#1 \[bug\] Unable to mount S3 due to 'item_not_found' exception * \#2 Require bucket name for S3 mounts * \#3 \[bug\] File size is not being updated in S3 mount * \#4 Upgrade to libfuse-3.x.x * \#5 Switch to renterd for Sia support * \#6 Switch to cpp-httplib to further reduce dependencies * \#7 Remove global_data and calculate used disk space per provider * \#8 Switch to libcurl for S3 mount support ### Changes from v1.x.x * Added read-only encrypt provider * Pass-through mount point that transparently encrypts source data using `XChaCha20-Poly1305` * Added S3 encryption support via `XChaCha20-Poly1305` * Added replay protection to remote mounts * Added support base64 writes in remote FUSE * Created static linked Linux binaries for `amd64` and `aarch64` using `musl-libc` * Removed legacy Sia renter support * Removed Skynet support * Fixed multiple remote mount WinFSP API issues on \*NIX servers * Implemented chunked read and write * Writes for non-cached files are performed in chunks of 8Mib * Removed `repertory-ui` support * Removed `FreeBSD` support * Switched to `libsodium` over `CryptoPP` * Switched to `XChaCha20-Poly1305` for remote mounts * Updated `GoogleTest` to v1.14.0 * Updated `JSON for Modern C++` to v3.11.2 * Updated `OpenSSL` to v1.1.1w * Updated `RocksDB` to v8.5.3 * Updated `WinFSP` to 2023 * Updated `boost` to v1.78.0 * Updated `cURL` to v8.3.0 * Updated `zlib` to v1.3 * Use `upload_manager` for all providers * Adds a delay to uploads to prevent excessive API calls * Supports re-upload after mount restart for incomplete uploads * NOTE: Uploads for all providers are full file (no resume support) * Multipart upload support is planned for S3 Reviewed-on: #9
This commit is contained in:
@@ -1,27 +1,32 @@
|
||||
/*
|
||||
Copyright <2018-2022> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
||||
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#if _WIN32
|
||||
|
||||
#include "fixtures/winfsp_fixture.hpp"
|
||||
#include "utils/event_capture.hpp"
|
||||
#include "test_common.hpp"
|
||||
|
||||
#include "fixtures/winfsp_fixture.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/event_capture.hpp"
|
||||
|
||||
namespace repertory {
|
||||
void launch_app(std::string cmd) {
|
||||
PROCESS_INFORMATION pi{};
|
||||
@@ -29,9 +34,10 @@ void launch_app(std::string cmd) {
|
||||
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()) + ")");
|
||||
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);
|
||||
@@ -44,70 +50,25 @@ void launch_app(std::string cmd) {
|
||||
}
|
||||
|
||||
E_SIMPLE1(test_begin, normal, false, std::string, test_name, TN, E_STRING);
|
||||
#define TEST_HEADER(func) \
|
||||
event_system::instance().raise<test_begin>( \
|
||||
std::string(func) + "\r\n***********************\r\n***********************")
|
||||
#define TEST_HEADER(func) \
|
||||
event_system::instance().raise<test_begin>( \
|
||||
std::string(func) + \
|
||||
"\r\n***********************\r\n***********************")
|
||||
|
||||
static auto mount_setup(const std::size_t &idx, winfsp_test *test, std::string &mount_point) {
|
||||
// Mock communicator setup
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/wallet", {}, {}, api_error::success, true);
|
||||
mock_comm.push_return("get", "/renter/dir/",
|
||||
{{"directories", {{{"numfiles", 0}, {"numsubdirs", 0}}}}}, {},
|
||||
api_error::success, true);
|
||||
mock_comm.push_return("get", "/renter/file/", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/dir/autorun.inf", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/dir/.git", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/.git", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/dir/HEAD", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/HEAD", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/autorun.inf", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/dir/AutoRun.inf", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/AutoRun.inf", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/dir/Desktop.ini", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/Desktop.ini", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
json files;
|
||||
files["files"] = std::vector<json>();
|
||||
mock_comm.push_return("get", "/renter/files", files, {}, api_error::success, true);
|
||||
mock_comm.push_return("get", "/renter/prices", {}, {{"message", "offline"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return(
|
||||
"get", "/daemon/version",
|
||||
{{"version", app_config::get_provider_minimum_version(provider_type::sia)}}, {},
|
||||
api_error::success, true);
|
||||
|
||||
// Mount setup
|
||||
mount_point = "U:";
|
||||
return std::vector<std::string>({"unittests", "-f", mount_point});
|
||||
}
|
||||
|
||||
if (idx == 1) {
|
||||
// Mount setup
|
||||
mount_point = "V:";
|
||||
return std::vector<std::string>({"unittests", "-f", mount_point});
|
||||
}
|
||||
static auto mount_setup(std::string &mount_point) {
|
||||
mount_point = "U:";
|
||||
return std::vector<std::string>({"unittests", "-f", mount_point});
|
||||
}
|
||||
|
||||
static void execute_mount(const std::size_t &idx, winfsp_test *test,
|
||||
const std::vector<std::string> &driveArgs, std::thread &th) {
|
||||
ASSERT_EQ(0, std::get<2>(test->provider_tests_[idx])->mount(driveArgs));
|
||||
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(const std::size_t &idx, winfsp_test *test, const std::string &mount_point) {
|
||||
std::get<2>(test->provider_tests_[idx])->shutdown();
|
||||
static void unmount(winfsp_test *test, const std::string &mount_point) {
|
||||
test->drive->shutdown();
|
||||
auto mounted = utils::file::is_directory(mount_point);
|
||||
for (auto i = 0; mounted && (i < 50); i++) {
|
||||
std::this_thread::sleep_for(100ms);
|
||||
@@ -119,31 +80,19 @@ static void unmount(const std::size_t &idx, winfsp_test *test, const std::string
|
||||
static void root_creation_test(const std::string &mount_point) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
WIN32_FILE_ATTRIBUTE_DATA ad{};
|
||||
EXPECT_TRUE(::GetFileAttributesEx(&mount_point[0], GetFileExInfoStandard, &ad));
|
||||
EXPECT_TRUE(
|
||||
::GetFileAttributesEx(&mount_point[0], GetFileExInfoStandard, &ad));
|
||||
EXPECT_EQ(FILE_ATTRIBUTE_DIRECTORY, ad.dwFileAttributes);
|
||||
EXPECT_EQ(0, ad.nFileSizeHigh);
|
||||
EXPECT_EQ(0, ad.nFileSizeLow);
|
||||
}
|
||||
|
||||
static auto create_test(const std::size_t &idx, winfsp_test *test, const std::string &mount_point) {
|
||||
static auto create_test(winfsp_test *test, const std::string &mount_point) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/test_create.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/test_create.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error);
|
||||
mock_comm.push_return("post_params", "/renter/delete/test_create.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error);
|
||||
mock_comm.push_return("post_params", "/renter/upload/test_create.txt", {}, {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/file/test_create.txt",
|
||||
RENTER_FILE_DATA("test_create.txt", 0), {}, api_error::success, true);
|
||||
}
|
||||
|
||||
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);
|
||||
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));
|
||||
|
||||
@@ -154,157 +103,49 @@ static auto create_test(const std::size_t &idx, winfsp_test *test, const std::st
|
||||
EXPECT_EQ(0, file_size);
|
||||
|
||||
std::string attr;
|
||||
EXPECT_EQ(api_error::success, std::get<1>(test->provider_tests_[idx])
|
||||
->get_item_meta("/test_create.txt", META_ATTRIBUTES, 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));
|
||||
|
||||
event_system::instance().stop();
|
||||
event_system::instance().start();
|
||||
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.remove_return("get", "/renter/dir/test_create.txt");
|
||||
mock_comm.remove_return("post_params", "/renter/delete/test_create.txt");
|
||||
mock_comm.remove_return("post_params", "/renter/upload/test_create.txt");
|
||||
mock_comm.remove_return("get", "/renter/file/test_create.txt");
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
static void delete_file_test(const std::size_t &idx, winfsp_test *test, const std::string &file) {
|
||||
static void delete_file_test(const std::string &file) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/test_create.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/test_create.txt",
|
||||
RENTER_FILE_DATA("test_create.txt", 0), {}, api_error::success);
|
||||
mock_comm.push_return("get", "/renter/file/test_create.txt",
|
||||
RENTER_FILE_DATA("test_create.txt", 0), {}, api_error::success);
|
||||
mock_comm.push_return("get", "/renter/file/test_create.txt",
|
||||
RENTER_FILE_DATA("test_create.txt", 0), {}, api_error::success);
|
||||
mock_comm.push_return("get", "/renter/file/test_create.txt",
|
||||
RENTER_FILE_DATA("test_create.txt", 0), {}, api_error::success);
|
||||
mock_comm.push_return("get", "/renter/file/test_create.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("post_params", "/renter/delete/test_create.txt", {}, {},
|
||||
api_error::success);
|
||||
}
|
||||
{
|
||||
event_capture ec({"file_removed"});
|
||||
EXPECT_TRUE(utils::file::delete_file(file));
|
||||
EXPECT_FALSE(utils::file::is_file(file));
|
||||
event_system::instance().stop();
|
||||
event_system::instance().start();
|
||||
}
|
||||
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.remove_return("post_params", "/renter/delete/test_create.txt");
|
||||
}
|
||||
event_capture ec({"file_removed"});
|
||||
EXPECT_TRUE(utils::file::retry_delete_file(file));
|
||||
EXPECT_FALSE(utils::file::is_file(file));
|
||||
}
|
||||
|
||||
static void create_directory_test(const std::size_t &idx, winfsp_test *test,
|
||||
const std::string &directory) {
|
||||
static void create_directory_test(const std::string &directory) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory.substr(3), {},
|
||||
{{"message", "no file known"}}, api_error::comm_error);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory.substr(3), {},
|
||||
{{"message", "no file known"}}, api_error::comm_error);
|
||||
mock_comm.push_return("get", "/renter/file/" + directory.substr(3), {},
|
||||
{{"message", "no file known"}}, api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory.substr(3),
|
||||
{{"directories", {{{"numfiles", 0}, {"numsubdirs", 0}}}}}, {},
|
||||
api_error::success, true);
|
||||
mock_comm.push_return("post_params", "/renter/dir/" + directory.substr(3), {}, {},
|
||||
api_error::success);
|
||||
}
|
||||
|
||||
EXPECT_FALSE(::PathIsDirectory(&directory[0]));
|
||||
EXPECT_TRUE(::CreateDirectoryA(&directory[0], nullptr));
|
||||
EXPECT_TRUE(::PathIsDirectory(&directory[0]));
|
||||
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.remove_return("get", "/renter/dir/" + directory.substr(3));
|
||||
mock_comm.remove_return("get", "/renter/file/" + directory.substr(3));
|
||||
mock_comm.remove_return("post_params", "/renter/dir/" + directory.substr(3));
|
||||
}
|
||||
}
|
||||
|
||||
static void remove_directory_test(const std::size_t &idx, winfsp_test *test,
|
||||
const std::string &directory) {
|
||||
static void remove_directory_test(const std::string &directory) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory.substr(3),
|
||||
{{"directories", {{{"numfiles", 0}, {"numsubdirs", 0}}}}}, {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory.substr(3),
|
||||
{{"directories", {{{"numfiles", 0}, {"numsubdirs", 0}}}}}, {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory.substr(3),
|
||||
{{"directories", {{{"numfiles", 0}, {"numsubdirs", 0}}}}}, {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory.substr(3),
|
||||
{{"directories", {{{"numfiles", 0}, {"numsubdirs", 0}}}}}, {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("post_params", "/renter/dir/" + directory.substr(3), {}, {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory.substr(3), {},
|
||||
{{"message", "no file known"}}, api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/" + directory.substr(3), {},
|
||||
{{"message", "no file known"}}, api_error::comm_error, true);
|
||||
}
|
||||
|
||||
{
|
||||
event_capture ec({"directory_removed"});
|
||||
EXPECT_TRUE(::PathIsDirectory(&directory[0]));
|
||||
EXPECT_TRUE(::RemoveDirectoryA(&directory[0]));
|
||||
EXPECT_FALSE(::PathIsDirectory(&directory[0]));
|
||||
event_system::instance().stop();
|
||||
event_system::instance().start();
|
||||
}
|
||||
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.remove_return("post_params", "/renter/dir/" + directory.substr(3));
|
||||
}
|
||||
event_capture ec({"directory_removed"});
|
||||
EXPECT_TRUE(::PathIsDirectory(&directory[0]));
|
||||
EXPECT_TRUE(::RemoveDirectoryA(&directory[0]));
|
||||
EXPECT_FALSE(::PathIsDirectory(&directory[0]));
|
||||
}
|
||||
|
||||
static void write_file_test(const std::size_t &idx, winfsp_test *test,
|
||||
const std::string &mount_point) {
|
||||
static void write_file_test(const std::string &mount_point) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/",
|
||||
{{"directories", {{{"numfiles", 0}, {"numsubdirs", 0}}}}}, {},
|
||||
api_error::success, true);
|
||||
mock_comm.push_return("get", "/renter/dir/test_write.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/test_write.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error);
|
||||
mock_comm.push_return("post_params", "/renter/upload/test_write.txt", {}, {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("post_params", "/renter/upload/test_write.txt", {}, {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/file/test_write.txt",
|
||||
RENTER_FILE_DATA("test_write.txt", 0), {}, api_error::success);
|
||||
mock_comm.push_return("get", "/renter/file/test_write.txt",
|
||||
RENTER_FILE_DATA("test_write.txt", 10), {}, api_error::success, true);
|
||||
}
|
||||
|
||||
const auto file = utils::path::combine(mount_point, {"test_write.txt"});
|
||||
auto handle = ::CreateFileA(&file[0], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr,
|
||||
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
auto handle =
|
||||
::CreateFileA(&file[0], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
|
||||
nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
EXPECT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
const std::string data = "0123456789";
|
||||
DWORD bytes_written = 0;
|
||||
EXPECT_TRUE(
|
||||
::WriteFile(handle, &data[0], static_cast<DWORD>(data.size()), &bytes_written, nullptr));
|
||||
EXPECT_TRUE(::WriteFile(handle, &data[0], static_cast<DWORD>(data.size()),
|
||||
&bytes_written, nullptr));
|
||||
EXPECT_EQ(10, bytes_written);
|
||||
EXPECT_TRUE(::CloseHandle(handle));
|
||||
|
||||
@@ -313,185 +154,80 @@ static void write_file_test(const std::size_t &idx, winfsp_test *test,
|
||||
std::uint64_t file_size;
|
||||
EXPECT_TRUE(utils::file::get_file_size(file, file_size));
|
||||
EXPECT_EQ(10, file_size);
|
||||
|
||||
event_system::instance().stop();
|
||||
event_system::instance().start();
|
||||
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.remove_return("get", "/renter/dir/");
|
||||
mock_comm.remove_return("post_params", "/renter/upload/test_write.txt");
|
||||
}
|
||||
}
|
||||
|
||||
static void read_file_test(const std::size_t &idx, winfsp_test *test,
|
||||
const std::string &mount_point) {
|
||||
static void read_file_test(const std::string &mount_point) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/",
|
||||
{{"directories", {{{"numfiles", 0}, {"numsubdirs", 0}}}}}, {},
|
||||
api_error::success, true);
|
||||
mock_comm.push_return("get", "/renter/dir/test_read.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/test_read.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error);
|
||||
mock_comm.push_return("post_params", "/renter/upload/test_read.txt", {}, {}, api_error::success,
|
||||
true);
|
||||
mock_comm.push_return("get", "/renter/file/test_read.txt", RENTER_FILE_DATA("test_read.txt", 0),
|
||||
{}, api_error::success);
|
||||
mock_comm.push_return("get", "/renter/file/test_read.txt",
|
||||
RENTER_FILE_DATA("test_read.txt", 10), {}, api_error::success, true);
|
||||
}
|
||||
|
||||
const auto file = utils::path::combine(mount_point, {"test_read.txt"});
|
||||
auto handle = ::CreateFileA(&file[0], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr,
|
||||
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
auto handle =
|
||||
::CreateFileA(&file[0], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
|
||||
nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
EXPECT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
const std::string data = "0123456789";
|
||||
DWORD bytes_written = 0;
|
||||
EXPECT_TRUE(
|
||||
::WriteFile(handle, &data[0], static_cast<DWORD>(data.size()), &bytes_written, nullptr));
|
||||
EXPECT_TRUE(::WriteFile(handle, &data[0], static_cast<DWORD>(data.size()),
|
||||
&bytes_written, nullptr));
|
||||
EXPECT_EQ(10, bytes_written);
|
||||
|
||||
std::vector<char> data2;
|
||||
data_buffer data2;
|
||||
data2.resize(10);
|
||||
DWORD bytes_read = 0;
|
||||
EXPECT_EQ(0, ::SetFilePointer(handle, 0, nullptr, FILE_BEGIN));
|
||||
EXPECT_TRUE(
|
||||
::ReadFile(handle, &data2[0], static_cast<DWORD>(data2.size()), &bytes_read, nullptr));
|
||||
EXPECT_TRUE(::ReadFile(handle, &data2[0], static_cast<DWORD>(data2.size()),
|
||||
&bytes_read, nullptr));
|
||||
EXPECT_EQ(10, bytes_read);
|
||||
for (auto i = 0; i < data.size(); i++) {
|
||||
EXPECT_EQ(data[i], data2[i]);
|
||||
}
|
||||
EXPECT_TRUE(::CloseHandle(handle));
|
||||
|
||||
event_system::instance().stop();
|
||||
event_system::instance().start();
|
||||
}
|
||||
|
||||
static void rename_file_test(const std::size_t &idx, winfsp_test *test,
|
||||
static void rename_file_test(winfsp_test *test,
|
||||
const std::string &mount_point) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/rename_file.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/rename_file.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error);
|
||||
mock_comm.push_return("post_params", "/renter/upload/rename_file.txt", {}, {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/file/rename_file.txt",
|
||||
RENTER_FILE_DATA("rename_file.txt", 0), {}, api_error::success, true);
|
||||
|
||||
mock_comm.push_return("get", "/renter/dir/rename_file2.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/rename_file2.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error);
|
||||
mock_comm.push_return("get", "/renter/file/rename_file2.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error);
|
||||
mock_comm.push_return("get", "/renter/file/rename_file2.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error);
|
||||
mock_comm.push_return("post_params", "/renter/rename/rename_file.txt", {}, {},
|
||||
api_error::success);
|
||||
}
|
||||
|
||||
const auto file = utils::path::combine(mount_point, {"rename_file.txt"});
|
||||
auto handle = ::CreateFileA(&file[0], GENERIC_READ, FILE_SHARE_READ, nullptr, CREATE_NEW,
|
||||
FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
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));
|
||||
|
||||
auto &provider = *std::get<1>(test->provider_tests_[idx]);
|
||||
|
||||
api_meta_map meta1{};
|
||||
EXPECT_EQ(api_error::success, provider.get_item_meta("/rename_file.txt", meta1));
|
||||
EXPECT_EQ(api_error::success,
|
||||
test->provider->get_item_meta("/rename_file.txt", meta1));
|
||||
|
||||
const auto file2 = utils::path::combine(mount_point, {"rename_file2.txt"});
|
||||
EXPECT_TRUE(::MoveFile(&file[0], &file2[0]));
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.remove_return("get", "/renter/file/rename_file.txt");
|
||||
mock_comm.push_return("get", "/renter/file/rename_file.txt", {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/rename_file2.txt",
|
||||
RENTER_FILE_DATA("rename_file2.txt", 0), {}, api_error::success, true);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(utils::file::is_file(file2));
|
||||
EXPECT_FALSE(utils::file::is_file(file));
|
||||
|
||||
api_meta_map meta2{};
|
||||
EXPECT_EQ(api_error::success, provider.get_item_meta("/rename_file2.txt", meta2));
|
||||
EXPECT_EQ(api_error::success,
|
||||
test->provider->get_item_meta("/rename_file2.txt", meta2));
|
||||
EXPECT_STREQ(meta1[META_SOURCE].c_str(), meta2[META_SOURCE].c_str());
|
||||
|
||||
filesystem_item fsi{};
|
||||
EXPECT_EQ(api_error::success, provider.get_filesystem_item("/rename_file2.txt", false, fsi));
|
||||
EXPECT_EQ(api_error::success, test->provider->get_filesystem_item(
|
||||
"/rename_file2.txt", false, fsi));
|
||||
EXPECT_STREQ(meta1[META_SOURCE].c_str(), fsi.source_path.c_str());
|
||||
|
||||
filesystem_item fsi2{};
|
||||
EXPECT_EQ(api_error::success,
|
||||
provider.get_filesystem_item_from_source_path(fsi.source_path, fsi2));
|
||||
test->provider->get_filesystem_item_from_source_path(
|
||||
fsi.source_path, fsi2));
|
||||
EXPECT_STREQ("/rename_file2.txt", fsi2.api_path.c_str());
|
||||
|
||||
EXPECT_EQ(api_error::item_not_found, provider.get_item_meta("/rename_file.txt", meta2));
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.remove_return("post_params", "/renter/upload/rename_file.txt");
|
||||
mock_comm.remove_return("post_params", "/renter/rename/rename_file.txt");
|
||||
}
|
||||
EXPECT_EQ(api_error::item_not_found,
|
||||
test->provider->get_item_meta("/rename_file.txt", meta2));
|
||||
}
|
||||
|
||||
static void rename_directory_test(const std::size_t &idx, winfsp_test *test,
|
||||
const std::string &mount_point) {
|
||||
static void rename_directory_test(const std::string &mount_point) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
std::string directory = "rename_dir";
|
||||
const auto full_directory = utils::path::combine(mount_point, {directory});
|
||||
std::string directory2 = "rename_dir2";
|
||||
const auto full_directory2 = utils::path::combine(mount_point, {directory2});
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, {}, {{"message", "no file known"}},
|
||||
api_error::comm_error);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, {}, {{"message", "no file known"}},
|
||||
api_error::comm_error);
|
||||
mock_comm.push_return("get", "/renter/file/" + directory, {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory2, {}, {{"message", "no file known"}},
|
||||
api_error::comm_error);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory2, {}, {{"message", "no file known"}},
|
||||
api_error::comm_error);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory2, {}, {{"message", "no file known"}},
|
||||
api_error::comm_error);
|
||||
|
||||
mock_comm.push_return("get", "/renter/file/" + directory2, {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, RENTER_DIR_DATA(directory), {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, RENTER_DIR_DATA(directory), {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, RENTER_DIR_DATA(directory), {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, RENTER_DIR_DATA(directory), {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, RENTER_DIR_DATA(directory), {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, RENTER_DIR_DATA(directory), {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, RENTER_DIR_DATA(directory), {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, RENTER_DIR_DATA(directory), {},
|
||||
api_error::success);
|
||||
mock_comm.push_return("post_params", "/renter/dir/" + directory, {}, {}, api_error::success);
|
||||
mock_comm.push_return("post_params", "/renter/dir/" + directory, {}, {}, api_error::success);
|
||||
|
||||
mock_comm.push_return("post_params", "/renter/dir/" + directory2, {}, {}, api_error::success);
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory2, RENTER_DIR_DATA(directory2), {},
|
||||
api_error::success, true);
|
||||
|
||||
mock_comm.push_return("get", "/renter/dir/" + directory, {}, {{"message", "no file known"}},
|
||||
api_error::comm_error, true);
|
||||
}
|
||||
|
||||
EXPECT_FALSE(::PathIsDirectory(&full_directory[0]));
|
||||
EXPECT_TRUE(::CreateDirectoryA(&full_directory[0], nullptr));
|
||||
@@ -499,36 +235,16 @@ static void rename_directory_test(const std::size_t &idx, winfsp_test *test,
|
||||
EXPECT_TRUE(::MoveFile(&full_directory[0], &full_directory2[0]));
|
||||
EXPECT_FALSE(::PathIsDirectory(&full_directory[0]));
|
||||
EXPECT_TRUE(::PathIsDirectory(&full_directory2[0]));
|
||||
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.remove_return("post_params", "/renter/dir/" + directory);
|
||||
mock_comm.remove_return("get", "/renter/dir/" + directory2);
|
||||
mock_comm.remove_return("get", "/renter/file/" + directory2);
|
||||
mock_comm.remove_return("post_params", "/renter/dir/" + directory2);
|
||||
}
|
||||
}
|
||||
|
||||
static void get_set_basic_info_test(const std::size_t &idx, winfsp_test *test,
|
||||
const std::string &mount_point) {
|
||||
static void get_set_basic_info_test(const std::string &mount_point) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/setbasicinfo_file.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/setbasicinfo_file.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error);
|
||||
mock_comm.push_return("post_params", "/renter/upload/setbasicinfo_file.txt", {}, {},
|
||||
api_error::success, true);
|
||||
|
||||
mock_comm.push_return("get", "/renter/file/setbasicinfo_file.txt",
|
||||
RENTER_FILE_DATA("setbasicinfo_file.txt", 0), {}, api_error::success,
|
||||
true);
|
||||
}
|
||||
|
||||
const auto file = utils::path::combine(mount_point, {"setbasicinfo_file.txt"});
|
||||
auto handle = ::CreateFileA(&file[0], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr,
|
||||
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
const auto file =
|
||||
utils::path::combine(mount_point, {"setbasicinfo_file.txt"});
|
||||
auto handle =
|
||||
::CreateFileA(&file[0], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
|
||||
nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
EXPECT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
|
||||
SYSTEMTIME st{};
|
||||
@@ -559,126 +275,110 @@ static void get_set_basic_info_test(const std::size_t &idx, winfsp_test *test,
|
||||
fbi.LastAccessTime = *(LARGE_INTEGER *)&test_la_time;
|
||||
fbi.LastWriteTime = *(LARGE_INTEGER *)&test_lw_time;
|
||||
|
||||
EXPECT_TRUE(::SetFileInformationByHandle(handle, FileBasicInfo, &fbi, sizeof(FILE_BASIC_INFO)));
|
||||
EXPECT_TRUE(::SetFileInformationByHandle(handle, FileBasicInfo, &fbi,
|
||||
sizeof(FILE_BASIC_INFO)));
|
||||
|
||||
FILE_BASIC_INFO fbi2{};
|
||||
EXPECT_TRUE(
|
||||
::GetFileInformationByHandleEx(handle, FileBasicInfo, &fbi2, sizeof(FILE_BASIC_INFO)));
|
||||
EXPECT_TRUE(::GetFileInformationByHandleEx(handle, FileBasicInfo, &fbi2,
|
||||
sizeof(FILE_BASIC_INFO)));
|
||||
|
||||
EXPECT_EQ(0, memcmp(&fbi, &fbi2, sizeof(FILE_BASIC_INFO)));
|
||||
|
||||
std::cout << fbi.FileAttributes << " " << fbi.ChangeTime.QuadPart << " "
|
||||
<< fbi.CreationTime.QuadPart << " " << fbi.LastAccessTime.QuadPart << " "
|
||||
<< fbi.LastWriteTime.QuadPart << std::endl;
|
||||
<< fbi.CreationTime.QuadPart << " " << fbi.LastAccessTime.QuadPart
|
||||
<< " " << fbi.LastWriteTime.QuadPart << std::endl;
|
||||
std::cout << fbi2.FileAttributes << " " << fbi2.ChangeTime.QuadPart << " "
|
||||
<< fbi2.CreationTime.QuadPart << " " << fbi2.LastAccessTime.QuadPart << " "
|
||||
<< fbi2.LastWriteTime.QuadPart << std::endl;
|
||||
<< fbi2.CreationTime.QuadPart << " " << fbi2.LastAccessTime.QuadPart
|
||||
<< " " << fbi2.LastWriteTime.QuadPart << std::endl;
|
||||
|
||||
EXPECT_TRUE(::CloseHandle(handle));
|
||||
}
|
||||
|
||||
static void overwrite_file_test(const std::size_t &idx, winfsp_test *test,
|
||||
const std::string &mount_point) {
|
||||
static void overwrite_file_test(const std::string &mount_point) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/dir/test_overwrite.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/dir/test_overwrite2.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error, true);
|
||||
mock_comm.push_return("get", "/renter/file/test_overwrite.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error);
|
||||
|
||||
mock_comm.push_return("post_params", "/renter/upload/test_overwrite.txt", {}, {},
|
||||
api_error::success, true);
|
||||
mock_comm.push_return("post_params", "/renter/upload/test_overwrite2.txt", {}, {},
|
||||
api_error::success, true);
|
||||
|
||||
mock_comm.push_return("post_params", "/renter/delete/test_overwrite2.txt", {}, {},
|
||||
api_error::success, true);
|
||||
}
|
||||
|
||||
const auto file = utils::path::combine("./", {"test_overwrite.txt"});
|
||||
auto handle = ::CreateFileA(&file[0], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
auto handle =
|
||||
::CreateFileA(&file[0], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
|
||||
nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
EXPECT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
const std::string data = "0123456789";
|
||||
DWORD bytes_written = 0;
|
||||
EXPECT_TRUE(
|
||||
::WriteFile(handle, &data[0], static_cast<DWORD>(data.size()), &bytes_written, nullptr));
|
||||
EXPECT_TRUE(::WriteFile(handle, &data[0], static_cast<DWORD>(data.size()),
|
||||
&bytes_written, nullptr));
|
||||
EXPECT_EQ(10, bytes_written);
|
||||
EXPECT_TRUE(::CloseHandle(handle));
|
||||
|
||||
if (bytes_written == 10) {
|
||||
const auto file2 = utils::path::combine(mount_point, {"test_overwrite2.txt"});
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.push_return("get", "/renter/file/test_overwrite2.txt", {},
|
||||
{{"message", "no file known"}}, api_error::comm_error);
|
||||
mock_comm.push_return("get", "/renter/file/test_overwrite.txt",
|
||||
RENTER_FILE_DATA("test_overwrite.txt", 0), {}, api_error::success,
|
||||
true);
|
||||
mock_comm.push_return("get", "/renter/file/test_overwrite2.txt",
|
||||
RENTER_FILE_DATA("test_overwrite2.txt", 0), {}, api_error::success,
|
||||
true);
|
||||
}
|
||||
const auto file2 =
|
||||
utils::path::combine(mount_point, {"test_overwrite2.txt"});
|
||||
EXPECT_TRUE(::CopyFile(&file[0], &file2[0], TRUE));
|
||||
|
||||
EXPECT_FALSE(::CopyFile(&file[0], &file2[0], TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
if (idx == 0) {
|
||||
auto &mock_comm = test->mock_sia_comm_;
|
||||
mock_comm.remove_return("post_params", "/renter/upload/test_overwrite.txt");
|
||||
mock_comm.remove_return("post_params", "/renter/upload/test_overwrite2.txt");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(winfsp_test, all_tests) {
|
||||
if (PROVIDER_INDEX == 0) {
|
||||
for (std::size_t idx = 0; idx < provider_tests_.size(); idx++) {
|
||||
launch_app(("cmd.exe /c unittests.exe --gtest_filter=winfsp_test.all_tests "
|
||||
"--provider_index " +
|
||||
std::to_string(idx) + " > unittests" + std::to_string(idx) + ".log 2>&1"));
|
||||
for (std::size_t idx = 0U; idx < 2U; idx++) {
|
||||
launch_app(
|
||||
("cmd.exe /c unittests.exe --gtest_filter=winfsp_test.all_tests "
|
||||
"--provider_index " +
|
||||
std::to_string(idx) + " > unittests" + std::to_string(idx) +
|
||||
".log 2>&1"));
|
||||
}
|
||||
} else {
|
||||
const auto idx = PROVIDER_INDEX - 1;
|
||||
|
||||
std::string mount_point;
|
||||
const auto drive_args = mount_setup(idx, this, mount_point);
|
||||
|
||||
event_capture ec({"drive_mounted"});
|
||||
std::thread th([&] {
|
||||
const auto mounted = ec.wait_for_event("drive_mounted");
|
||||
EXPECT_TRUE(mounted);
|
||||
if (mounted) {
|
||||
root_creation_test(mount_point);
|
||||
{
|
||||
const auto file = create_test(idx, this, mount_point);
|
||||
delete_file_test(idx, this, file);
|
||||
}
|
||||
{
|
||||
const auto testDir = utils::path::combine(mount_point, {"TestDir"});
|
||||
create_directory_test(idx, this, testDir);
|
||||
remove_directory_test(idx, this, testDir);
|
||||
}
|
||||
write_file_test(idx, this, mount_point);
|
||||
read_file_test(idx, this, mount_point);
|
||||
rename_file_test(idx, this, mount_point);
|
||||
rename_directory_test(idx, this, mount_point);
|
||||
overwrite_file_test(idx, this, mount_point);
|
||||
get_set_basic_info_test(idx, this, mount_point);
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
unmount(idx, this, mount_point);
|
||||
}
|
||||
});
|
||||
|
||||
execute_mount(idx, this, drive_args, th);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef REPERTORY_ENABLE_S3
|
||||
if (PROVIDER_INDEX == 1U) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string mount_point;
|
||||
const auto drive_args = mount_setup(mount_point);
|
||||
|
||||
event_capture ec({
|
||||
"drive_mounted",
|
||||
"drive_unmounted",
|
||||
"drive_unmount_pending",
|
||||
"drive_mount_result",
|
||||
});
|
||||
|
||||
std::thread th([&] {
|
||||
const auto mounted = ec.wait_for_event("drive_mounted");
|
||||
EXPECT_TRUE(mounted);
|
||||
if (mounted) {
|
||||
root_creation_test(mount_point);
|
||||
{
|
||||
const auto file = create_test(this, mount_point);
|
||||
delete_file_test(file);
|
||||
}
|
||||
{
|
||||
const auto dir = utils::path::combine(mount_point, {"TestDir"});
|
||||
create_directory_test(dir);
|
||||
remove_directory_test(dir);
|
||||
}
|
||||
write_file_test(mount_point);
|
||||
read_file_test(mount_point);
|
||||
// TODO enable after rename support is available
|
||||
// rename_file_test(this, mount_point);
|
||||
// rename_directory_test(mount_point);
|
||||
overwrite_file_test(mount_point);
|
||||
get_set_basic_info_test(mount_point);
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
unmount(this, mount_point);
|
||||
ec.wait_for_empty();
|
||||
}
|
||||
});
|
||||
|
||||
execute_mount(this, drive_args, th);
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
|
Reference in New Issue
Block a user