fuse test changes
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class encrypt_provider final : public i_provider {
|
class encrypt_provider final : public i_provider {
|
||||||
|
public:
|
||||||
|
static const constexpr auto type{provider_type::encrypt};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit encrypt_provider(app_config &config);
|
explicit encrypt_provider(app_config &config);
|
||||||
|
|
||||||
@ -81,74 +84,68 @@ public:
|
|||||||
[[nodiscard]] auto create_directory(const std::string &api_path,
|
[[nodiscard]] auto create_directory(const std::string &api_path,
|
||||||
api_meta_map &meta) -> api_error override;
|
api_meta_map &meta) -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto create_directory_clone_source_meta(
|
||||||
create_directory_clone_source_meta(const std::string & /*source_api_path*/,
|
const std::string & /*source_api_path*/,
|
||||||
const std::string & /*api_path*/)
|
const std::string & /*api_path*/) -> api_error override {
|
||||||
-> api_error override {
|
|
||||||
return api_error::not_implemented;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto create_file(const std::string & /*api_path*/,
|
|
||||||
api_meta_map & /*meta*/)
|
|
||||||
-> api_error override {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto
|
||||||
get_api_path_from_source(const std::string & /*source_path*/,
|
create_file(const std::string & /*api_path*/,
|
||||||
std::string & /*api_path*/) const
|
api_meta_map & /*meta*/) -> api_error override {
|
||||||
-> api_error override;
|
return api_error::not_implemented;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_api_path_from_source(
|
||||||
|
const std::string & /*source_path*/,
|
||||||
|
std::string & /*api_path*/) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
|
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
|
||||||
-> std::uint64_t override;
|
-> std::uint64_t override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_directory_items(const std::string &api_path,
|
[[nodiscard]] auto
|
||||||
directory_item_list &list) const
|
get_directory_items(const std::string &api_path,
|
||||||
-> api_error override;
|
directory_item_list &list) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const
|
[[nodiscard]] auto get_file(const std::string &api_path,
|
||||||
-> api_error override;
|
api_file &file) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_file_list(api_file_list &list) const
|
|
||||||
-> api_error override;
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_file_size(const std::string &api_path,
|
|
||||||
std::uint64_t &file_size) const
|
|
||||||
-> api_error override;
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_filesystem_item(const std::string &api_path,
|
|
||||||
bool directory,
|
|
||||||
filesystem_item &fsi) const
|
|
||||||
-> api_error override;
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_filesystem_item_and_file(const std::string &api_path,
|
|
||||||
api_file &file,
|
|
||||||
filesystem_item &fsi) const
|
|
||||||
-> api_error override;
|
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto
|
||||||
get_filesystem_item_from_source_path(const std::string &source_path,
|
get_file_list(api_file_list &list) const -> api_error override;
|
||||||
filesystem_item &fsi) const
|
|
||||||
-> api_error override;
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_pinned_files() const
|
[[nodiscard]] auto
|
||||||
-> std::vector<std::string> override;
|
get_file_size(const std::string &api_path,
|
||||||
|
std::uint64_t &file_size) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_item_meta(const std::string &api_path,
|
[[nodiscard]] auto
|
||||||
api_meta_map &meta) const
|
get_filesystem_item(const std::string &api_path, bool directory,
|
||||||
-> api_error override;
|
filesystem_item &fsi) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_item_meta(const std::string &api_path,
|
[[nodiscard]] auto get_filesystem_item_and_file(
|
||||||
const std::string &key,
|
const std::string &api_path, api_file &file,
|
||||||
std::string &value) const
|
filesystem_item &fsi) const -> api_error override;
|
||||||
-> api_error override;
|
|
||||||
|
[[nodiscard]] auto get_filesystem_item_from_source_path(
|
||||||
|
const std::string &source_path,
|
||||||
|
filesystem_item &fsi) const -> api_error override;
|
||||||
|
|
||||||
|
[[nodiscard]] auto
|
||||||
|
get_pinned_files() const -> std::vector<std::string> override;
|
||||||
|
|
||||||
|
[[nodiscard]] auto
|
||||||
|
get_item_meta(const std::string &api_path,
|
||||||
|
api_meta_map &meta) const -> api_error override;
|
||||||
|
|
||||||
|
[[nodiscard]] auto
|
||||||
|
get_item_meta(const std::string &api_path, const std::string &key,
|
||||||
|
std::string &value) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
|
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override;
|
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_provider_type() const -> provider_type override {
|
[[nodiscard]] auto get_provider_type() const -> provider_type override {
|
||||||
return provider_type::encrypt;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override;
|
[[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override;
|
||||||
@ -158,54 +155,52 @@ public:
|
|||||||
[[nodiscard]] auto is_directory(const std::string &api_path,
|
[[nodiscard]] auto is_directory(const std::string &api_path,
|
||||||
bool &exists) const -> api_error override;
|
bool &exists) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const
|
[[nodiscard]] auto is_file(const std::string &api_path,
|
||||||
-> api_error override;
|
bool &exists) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto is_file_writeable(const std::string &api_path) const
|
[[nodiscard]] auto
|
||||||
-> bool override;
|
is_file_writeable(const std::string &api_path) const -> bool override;
|
||||||
|
|
||||||
[[nodiscard]] auto is_online() const -> bool override;
|
[[nodiscard]] auto is_online() const -> bool override;
|
||||||
|
|
||||||
[[nodiscard]] auto is_rename_supported() const -> bool override;
|
[[nodiscard]] auto is_rename_supported() const -> bool override;
|
||||||
|
|
||||||
[[nodiscard]] auto read_file_bytes(const std::string &api_path,
|
[[nodiscard]] auto
|
||||||
std::size_t size, std::uint64_t offset,
|
read_file_bytes(const std::string &api_path, std::size_t size,
|
||||||
data_buffer &data,
|
std::uint64_t offset, data_buffer &data,
|
||||||
stop_type &stop_requested)
|
stop_type &stop_requested) -> api_error override;
|
||||||
-> api_error override;
|
|
||||||
|
|
||||||
[[nodiscard]] auto remove_directory(const std::string & /*api_path*/)
|
[[nodiscard]] auto
|
||||||
-> api_error override {
|
remove_directory(const std::string & /*api_path*/) -> api_error override {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto remove_file(const std::string & /*api_path*/)
|
[[nodiscard]] auto
|
||||||
-> api_error override {
|
remove_file(const std::string & /*api_path*/) -> api_error override {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto remove_item_meta(const std::string & /*api_path*/,
|
[[nodiscard]] auto
|
||||||
const std::string & /*key*/)
|
remove_item_meta(const std::string & /*api_path*/,
|
||||||
-> api_error override {
|
const std::string & /*key*/) -> api_error override {
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto rename_file(const std::string & /*from_api_path*/,
|
[[nodiscard]] auto
|
||||||
const std::string & /*to_api_path*/)
|
rename_file(const std::string & /*from_api_path*/,
|
||||||
-> api_error override {
|
const std::string & /*to_api_path*/) -> api_error override {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto set_item_meta(const std::string & /*api_path*/,
|
[[nodiscard]] auto
|
||||||
const std::string & /*key*/,
|
set_item_meta(const std::string & /*api_path*/, const std::string & /*key*/,
|
||||||
const std::string & /*value*/)
|
const std::string & /*value*/) -> api_error override {
|
||||||
-> api_error override {
|
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto set_item_meta(const std::string & /*api_path*/,
|
[[nodiscard]] auto
|
||||||
const api_meta_map & /*meta*/)
|
set_item_meta(const std::string & /*api_path*/,
|
||||||
-> api_error override {
|
const api_meta_map & /*meta*/) -> api_error override {
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,10 +209,10 @@ public:
|
|||||||
|
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
|
||||||
[[nodiscard]] auto upload_file(const std::string & /*api_path*/,
|
[[nodiscard]] auto
|
||||||
|
upload_file(const std::string & /*api_path*/,
|
||||||
const std::string & /*source_path*/,
|
const std::string & /*source_path*/,
|
||||||
stop_type & /*stop_requested*/)
|
stop_type & /*stop_requested*/) -> api_error override {
|
||||||
-> api_error override {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -32,6 +32,9 @@ class i_http_comm;
|
|||||||
struct head_object_result;
|
struct head_object_result;
|
||||||
|
|
||||||
class s3_provider final : public base_provider {
|
class s3_provider final : public base_provider {
|
||||||
|
public:
|
||||||
|
static const constexpr auto type{provider_type::s3};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
s3_provider(app_config &config, i_http_comm &comm);
|
s3_provider(app_config &config, i_http_comm &comm);
|
||||||
|
|
||||||
@ -104,7 +107,7 @@ public:
|
|||||||
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
|
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_provider_type() const -> provider_type override {
|
[[nodiscard]] auto get_provider_type() const -> provider_type override {
|
||||||
return provider_type::s3;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto is_direct_only() const -> bool override { return false; }
|
[[nodiscard]] auto is_direct_only() const -> bool override { return false; }
|
||||||
|
@ -31,6 +31,9 @@ class i_file_manager;
|
|||||||
class i_http_comm;
|
class i_http_comm;
|
||||||
|
|
||||||
class sia_provider : public base_provider {
|
class sia_provider : public base_provider {
|
||||||
|
public:
|
||||||
|
static const constexpr auto type{provider_type::sia};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
sia_provider(app_config &config, i_http_comm &comm);
|
sia_provider(app_config &config, i_http_comm &comm);
|
||||||
|
|
||||||
@ -50,40 +53,39 @@ private:
|
|||||||
nlohmann::json &object_list) const -> bool;
|
nlohmann::json &object_list) const -> bool;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
[[nodiscard]] auto create_directory_impl(const std::string &api_path,
|
[[nodiscard]] auto
|
||||||
api_meta_map &meta)
|
create_directory_impl(const std::string &api_path,
|
||||||
-> api_error override;
|
api_meta_map &meta) -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_directory_items_impl(const std::string &api_path,
|
[[nodiscard]] auto get_directory_items_impl(const std::string &api_path,
|
||||||
directory_item_list &list) const
|
directory_item_list &list) const
|
||||||
-> api_error override;
|
-> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_used_drive_space_impl() const
|
[[nodiscard]] auto
|
||||||
-> std::uint64_t override;
|
get_used_drive_space_impl() const -> std::uint64_t override;
|
||||||
|
|
||||||
[[nodiscard]] auto remove_directory_impl(const std::string &api_path)
|
[[nodiscard]] auto
|
||||||
-> api_error override;
|
remove_directory_impl(const std::string &api_path) -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto remove_file_impl(const std::string &api_path)
|
[[nodiscard]] auto
|
||||||
-> api_error override;
|
remove_file_impl(const std::string &api_path) -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto upload_file_impl(const std::string &api_path,
|
[[nodiscard]] auto
|
||||||
const std::string &source_path,
|
upload_file_impl(const std::string &api_path, const std::string &source_path,
|
||||||
stop_type &stop_requested)
|
stop_type &stop_requested) -> api_error override;
|
||||||
-> api_error override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
|
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
|
||||||
-> std::uint64_t override;
|
-> std::uint64_t override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const
|
[[nodiscard]] auto get_file(const std::string &api_path,
|
||||||
-> api_error override;
|
api_file &file) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_file_list(api_file_list &list) const
|
[[nodiscard]] auto
|
||||||
-> api_error override;
|
get_file_list(api_file_list &list) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_provider_type() const -> provider_type override {
|
[[nodiscard]] auto get_provider_type() const -> provider_type override {
|
||||||
return provider_type::sia;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
|
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
|
||||||
@ -93,8 +95,8 @@ public:
|
|||||||
[[nodiscard]] auto is_directory(const std::string &api_path,
|
[[nodiscard]] auto is_directory(const std::string &api_path,
|
||||||
bool &exists) const -> api_error override;
|
bool &exists) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const
|
[[nodiscard]] auto is_file(const std::string &api_path,
|
||||||
-> api_error override;
|
bool &exists) const -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto is_online() const -> bool override;
|
[[nodiscard]] auto is_online() const -> bool override;
|
||||||
|
|
||||||
@ -102,15 +104,14 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto read_file_bytes(const std::string &api_path,
|
[[nodiscard]] auto
|
||||||
std::size_t size, std::uint64_t offset,
|
read_file_bytes(const std::string &api_path, std::size_t size,
|
||||||
data_buffer &buffer,
|
std::uint64_t offset, data_buffer &buffer,
|
||||||
stop_type &stop_requested)
|
stop_type &stop_requested) -> api_error override;
|
||||||
-> api_error override;
|
|
||||||
|
|
||||||
[[nodiscard]] auto rename_file(const std::string &from_api_path,
|
[[nodiscard]] auto
|
||||||
const std::string &to_api_path)
|
rename_file(const std::string &from_api_path,
|
||||||
-> api_error override;
|
const std::string &to_api_path) -> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto start(api_item_added_callback api_item_added,
|
[[nodiscard]] auto start(api_item_added_callback api_item_added,
|
||||||
i_file_manager *mgr) -> bool override;
|
i_file_manager *mgr) -> bool override;
|
||||||
|
235
repertory/repertory_test/include/fixtures/fuse_fixture.hpp
Normal file
235
repertory/repertory_test/include/fixtures/fuse_fixture.hpp
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
Copyright <2018-2024> <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
|
||||||
|
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 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.
|
||||||
|
*/
|
||||||
|
#ifndef REPERTORY_TEST_INCLUDE_FIXTURES_FUSE_FIXTURE_HPP
|
||||||
|
#define REPERTORY_TEST_INCLUDE_FIXTURES_FUSE_FIXTURE_HPP
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
|
||||||
|
#include "test_common.hpp"
|
||||||
|
|
||||||
|
#include "app_config.hpp"
|
||||||
|
#include "comm/curl/curl_comm.hpp"
|
||||||
|
#include "drives/fuse/fuse_drive.hpp"
|
||||||
|
#include "platform/platform.hpp"
|
||||||
|
#include "providers/encrypt/encrypt_provider.hpp"
|
||||||
|
#include "providers/s3/s3_provider.hpp"
|
||||||
|
#include "providers/sia/sia_provider.hpp"
|
||||||
|
#include "utils/file_utils.hpp"
|
||||||
|
#include "utils/path.hpp"
|
||||||
|
|
||||||
|
#if !defined(ACCESSPERMS)
|
||||||
|
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
inline constexpr const auto SLEEP_SECONDS{1.5s};
|
||||||
|
|
||||||
|
template <typename provider_t> class fuse_test : public ::testing::Test {
|
||||||
|
public:
|
||||||
|
static std::string cfg_directory;
|
||||||
|
static std::unique_ptr<curl_comm> comm;
|
||||||
|
static std::unique_ptr<app_config> config;
|
||||||
|
static std::filesystem::path current_directory;
|
||||||
|
static std::unique_ptr<fuse_drive> drive;
|
||||||
|
static lock_data lock_data_;
|
||||||
|
static std::string mount_location;
|
||||||
|
static std::unique_ptr<i_provider> provider;
|
||||||
|
static std::string test_directory;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void SetUpTestCase() {
|
||||||
|
current_directory = std::filesystem::current_path();
|
||||||
|
|
||||||
|
test_directory = utils::path::combine(
|
||||||
|
test::get_test_output_dir(),
|
||||||
|
{
|
||||||
|
"fuse_test",
|
||||||
|
std::to_string(static_cast<std::uint8_t>(provider_t::type)),
|
||||||
|
});
|
||||||
|
|
||||||
|
ASSERT_TRUE(utils::file::remove_directory(test_directory, true));
|
||||||
|
|
||||||
|
mount_location = utils::path::combine(test_directory, {"mount"});
|
||||||
|
ASSERT_TRUE(utils::file::create_directories(mount_location));
|
||||||
|
|
||||||
|
cfg_directory = utils::path::combine(test_directory, {"cfg"});
|
||||||
|
ASSERT_TRUE(utils::file::create_directories(cfg_directory));
|
||||||
|
|
||||||
|
config = std::make_unique<app_config>(provider_t::type, cfg_directory);
|
||||||
|
|
||||||
|
std::vector<std::string> drive_args{};
|
||||||
|
switch (provider_t::type) {
|
||||||
|
case provider_type::s3: {
|
||||||
|
{
|
||||||
|
app_config src_cfg{
|
||||||
|
provider_type::s3,
|
||||||
|
utils::path::combine(test::get_test_input_dir(), {"storj"}),
|
||||||
|
};
|
||||||
|
config->set_enable_drive_events(true);
|
||||||
|
config->set_event_level(event_level::trace);
|
||||||
|
config->set_s3_config(src_cfg.get_s3_config());
|
||||||
|
}
|
||||||
|
|
||||||
|
comm = std::make_unique<curl_comm>(config->get_s3_config());
|
||||||
|
drive_args = std::vector<std::string>({
|
||||||
|
"-s3",
|
||||||
|
"-na",
|
||||||
|
"storj",
|
||||||
|
});
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case provider_type::sia: {
|
||||||
|
{
|
||||||
|
app_config src_cfg{
|
||||||
|
provider_type::sia,
|
||||||
|
utils::path::combine(test::get_test_input_dir(), {"sia"}),
|
||||||
|
};
|
||||||
|
config->set_enable_drive_events(true);
|
||||||
|
config->set_event_level(event_level::debug);
|
||||||
|
config->set_host_config(src_cfg.get_host_config());
|
||||||
|
}
|
||||||
|
|
||||||
|
comm = std::make_unique<curl_comm>(config->get_host_config());
|
||||||
|
} break;
|
||||||
|
// case 0U: {
|
||||||
|
// config =
|
||||||
|
// std::make_unique<app_config>(provider_type::encrypt,
|
||||||
|
// cfg_directory);
|
||||||
|
// {
|
||||||
|
// app_config src_cfg(
|
||||||
|
// provider_type::s3,
|
||||||
|
// utils::path::combine(test::get_test_input_dir(), {"encrypt"}));
|
||||||
|
// config->set_enable_drive_events(true);
|
||||||
|
// config->set_event_level(event_level::trace);
|
||||||
|
// config->set_s3_config(src_cfg.get_s3_config());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// comm = std::make_unique<curl_comm>(config->get_s3_config());
|
||||||
|
// provider = std::make_unique<s3_provider>(*config, *comm);
|
||||||
|
// drive_args = std::vector<std::string>({"-en"});
|
||||||
|
// } break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw std::runtime_error("provider type is not implemented");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
provider = std::make_unique<provider_t>(*config, *comm);
|
||||||
|
drive_args.push_back(mount_location);
|
||||||
|
execute_mount(drive_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TearDownTestCase() {
|
||||||
|
execute_unmount();
|
||||||
|
std::filesystem::current_path(current_directory);
|
||||||
|
|
||||||
|
[[maybe_unused]] auto ret =
|
||||||
|
utils::file::remove_directory(test_directory, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static auto create_file_and_test(std::string name) -> std::string {
|
||||||
|
auto file_path = utils::path::combine(mount_location, {name});
|
||||||
|
|
||||||
|
auto fd =
|
||||||
|
open(file_path.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP);
|
||||||
|
EXPECT_LE(1, fd);
|
||||||
|
|
||||||
|
EXPECT_TRUE(utils::file::is_file(file_path));
|
||||||
|
EXPECT_FALSE(utils::file::is_directory(file_path));
|
||||||
|
|
||||||
|
std::uint64_t file_size{};
|
||||||
|
EXPECT_TRUE(utils::file::get_file_size(file_path, file_size));
|
||||||
|
EXPECT_EQ(0U, file_size);
|
||||||
|
|
||||||
|
EXPECT_EQ(0, close(fd));
|
||||||
|
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||||
|
|
||||||
|
return file_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void execute_mount(auto &&drive_args) {
|
||||||
|
auto mount_cmd = "./repertory -dd \"" + config->get_data_directory() +
|
||||||
|
"\"" + " " + utils::string::join(drive_args, ' ');
|
||||||
|
std::cout << "mount command: " << mount_cmd << std::endl;
|
||||||
|
ASSERT_EQ(0, system(mount_cmd.c_str()));
|
||||||
|
std::this_thread::sleep_for(5s);
|
||||||
|
EXPECT_EQ(0, system(("mount|grep \"" + mount_location + "\"").c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void execute_unmount() {
|
||||||
|
auto unmounted{false};
|
||||||
|
for (int i = 0; not unmounted && (i < 50); i++) {
|
||||||
|
unmounted = (fuse_base::unmount(mount_location) == 0);
|
||||||
|
if (not unmounted) {
|
||||||
|
std::this_thread::sleep_for(100ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_TRUE(unmounted);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unlink_file_and_test(const std::string &file_path) {
|
||||||
|
int ret = 0;
|
||||||
|
for (auto i = 0; ((ret = unlink(file_path.c_str())) != 0) && (i < 20);
|
||||||
|
i++) {
|
||||||
|
std::this_thread::sleep_for(100ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||||
|
EXPECT_FALSE(utils::file::is_directory(file_path));
|
||||||
|
EXPECT_FALSE(utils::file::is_file(file_path));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename provider_t>
|
||||||
|
std::string fuse_test<provider_t>::cfg_directory{};
|
||||||
|
|
||||||
|
template <typename provider_t>
|
||||||
|
std::unique_ptr<curl_comm> fuse_test<provider_t>::comm{};
|
||||||
|
|
||||||
|
template <typename provider_t>
|
||||||
|
std::unique_ptr<app_config> fuse_test<provider_t>::config{};
|
||||||
|
|
||||||
|
template <typename provider_t>
|
||||||
|
std::filesystem::path fuse_test<provider_t>::current_directory{};
|
||||||
|
|
||||||
|
template <typename provider_t>
|
||||||
|
std::unique_ptr<fuse_drive> fuse_test<provider_t>::drive{};
|
||||||
|
|
||||||
|
template <typename provider_t> lock_data fuse_test<provider_t>::lock_data_{};
|
||||||
|
|
||||||
|
template <typename provider_t>
|
||||||
|
std::string fuse_test<provider_t>::mount_location{};
|
||||||
|
|
||||||
|
template <typename provider_t>
|
||||||
|
std::unique_ptr<i_provider> fuse_test<provider_t>::provider{};
|
||||||
|
|
||||||
|
template <typename provider_t>
|
||||||
|
std::string fuse_test<provider_t>::test_directory;
|
||||||
|
|
||||||
|
typedef ::testing::Types<s3_provider, sia_provider> fuse_provider_types;
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
#endif // !defined(_WIN32)
|
||||||
|
#endif // REPERTORY_TEST_INCLUDE_FIXTURES_FUSE_FIXTURE_HPP
|
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,8 @@ if [ -f "${PROJECT_SOURCE_DIR}/pre_build.sh" ]; then
|
|||||||
"${PROJECT_SOURCE_DIR}/pre_build.sh"
|
"${PROJECT_SOURCE_DIR}/pre_build.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ln -sf "${PROJECT_BUILD_DIR}/build/compile_commands.json" "${PROJECT_SOURCE_DIR}/compile_commands.json"
|
||||||
|
|
||||||
pushd "${PROJECT_BUILD_DIR}"
|
pushd "${PROJECT_BUILD_DIR}"
|
||||||
cmake "${PROJECT_SOURCE_DIR}" \
|
cmake "${PROJECT_SOURCE_DIR}" \
|
||||||
-G"Unix Makefiles" \
|
-G"Unix Makefiles" \
|
||||||
@ -80,8 +82,6 @@ if [ "${PROJECT_IS_MINGW}" == "1" ]; then
|
|||||||
. "${PROJECT_SCRIPTS_DIR}/copy_mingw64_deps.sh" "$1" "$2" "$3" "$4" "$5"
|
. "${PROJECT_SCRIPTS_DIR}/copy_mingw64_deps.sh" "$1" "$2" "$3" "$4" "$5"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sf "${PROJECT_BUILD_DIR}/build/compile_commands.json" "${PROJECT_SOURCE_DIR}/compile_commands.json"
|
|
||||||
|
|
||||||
if [ -f "${PROJECT_SOURCE_DIR}/post_build.sh" ]; then
|
if [ -f "${PROJECT_SOURCE_DIR}/post_build.sh" ]; then
|
||||||
"${PROJECT_SOURCE_DIR}/post_build.sh"
|
"${PROJECT_SOURCE_DIR}/post_build.sh"
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user