fixes
This commit is contained in:
@ -934,7 +934,7 @@ TEST(remote_fuse, all_tests) {
|
||||
|
||||
event_system::instance().start();
|
||||
#if defined(_WIN32)
|
||||
mount_location_ = std::string(test::get_test_output_dir(), 2);
|
||||
mount_location_ = test::get_test_output_dir().substr(0, 2);
|
||||
mock_winfsp_drive drive(mount_location_);
|
||||
remote_server server(config, drive, mount_location_);
|
||||
#else
|
||||
|
@ -491,7 +491,6 @@ TEST(remote_winfsp, all_tests) {
|
||||
EXPECT_TRUE(found_port);
|
||||
if (found_port) {
|
||||
console_consumer c;
|
||||
|
||||
app_config config(provider_type::remote, win_remote_dir);
|
||||
config.set_remote_host_name_or_ip("localhost");
|
||||
config.set_remote_port(port);
|
||||
@ -501,7 +500,7 @@ TEST(remote_winfsp, all_tests) {
|
||||
|
||||
event_system::instance().start();
|
||||
#if defined(_WIN32)
|
||||
mount_location_ = std::string(test::get_test_output_dir(), 2);
|
||||
mount_location_ = test::get_test_output_dir().substr(0, 2);
|
||||
mock_winfsp_drive drive(mount_location_);
|
||||
remote_server server(config, drive, mount_location_);
|
||||
#else
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
[[nodiscard]] static auto open_or_create_file(std::filesystem::path path,
|
||||
bool read_only = false) -> file;
|
||||
|
||||
public:
|
||||
file() noexcept = default;
|
||||
|
||||
protected:
|
||||
|
@ -28,6 +28,11 @@
|
||||
|
||||
namespace repertory::utils::file {
|
||||
auto file::open_file(std::filesystem::path path, bool read_only) -> file {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
|
||||
try {
|
||||
path = utils::path::absolute(path.string());
|
||||
if (not is_file(path.string())) {
|
||||
throw std::runtime_error("file not found: " + path.string());
|
||||
@ -44,7 +49,6 @@ auto file::open_file(std::filesystem::path path, bool read_only) -> file {
|
||||
#if defined(_WIN32)
|
||||
auto *ptr =
|
||||
_fsopen(path.string().c_str(), read_only ? "rb" : "rb+", _SH_DENYNO);
|
||||
std::cout << errno << std::endl;
|
||||
#else // !defined(_WIN32)
|
||||
auto *ptr = fopen(path.string().c_str(), read_only ? "rb" : "rb+");
|
||||
#endif // defined(_WIN32)
|
||||
@ -53,6 +57,13 @@ auto file::open_file(std::filesystem::path path, bool read_only) -> file {
|
||||
file_t{ptr},
|
||||
path,
|
||||
};
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::handle_exception(function_name, e);
|
||||
} catch (...) {
|
||||
utils::error::handle_exception(function_name);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
auto file::open_or_create_file(std::filesystem::path path,
|
||||
|
@ -34,21 +34,23 @@ using namespace ::testing;
|
||||
|
||||
#define COMMA ,
|
||||
|
||||
#include "utils/config.hpp"
|
||||
|
||||
#include "utils/all.hpp"
|
||||
|
||||
namespace repertory::test {
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
[[nodiscard]] auto create_random_file(std::size_t size) -> utils::file::file;
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
||||
[[nodiscard]] auto
|
||||
generate_test_file_name(std::string_view file_name_no_extension) -> std::string;
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
|
||||
template <typename buffer_t, typename result_t>
|
||||
static void decrypt_and_verify(const buffer_t &buffer, std::string_view token,
|
||||
result_t &result) {
|
||||
EXPECT_TRUE(utils::encryption::decrypt_data(token, buffer, result));
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
|
||||
|
||||
[[nodiscard]] auto get_test_input_dir() -> std::string;
|
||||
|
||||
|
@ -53,6 +53,7 @@ static auto deleter{std::make_unique<file_deleter>()};
|
||||
} // namespace
|
||||
|
||||
namespace repertory::test {
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
auto create_random_file(std::size_t size) -> utils::file::file {
|
||||
recur_mutex_lock lock{file_mtx};
|
||||
|
||||
@ -74,6 +75,7 @@ auto create_random_file(std::size_t size) -> utils::file::file {
|
||||
|
||||
return file;
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
||||
auto generate_test_file_name(std::string_view file_name_no_extension)
|
||||
-> std::string {
|
||||
|
Reference in New Issue
Block a user