refactor proprocessor directives
This commit is contained in:
@@ -19,9 +19,9 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_WINFSP_FIXTURE_H
|
||||
#define REPERTORY_WINFSP_FIXTURE_H
|
||||
#if _WIN32
|
||||
#ifndef REPERTORY_WINFSP_FIXTURE_HPP
|
||||
#define REPERTORY_WINFSP_FIXTURE_HPP
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "test_common.hpp"
|
||||
|
||||
@@ -47,7 +47,7 @@ protected:
|
||||
void SetUp() override {
|
||||
if (PROVIDER_INDEX != 0) {
|
||||
if (PROVIDER_INDEX == 1) {
|
||||
#ifdef REPERTORY_ENABLE_S3
|
||||
#if defined(REPERTORY_ENABLE_S3)
|
||||
EXPECT_TRUE(utils::file::delete_directory_recursively(
|
||||
"./winfsp_test" + std::to_string(PROVIDER_INDEX)));
|
||||
|
||||
@@ -145,4 +145,4 @@ protected:
|
||||
} // namespace repertory
|
||||
|
||||
#endif
|
||||
#endif // REPERTORY_WINFSP_FIXTURE_H
|
||||
#endif // REPERTORY_WINFSP_FIXTURE_HPP
|
||||
|
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
#ifndef TESTS_MOCKS_MOCK_FUSE_DRIVE_HPP_
|
||||
#define TESTS_MOCKS_MOCK_FUSE_DRIVE_HPP_
|
||||
#ifndef _WIN32
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include "test_common.hpp"
|
||||
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto check_parent_access(const std::string &, int) const
|
||||
-> api_error override {
|
||||
auto check_parent_access(const std::string &,
|
||||
int) const -> api_error override {
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ public:
|
||||
return 0U;
|
||||
}
|
||||
|
||||
auto get_item_meta(const std::string &api_path, api_meta_map &meta) const
|
||||
-> api_error override {
|
||||
auto get_item_meta(const std::string &api_path,
|
||||
api_meta_map &meta) const -> api_error override {
|
||||
meta = const_cast<mock_fuse_drive *>(this)->meta_[api_path];
|
||||
return api_error::success;
|
||||
}
|
||||
@@ -123,8 +123,8 @@ public:
|
||||
}
|
||||
|
||||
auto rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path, bool overwrite)
|
||||
-> int override {
|
||||
const std::string &to_api_path,
|
||||
bool overwrite) -> int override {
|
||||
const auto from_file_path =
|
||||
utils::path::combine(mount_location_, {from_api_path});
|
||||
const auto to_file_path =
|
||||
|
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
#ifndef TESTS_MOCKS_MOCK_WINFSP_DRIVE_HPP_
|
||||
#define TESTS_MOCKS_MOCK_WINFSP_DRIVE_HPP_
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "test_common.hpp"
|
||||
|
||||
@@ -40,9 +40,8 @@ private:
|
||||
const std::string mount_location_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto
|
||||
get_directory_item_count(const std::string & /*api_path*/) const
|
||||
-> std::uint64_t override {
|
||||
[[nodiscard]] auto get_directory_item_count(
|
||||
const std::string & /*api_path*/) const -> std::uint64_t override {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -72,8 +71,8 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto get_item_meta(const std::string & /*api_path*/, api_meta_map &meta) const
|
||||
-> api_error override {
|
||||
auto get_item_meta(const std::string & /*api_path*/,
|
||||
api_meta_map &meta) const -> api_error override {
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
@@ -83,10 +82,10 @@ public:
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
auto get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size)
|
||||
-> NTSTATUS override {
|
||||
auto
|
||||
get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size) -> NTSTATUS override {
|
||||
auto ret = STATUS_SUCCESS;
|
||||
|
||||
if (attributes) {
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#ifndef TESTS_TEST_COMMON_HPP_
|
||||
#define TESTS_TEST_COMMON_HPP_
|
||||
|
||||
#ifdef U
|
||||
#if defined(U)
|
||||
#undef U
|
||||
#endif
|
||||
|
||||
@@ -44,15 +44,14 @@ using ::testing::_;
|
||||
using namespace ::testing;
|
||||
|
||||
namespace repertory {
|
||||
[[nodiscard]] auto create_random_file(std::string path, std::size_t size)
|
||||
-> native_file_ptr;
|
||||
[[nodiscard]] auto create_random_file(std::string path,
|
||||
std::size_t size) -> native_file_ptr;
|
||||
|
||||
void delete_generated_files();
|
||||
|
||||
[[nodiscard]] auto
|
||||
generate_test_file_name(const std::string &directory,
|
||||
const std::string &file_name_no_extension)
|
||||
-> std::string;
|
||||
[[nodiscard]] auto generate_test_file_name(
|
||||
const std::string &directory,
|
||||
const std::string &file_name_no_extension) -> std::string;
|
||||
|
||||
template <typename T, typename T2>
|
||||
static void decrypt_and_verify(const T &buffer, const std::string &token,
|
||||
|
@@ -21,13 +21,13 @@
|
||||
*/
|
||||
#include "initialize.hpp"
|
||||
#include "test_common.hpp"
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
#include "utils/cli_utils.hpp"
|
||||
#endif // _WIN32
|
||||
|
||||
using namespace repertory;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
std::size_t PROVIDER_INDEX{0U};
|
||||
#endif // _WIN32
|
||||
|
||||
@@ -36,7 +36,7 @@ auto main(int argc, char **argv) -> int {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
std::vector<const char *> args;
|
||||
{
|
||||
auto args_span = std::span(argv, static_cast<std::size_t>(argc));
|
||||
|
@@ -49,7 +49,7 @@ const auto DEFAULT_SIA_CONFIG = "{\n"
|
||||
" \"EnableCommDurationEvents\": false,\n"
|
||||
" \"EnableDriveEvents\": false,\n"
|
||||
" \"EnableMaxCacheSize\": false,\n"
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
" \"EnableMountManager\": false,\n"
|
||||
#endif
|
||||
" \"EventLevel\": \"normal\",\n"
|
||||
@@ -97,7 +97,7 @@ const auto DEFAULT_S3_CONFIG = "{\n"
|
||||
" \"EnableCommDurationEvents\": false,\n"
|
||||
" \"EnableDriveEvents\": false,\n"
|
||||
" \"EnableMaxCacheSize\": false,\n"
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
" \"EnableMountManager\": false,\n"
|
||||
#endif
|
||||
" \"EventLevel\": \"normal\",\n"
|
||||
@@ -294,7 +294,7 @@ TEST_F(config_test, enable_max_cache_size) {
|
||||
EXPECT_EQ(not original_value, config.get_enable_max_cache_size());
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
TEST_F(config_test, enable_mount_manager) {
|
||||
bool original_value;
|
||||
{
|
||||
@@ -575,14 +575,14 @@ TEST_F(config_test, default_data_directory) {
|
||||
app_config::default_data_directory(provider_type::sia),
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
const auto local_app_data = utils::get_environment_variable("localappdata");
|
||||
#endif
|
||||
#if __linux__
|
||||
#if defined(__linux__)
|
||||
const auto local_app_data =
|
||||
utils::path::combine(utils::get_environment_variable("HOME"), {".local"});
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__)
|
||||
const auto local_app_data = utils::path::combine(
|
||||
utils::get_environment_variable("HOME"), {"Library/Application Support"});
|
||||
#endif
|
||||
|
@@ -588,7 +588,7 @@ TEST(open_file, can_add_handle) {
|
||||
{"filesystem_item_opened", "filesystem_item_handle_opened"});
|
||||
|
||||
file_manager::open_file o(test_chunk_size, 0U, fsi, mp, um);
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
o.add(1u, {});
|
||||
EXPECT_EQ(nullptr, o.get_open_data(1u).directory_buffer);
|
||||
#else
|
||||
@@ -653,7 +653,7 @@ TEST(open_file, can_remove_handle) {
|
||||
});
|
||||
|
||||
file_manager::open_file o(test_chunk_size, 0U, fsi, mp, um);
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
o.add(1u, {});
|
||||
#else
|
||||
o.add(1u, O_RDWR | O_SYNC);
|
||||
|
@@ -39,7 +39,7 @@
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
namespace repertory {
|
||||
#ifdef PROJECT_ENABLE_TESTING
|
||||
#if defined(PROJECT_ENABLE_TESTING)
|
||||
auto file_manager::open(std::shared_ptr<i_closeable_open_file> of,
|
||||
const open_file_data &ofd, std::uint64_t &handle,
|
||||
std::shared_ptr<i_open_file> &f) -> api_error {
|
||||
@@ -154,7 +154,7 @@ TEST(file_manager, can_create_and_close_file) {
|
||||
EXPECT_STREQ("1", ee.get_handle().get<std::string>().c_str());
|
||||
});
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success,
|
||||
fm.create("/test_create.txt", meta, {}, handle, f));
|
||||
#else
|
||||
@@ -270,7 +270,7 @@ TEST(file_manager, can_open_and_close_file) {
|
||||
});
|
||||
|
||||
std::shared_ptr<i_open_file> f;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success,
|
||||
fm.open("/test_open.txt", false, {}, handle, f));
|
||||
#else
|
||||
@@ -360,7 +360,7 @@ TEST(file_manager, can_open_and_close_multiple_handles_for_same_file) {
|
||||
std::array<std::uint64_t, 4u> handles;
|
||||
for (std::uint8_t i = 0u; i < handles.size(); i++) {
|
||||
std::shared_ptr<i_open_file> f;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success,
|
||||
fm.open("/test_open.txt", false, {}, handles[i], f));
|
||||
#else
|
||||
@@ -440,7 +440,7 @@ TEST(file_manager, download_is_stored_after_write_if_partially_downloaded) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success, fm.open("/test_write_partial_download.txt",
|
||||
false, {}, handle, f));
|
||||
#else
|
||||
@@ -602,7 +602,7 @@ TEST(file_manager, upload_occurs_after_write_if_fully_downloaded) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success,
|
||||
fm.open("/test_write_full_download.txt", false, {}, handle, f));
|
||||
#else
|
||||
@@ -712,7 +712,7 @@ TEST(file_manager, can_evict_file) {
|
||||
return api_error::success;
|
||||
});
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success,
|
||||
fm.create("/test_evict.txt", meta, {}, handle, f));
|
||||
#else
|
||||
@@ -843,7 +843,7 @@ TEST(file_manager, evict_file_fails_if_file_is_open) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success,
|
||||
fm.open("/test_open.txt", false, {}, handle, f));
|
||||
#else
|
||||
@@ -978,7 +978,7 @@ TEST(file_manager, evict_file_fails_if_file_is_uploading) {
|
||||
return api_error::success;
|
||||
});
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success,
|
||||
fm.create("/test_evict.txt", meta, {}, handle, f));
|
||||
#else
|
||||
@@ -1081,7 +1081,7 @@ TEST(file_manager, evict_file_fails_if_file_is_modified) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
|
||||
#else
|
||||
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
|
||||
@@ -1129,7 +1129,7 @@ TEST(file_manager, evict_file_fails_if_file_is_not_complete) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
|
||||
#else
|
||||
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
|
||||
@@ -1198,7 +1198,7 @@ TEST(file_manager, file_is_not_opened_if_provider_create_file_fails) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::error,
|
||||
fm.create("/test_create.txt", meta, {}, handle, f));
|
||||
#else
|
||||
@@ -1230,7 +1230,7 @@ TEST(file_manager, create_fails_if_provider_create_is_unsuccessful) {
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f{};
|
||||
api_meta_map meta{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::error,
|
||||
fm.create("/test_create.txt", meta, {}, handle, f));
|
||||
#else
|
||||
@@ -1319,7 +1319,7 @@ TEST(file_manager,
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success, fm.open(non_writeable, {}, handle, f));
|
||||
EXPECT_CALL(*non_writeable, get_open_data())
|
||||
.WillOnce([&handle]() -> std::map<std::uint64_t, open_file_data> {
|
||||
@@ -1404,7 +1404,7 @@ TEST(file_manager, open_file_fails_if_provider_get_filesystem_item_fails) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::error, fm.open(of, {}, handle, f));
|
||||
#else
|
||||
EXPECT_EQ(api_error::error, fm.open(of, O_RDWR, handle, f));
|
||||
@@ -1455,7 +1455,7 @@ TEST(file_manager, open_file_fails_if_provider_set_item_meta_fails) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::error, fm.open(of, {}, handle, f));
|
||||
#else
|
||||
EXPECT_EQ(api_error::error, fm.open(of, O_RDWR, handle, f));
|
||||
@@ -1514,7 +1514,7 @@ TEST(file_manager, open_file_creates_source_path_if_empty) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
|
||||
#else
|
||||
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
|
||||
@@ -1569,7 +1569,7 @@ TEST(file_manager, open_file_first_file_handle_is_not_zero) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
|
||||
#else
|
||||
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
|
||||
@@ -1701,7 +1701,7 @@ TEST(file_manager, remove_file_fails_if_open_file_is_modified) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success, fm.open(of, {}, handle, f));
|
||||
#else
|
||||
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
|
||||
@@ -1762,7 +1762,7 @@ TEST(file_manager, file_is_closed_after_download_timeout) {
|
||||
|
||||
std::uint64_t handle{};
|
||||
std::shared_ptr<i_open_file> f;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(api_error::success,
|
||||
fm.open("/test_download_timeout.txt", false, {}, handle, f));
|
||||
#else
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#include "utils/file_utils.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
#ifndef ACCESSPERMS
|
||||
#if !defined(ACCESSPERMS)
|
||||
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
|
||||
#endif
|
||||
|
||||
@@ -278,7 +278,7 @@ static void test_ftruncate(const std::string &file_path) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
#if !defined(__APPLE__)
|
||||
static void test_fallocate(const std::string & /* api_path */,
|
||||
const std::string &file_path) {
|
||||
std::cout << __FUNCTION__ << std::endl;
|
||||
@@ -344,7 +344,7 @@ test_write_operations_fail_if_read_only(const std::string & /* api_path */,
|
||||
|
||||
EXPECT_EQ(-1, ftruncate(fd, 9u));
|
||||
|
||||
#ifndef __APPLE__
|
||||
#if !defined(__APPLE__)
|
||||
EXPECT_EQ(-1, fallocate(fd, 0, 0, 16));
|
||||
#endif
|
||||
|
||||
@@ -536,7 +536,7 @@ TEST(fuse_drive, all_tests) {
|
||||
|
||||
switch (idx) {
|
||||
case 0U: {
|
||||
#ifdef REPERTORY_ENABLE_S3
|
||||
#if defined(REPERTORY_ENABLE_S3)
|
||||
config_ptr =
|
||||
std::make_unique<app_config>(provider_type::s3, cfg_directory);
|
||||
{
|
||||
@@ -623,7 +623,7 @@ TEST(fuse_drive, all_tests) {
|
||||
test_ftruncate(file_path);
|
||||
unlink_file_and_test(file_path);
|
||||
|
||||
#ifndef __APPLE__
|
||||
#if !defined(__APPLE__)
|
||||
file_path = create_file_and_test(mount_location, "fallocate_file_test");
|
||||
test_fallocate(utils::path::create_api_path("fallocate_file_test"),
|
||||
file_path);
|
||||
|
@@ -40,7 +40,7 @@ TEST(lock_data, lock_and_unlock) {
|
||||
EXPECT_EQ(lock_result::success, l.grab_lock(10));
|
||||
}).join();
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
lock_data l2(provider_type::remote, "1");
|
||||
EXPECT_EQ(lock_result::success, l2.grab_lock());
|
||||
|
||||
@@ -49,7 +49,7 @@ TEST(lock_data, lock_and_unlock) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
TEST(lock_data, set_and_unset_mount_state) {
|
||||
lock_data l(provider_type::sia, "1");
|
||||
EXPECT_TRUE(l.set_mount_state(true, "C:", 99));
|
||||
|
@@ -27,21 +27,21 @@ namespace repertory {
|
||||
TEST(path_utils, combine) {
|
||||
auto s = utils::path::combine(R"(\test\path)", {});
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\test\path)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/test/path", s.c_str());
|
||||
#endif
|
||||
|
||||
s = utils::path::combine(R"(\test)", {R"(\path)"});
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\test\path)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/test/path", s.c_str());
|
||||
#endif
|
||||
|
||||
s = utils::path::combine(R"(\test)", {R"(\path)", R"(\again\)"});
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\test\path\again)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/test/path/again", s.c_str());
|
||||
@@ -82,49 +82,49 @@ TEST(path_utils, finalize) {
|
||||
EXPECT_STREQ("", s.c_str());
|
||||
|
||||
s = utils::path::finalize(R"(\)");
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/", s.c_str());
|
||||
#endif
|
||||
|
||||
s = utils::path::finalize("/");
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/", s.c_str());
|
||||
#endif
|
||||
|
||||
s = utils::path::finalize(R"(\\)");
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/", s.c_str());
|
||||
#endif
|
||||
|
||||
s = utils::path::finalize("//");
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/", s.c_str());
|
||||
#endif
|
||||
|
||||
s = utils::path::finalize("/cow///moose/////dog/chicken");
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
|
||||
#endif
|
||||
|
||||
s = utils::path::finalize("\\cow\\\\\\moose\\\\\\\\dog\\chicken/");
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
|
||||
#endif
|
||||
|
||||
s = utils::path::finalize("/cow\\\\/moose\\\\/\\dog\\chicken\\");
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ(R"(\cow\moose\dog\chicken)", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace {
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
using gid_t = std::uint32_t;
|
||||
using uid_t = std::uint32_t;
|
||||
static constexpr auto getgid() -> gid_t { return 0U; }
|
||||
@@ -435,7 +435,7 @@ static void get_directory_items(const app_config &cfg, i_provider &provider) {
|
||||
EXPECT_LT(file, list_decrypted.end());
|
||||
EXPECT_STREQ("/test.txt", file->api_path.c_str());
|
||||
EXPECT_STREQ("/", file->api_parent.c_str());
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(std::size_t(47U), file->size);
|
||||
#else
|
||||
EXPECT_EQ(std::size_t(46U), file->size);
|
||||
@@ -465,7 +465,7 @@ static void get_directory_items(const app_config &cfg, i_provider &provider) {
|
||||
EXPECT_LT(file2, list_decrypted2.end());
|
||||
EXPECT_STREQ("/sub10/moose.txt", file2->api_path.c_str());
|
||||
EXPECT_STREQ("/sub10", file2->api_parent.c_str());
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(std::size_t(46U), file2->size);
|
||||
#else
|
||||
EXPECT_EQ(std::size_t(45U), file2->size);
|
||||
@@ -514,7 +514,7 @@ static void get_file(const app_config &cfg, i_provider &provider) {
|
||||
|
||||
EXPECT_STREQ("/test.txt", file.api_path.c_str());
|
||||
EXPECT_STREQ("/", file.api_parent.c_str());
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(std::size_t(47U), file.file_size);
|
||||
#else
|
||||
EXPECT_EQ(std::size_t(46U), file.file_size);
|
||||
|
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
#include "test_common.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
#define NOT_IMPLEMENTED STATUS_NOT_IMPLEMENTED
|
||||
#include "drives/winfsp/i_winfsp_drive.hpp"
|
||||
#include "drives/winfsp/remotewinfsp/remote_server.hpp"
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
using namespace repertory;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
using namespace repertory::remote_winfsp;
|
||||
#else
|
||||
using namespace repertory::remote_fuse;
|
||||
@@ -77,7 +77,7 @@ static void chflags_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, ret);
|
||||
if (ret == 0) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_chflags(api_path.c_str(), 0));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_chflags(api_path.c_str(), 0));
|
||||
@@ -100,7 +100,7 @@ static void chmod_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, ret);
|
||||
if (ret == 0) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_chmod(api_path.c_str(), 0));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_chmod(api_path.c_str(), S_IRUSR | S_IWUSR));
|
||||
@@ -123,7 +123,7 @@ static void chown_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, ret);
|
||||
if (ret == 0) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_chown(api_path.c_str(), 0, 0));
|
||||
#else
|
||||
if (getuid() == 0) {
|
||||
@@ -205,7 +205,7 @@ static void fgetattr_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
|
||||
EXPECT_FALSE(directory);
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
struct _stat64 st1 {};
|
||||
_stat64(&test_file[0], &st1);
|
||||
#else
|
||||
@@ -244,7 +244,7 @@ static void fsetattr_x_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, ret);
|
||||
if (ret == 0) {
|
||||
remote::setattr_x attr{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED,
|
||||
client.fuse_fsetattr_x(api_path.c_str(), attr, handle));
|
||||
#else
|
||||
@@ -319,7 +319,7 @@ static void getattr_test(repertory::remote_fuse::remote_client &client) {
|
||||
remote::stat st{};
|
||||
EXPECT_EQ(0, client.fuse_getattr(api_path.c_str(), st, directory));
|
||||
EXPECT_FALSE(directory);
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
struct _stat64 st1 {};
|
||||
_stat64(&test_file[0], &st1);
|
||||
#else
|
||||
@@ -355,7 +355,7 @@ api_path = test_file.substr(mount_location_.size());
|
||||
api_path.c_str(), 0, remote::open_flags::Create |
|
||||
remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
#if _WIN32 || !HAS_SETXATTR || __APPLE__
|
||||
#if defined(_WIN32) || !defined(HAS_SETXATTR) || defined(__APPLE__)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_getxattr(api_path.c_str(), "test",
|
||||
nullptr, 0)); #else EXPECT_EQ(-EACCES, client.fuse_getxattr(api_path.c_str(),
|
||||
"test", nullptr, 0)); #endif
|
||||
@@ -396,7 +396,7 @@ static void getxtimes_test(repertory::remote_fuse::remote_client &client) {
|
||||
if (ret == 0) {
|
||||
remote::file_time bkuptime = 0;
|
||||
remote::file_time crtime = 0;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED,
|
||||
client.fuse_getxtimes(api_path.c_str(), bkuptime, crtime));
|
||||
#else
|
||||
@@ -423,7 +423,7 @@ api_path = test_file.substr(mount_location_.size());
|
||||
api_path.c_str(), 0, remote::open_flags::Create |
|
||||
remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
#if _WIN32 || !HAS_SETXATTR
|
||||
#if defined(_WIN32) || !defined(HAS_SETXATTR)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_listxattr(api_path.c_str(), nullptr,
|
||||
0)); #else EXPECT_EQ(-EIO, client.fuse_listxattr(api_path.c_str(), nullptr, 0));
|
||||
#endif
|
||||
@@ -438,7 +438,7 @@ static void mkdir_test(repertory::remote_fuse::remote_client &client) {
|
||||
const auto api_path = test_directory.substr(mount_location_.size());
|
||||
EXPECT_TRUE(utils::file::delete_directory(test_directory));
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
|
||||
@@ -455,7 +455,7 @@ static void open_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
||||
|
||||
remote::file_handle handle;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
const auto ret = client.fuse_create(
|
||||
api_path.c_str(), 0,
|
||||
remote::open_flags::create | remote::open_flags::read_write, handle);
|
||||
@@ -484,7 +484,7 @@ opendir_and_releasedir_test(repertory::remote_fuse::remote_client &client) {
|
||||
const auto api_path = test_directory.substr(mount_location_.size());
|
||||
EXPECT_TRUE(utils::file::delete_directory(test_directory));
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
|
||||
@@ -554,7 +554,7 @@ static void readdir_test(repertory::remote_fuse::remote_client &client) {
|
||||
const auto api_path = test_directory.substr(mount_location_.size());
|
||||
EXPECT_TRUE(utils::file::delete_directory(test_directory));
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
|
||||
@@ -587,7 +587,7 @@ api_path = test_file.substr(mount_location_.size());
|
||||
api_path.c_str(), 0, remote::open_flags::Create |
|
||||
remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
#if _WIN32 || !HAS_SETXATTR
|
||||
#if defined(_WIN32) || !defined(HAS_SETXATTR)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_removexattr(api_path.c_str(),
|
||||
"test")); #else EXPECT_EQ(-EACCES, client.fuse_removexattr(api_path.c_str(),
|
||||
"test")); #endif
|
||||
@@ -608,7 +608,7 @@ static void rename_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_TRUE(utils::file::retry_delete_file(renamed_test_file));
|
||||
|
||||
remote::file_handle handle;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
const auto ret = client.fuse_create(
|
||||
api_path.c_str(), 0,
|
||||
remote::open_flags::create | remote::open_flags::read_write, handle);
|
||||
@@ -637,7 +637,7 @@ static void rmdir_test(repertory::remote_fuse::remote_client &client) {
|
||||
const auto api_path = test_directory.substr(mount_location_.size());
|
||||
EXPECT_TRUE(utils::file::delete_directory(test_directory));
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), 0));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
|
||||
@@ -665,7 +665,7 @@ static void setattr_x_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
|
||||
remote::setattr_x attr{};
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setattr_x(api_path.c_str(), attr));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_setattr_x(api_path.c_str(), attr));
|
||||
@@ -690,7 +690,7 @@ static void setbkuptime_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
|
||||
remote::file_time ts = utils::get_file_time_now();
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setbkuptime(api_path.c_str(), ts));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_setbkuptime(api_path.c_str(), ts));
|
||||
@@ -715,7 +715,7 @@ static void setchgtime_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
|
||||
remote::file_time ts = utils::get_file_time_now();
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setchgtime(api_path.c_str(), ts));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_setchgtime(api_path.c_str(), ts));
|
||||
@@ -740,7 +740,7 @@ static void setcrtime_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
|
||||
remote::file_time ts = utils::get_file_time_now();
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED, client.fuse_setcrtime(api_path.c_str(), ts));
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_setcrtime(api_path.c_str(), ts));
|
||||
@@ -765,7 +765,7 @@ api_path = test_file.substr(mount_location_.size());
|
||||
api_path.c_str(), 0, remote::open_flags::Create |
|
||||
remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
#if _WIN32 || !HAS_SETXATTR
|
||||
#if defined(_WIN32) || !defined(HAS_SETXATTR)
|
||||
EXPECT_EQ(NOT_IMPLEMENTED,
|
||||
client.fuse_setxattr(api_path.c_str(), "test", "moose", 5, 0));
|
||||
#else
|
||||
@@ -796,7 +796,7 @@ remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
||||
utils::file::retry_delete_file(test_file);
|
||||
}*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
static void test_statfs(repertory::remote_fuse::remote_client &client,
|
||||
const i_winfsp_drive &drive) {
|
||||
#else
|
||||
@@ -823,7 +823,7 @@ static void test_statfs(repertory::remote_fuse::remote_client &client,
|
||||
EXPECT_EQ(st.f_favail, st.f_ffree);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
static void statfs_x_test(repertory::remote_fuse::remote_client &client,
|
||||
const i_winfsp_drive &drive) {
|
||||
#else
|
||||
@@ -860,7 +860,7 @@ static void truncate_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
||||
|
||||
remote::file_handle handle;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
const auto ret = client.fuse_create(
|
||||
api_path.c_str(), 0,
|
||||
remote::open_flags::create | remote::open_flags::read_write, handle);
|
||||
@@ -939,7 +939,7 @@ TEST(remote_fuse, all_tests) {
|
||||
config.set_event_level(event_level::verbose);
|
||||
|
||||
event_system::instance().start();
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
mount_location_ = std::string(__FILE__).substr(0, 2);
|
||||
mock_winfsp_drive drive(mount_location_);
|
||||
remote_server server(config, drive, mount_location_);
|
||||
|
@@ -24,7 +24,7 @@
|
||||
#include "drives/winfsp/i_winfsp_drive.hpp"
|
||||
#include "drives/winfsp/remotewinfsp/remote_client.hpp"
|
||||
#include "events/consumers/console_consumer.hpp"
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
#include "drives/winfsp/remotewinfsp/remote_server.hpp"
|
||||
#include "mocks/mock_winfsp_drive.hpp"
|
||||
#else
|
||||
@@ -409,7 +409,7 @@ static void set_basic_info_test(remote_client &client) {
|
||||
EXPECT_EQ(STATUS_SUCCESS, ret);
|
||||
|
||||
const auto attributes = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
SYSTEMTIME st{};
|
||||
::GetSystemTime(&st);
|
||||
|
||||
@@ -493,7 +493,7 @@ TEST(remote_winfsp, all_tests) {
|
||||
config.set_event_level(event_level::verbose);
|
||||
|
||||
event_system::instance().start();
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
mount_location_ = std::string(__FILE__).substr(0, 2);
|
||||
mock_winfsp_drive drive(mount_location_);
|
||||
remote_server server(config, drive, mount_location_);
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
namespace repertory {
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
TEST(utils, convert_api_date) {
|
||||
LARGE_INTEGER li{};
|
||||
li.QuadPart = utils::convert_api_date("2009-10-12T17:50:30.111Z");
|
||||
|
@@ -19,7 +19,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#if _WIN32
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "test_common.hpp"
|
||||
|
||||
@@ -333,7 +333,7 @@ TEST_F(winfsp_test, all_tests) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef REPERTORY_ENABLE_S3
|
||||
#if !defined(REPERTORY_ENABLE_S3)
|
||||
if (PROVIDER_INDEX == 1U) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user