From 7a94675ebefb981fd5da2aea981bbe92b8339460 Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Sun, 26 Feb 2023 12:14:53 +0300 Subject: [PATCH 001/158] minor fixes --- src/fs/file_actor.cpp | 1 + src/ui-daemon/main.cpp | 1 + tests/060-bep.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fs/file_actor.cpp b/src/fs/file_actor.cpp index 5bb1220e..b11a9582 100644 --- a/src/fs/file_actor.cpp +++ b/src/fs/file_actor.cpp @@ -8,6 +8,7 @@ #include "model/diff/modify/clone_file.h" #include "model/diff/modify/flush_file.h" #include "utils.h" +#include using namespace syncspirit::fs; diff --git a/src/ui-daemon/main.cpp b/src/ui-daemon/main.cpp index c3b5e4e2..c0c115a2 100644 --- a/src/ui-daemon/main.cpp +++ b/src/ui-daemon/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "syncspirit-config.h" #include "constants.h" diff --git a/tests/060-bep.cpp b/tests/060-bep.cpp index 01e49b20..928903e9 100644 --- a/tests/060-bep.cpp +++ b/tests/060-bep.cpp @@ -78,7 +78,7 @@ TEST_CASE("hello", "[bep]") { auto &msg = std::get(v.message); CHECK(msg->device_name() == "test-device"); CHECK(msg->client_name() == "syncspirit"); - CHECK(msg->client_version() == "v0.1.0"); + CHECK(msg->client_version() == "v0.2.0"); } } From 2d81968375224eab3e5dad941e8e10aa55faa31a Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Sun, 26 Feb 2023 17:15:10 +0300 Subject: [PATCH 002/158] try to use conan v2 --- CMakeLists.txt | 42 +++++++++----------- conanfile.txt | 24 ++++++++++++ src/config/utils.cpp | 2 +- src/constants.h | 9 +++-- src/hasher/hasher_actor.cpp | 2 +- src/hasher/hasher_proxy_actor.cpp | 2 +- src/model/block_info.cpp | 4 +- src/model/device.cpp | 4 +- src/model/device_id.h | 2 +- src/model/diff/load/close_transaction.cpp | 2 +- src/model/diff/modify/update_contact.cpp | 2 +- src/model/file_info.cpp | 4 +- src/model/folder.cpp | 6 +-- src/model/folder_info.cpp | 6 +-- src/model/ignored_device.cpp | 2 +- src/model/ignored_folder.cpp | 2 +- src/net/acceptor_actor.cpp | 1 + src/net/initiator_actor.cpp | 3 +- src/net/initiator_actor.h | 2 +- src/net/local_discovery_actor.cpp | 1 + src/net/messages.h | 2 +- src/net/peer_supervisor.cpp | 1 + src/net/upnp_actor.cpp | 1 + src/proto/bep_support.cpp | 18 ++++----- src/proto/bep_support.h | 2 +- src/proto/discovery_support.h | 2 +- src/proto/upnp_support.h | 2 +- src/transport/stream.h | 6 +-- src/ui-daemon/command/add_folder.cpp | 3 +- src/ui-daemon/governor_actor.cpp | 5 ++- src/utils/beast_support.h | 2 +- src/utils/error_code.h | 2 +- src/utils/format.hpp | 47 +++++++++++++++++++++++ tests/020-generic-map.cpp | 2 +- tests/077-initiator.cpp | 1 + tests/078-relay.cpp | 1 + 36 files changed, 147 insertions(+), 72 deletions(-) create mode 100644 conanfile.txt create mode 100644 src/utils/format.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ebea72f2..a7403631 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,10 @@ project (syncspirit) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # does not works because of pugixml -#set(CMAKE_CXX_VISIBILITY_PRESET hidden) -#set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -#cmake_policy(SET CMP0063 NEW) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +cmake_policy(SET CMP0063 NEW) +cmake_policy(SET CMP0077 NEW) include(GenerateExportHeader) set(CMAKE_POSITION_INDEPENDENT_CODE True) @@ -23,6 +24,14 @@ find_package( find_package(OpenSSL REQUIRED) find_package(Protobuf REQUIRED) find_package(ZLIB REQUIRED) +find_package(rotor COMPONENTS asio thread REQUIRED) +find_package(lz4) +find_package(fmt) +find_package(spdlog) +find_package(pugixml) +find_package(uriparser) +find_package(tomlplusplus) +find_package(nlohmann_json) set(SYNCSPIRIT_VERSION "v0.2.0") @@ -171,28 +180,12 @@ set(MDBX_BUILD_TOOLS false CACHE BOOL "MDBX_BUILD_TOOLS") set(MDBX_ENABLE_TESTS false CACHE BOOL "MDBX_ENABLE_TESTS") set(MDBX_BUILD_CXX false CACHE BOOL "MDBX_BUILD_CXX") -cmake_policy(SET CMP0077 NEW) set(PUGIXML_NO_EXCEPTIONS on) -add_subdirectory("lib/spdlog") -add_subdirectory("lib/lz4/build/cmake/") -add_subdirectory("lib/pugixml") -add_subdirectory("lib/rotor") -add_subdirectory("lib/uriparser") add_subdirectory("lib/mbdx") - target_include_directories(syncspirit_lib PUBLIC - ${syncspirit_SOURCE_DIR}/lib/rotor/include - ${syncspirit_SOURCE_DIR}/lib/spdlog/include - ${syncspirit_SOURCE_DIR}/lib/spdlog/include/spdlog/ - ${syncspirit_SOURCE_DIR}/lib/json/include - ${syncspirit_SOURCE_DIR}/lib/pugixml/src - ${syncspirit_SOURCE_DIR}/lib/uriparser/include - ${syncspirit_SOURCE_DIR}/lib/tomlplusplus/include - ${syncspirit_SOURCE_DIR}/lib/lz4/lib ${syncspirit_SOURCE_DIR}/lib/mbdx - ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src @@ -202,17 +195,18 @@ target_link_libraries(syncspirit_lib syncspirit_pb rotor::asio rotor::thread - pugixml + pugixml::pugixml Boost::iostreams Boost::filesystem Boost::program_options Boost::system - ${Boost_LIBRARIES} OpenSSL::SSL + fmt::fmt spdlog::spdlog - uriparser - lz4_static - ZLIB::ZLIB + uriparser::uriparser + tomlplusplus::tomlplusplus + nlohmann_json::nlohmann_json + lz4::lz4 mdbx-static $<$:iphlpapi> $<$:ws2_32> diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 00000000..04bb3efc --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,24 @@ +[tool_requires] +catch2/3.3.1 + + +[requires] +boost/1.81.0 +lz4/1.9.4 +nlohmann_json/3.11.2 +pugixml/1.13 +rotor/0.25 +spdlog/1.11.0 +tomlplusplus/3.3.0 +uriparser/0.9.7 + + +[options] +pugixml/1.13no_exceptions=True +rotor/0.25:enable_asio=True +rotor/0.25:enable_thread=True + +[generators] +CMakeDeps +CMakeToolchain + diff --git a/src/config/utils.cpp b/src/config/utils.cpp index 1d334ce4..a75c87b6 100644 --- a/src/config/utils.cpp +++ b/src/config/utils.cpp @@ -465,7 +465,7 @@ outcome::result generate_config(const boost::filesystem::path &config_pa spdlog::info("creating directory {}", dir.string()); bfs::create_directories(dir, ec); if (ec) { - spdlog::error("cannot create dirs: {}", ec); + spdlog::error("cannot create dirs: {}", ec.message()); return ec; } } diff --git a/src/constants.h b/src/constants.h index 33b9a4c5..d7d136b3 100644 --- a/src/constants.h +++ b/src/constants.h @@ -4,13 +4,14 @@ #pragma once #include +#include "syncspirit-export.h" namespace syncspirit::constants { static const constexpr std::uint32_t bep_magic = 0x2EA7D90B; static const constexpr std::uint32_t rescan_interval = 3600; -extern const char *client_name; -extern const char *issuer_name; -extern const char *protocol_name; -extern const char *relay_protocol_name; +SYNCSPIRIT_API extern const char *client_name; +SYNCSPIRIT_API extern const char *issuer_name; +SYNCSPIRIT_API extern const char *protocol_name; +SYNCSPIRIT_API extern const char *relay_protocol_name; } // namespace syncspirit::constants diff --git a/src/hasher/hasher_actor.cpp b/src/hasher/hasher_actor.cpp index 19ea914c..900e7412 100644 --- a/src/hasher/hasher_actor.cpp +++ b/src/hasher/hasher_actor.cpp @@ -3,7 +3,7 @@ #include "hasher_actor.h" #include "../utils/tls.h" -#include +#include #include using namespace syncspirit::hasher; diff --git a/src/hasher/hasher_proxy_actor.cpp b/src/hasher/hasher_proxy_actor.cpp index 089f4109..553ade2d 100644 --- a/src/hasher/hasher_proxy_actor.cpp +++ b/src/hasher/hasher_proxy_actor.cpp @@ -3,7 +3,7 @@ #include "hasher_proxy_actor.h" #include "../utils/error_code.h" -#include +#include #include using namespace syncspirit::hasher; diff --git a/src/model/block_info.cpp b/src/model/block_info.cpp index 98ffe309..d281714c 100644 --- a/src/model/block_info.cpp +++ b/src/model/block_info.cpp @@ -6,7 +6,7 @@ #include "structs.pb.h" #include "../db/prefix.h" #include "misc/error_code.h" -#include +#include namespace syncspirit::model { @@ -109,6 +109,6 @@ void block_info_t::lock() noexcept { ++locked; } void block_info_t::unlock() noexcept { --locked; } -template <> std::string_view get_index<0>(const block_info_ptr_t &item) noexcept { return item->get_hash(); } +template <> SYNCSPIRIT_API std::string_view get_index<0>(const block_info_ptr_t &item) noexcept { return item->get_hash(); } } // namespace syncspirit::model diff --git a/src/model/device.cpp b/src/model/device.cpp index 8be342f6..9a71c90b 100644 --- a/src/model/device.cpp +++ b/src/model/device.cpp @@ -96,9 +96,9 @@ local_device_t::local_device_t(const device_id_t &device_id, std::string_view na std::string_view local_device_t::get_key() const noexcept { return local_device_id.get_key(); } -template <> std::string_view get_index<0, device_ptr_t>(const device_ptr_t &item) noexcept { return item->get_key(); } +template <> SYNCSPIRIT_API std::string_view get_index<0, device_ptr_t>(const device_ptr_t &item) noexcept { return item->get_key(); } -template <> std::string_view get_index<1, device_ptr_t>(const device_ptr_t &item) noexcept { +template <> SYNCSPIRIT_API std::string_view get_index<1, device_ptr_t>(const device_ptr_t &item) noexcept { return item->device_id().get_sha256(); } diff --git a/src/model/device_id.h b/src/model/device_id.h index 84faca25..9a521fcf 100644 --- a/src/model/device_id.h +++ b/src/model/device_id.h @@ -59,7 +59,7 @@ struct SYNCSPIRIT_API device_id_t { char hash[data_length]; }; -extern const device_id_t local_device_id; +SYNCSPIRIT_API extern const device_id_t local_device_id; } // namespace syncspirit::model diff --git a/src/model/diff/load/close_transaction.cpp b/src/model/diff/load/close_transaction.cpp index c432e86b..6f0e8b57 100644 --- a/src/model/diff/load/close_transaction.cpp +++ b/src/model/diff/load/close_transaction.cpp @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou #include "close_transaction.h" -#include +#include using namespace syncspirit::model::diff::load; diff --git a/src/model/diff/modify/update_contact.cpp b/src/model/diff/modify/update_contact.cpp index f5d95c83..8ebdc877 100644 --- a/src/model/diff/modify/update_contact.cpp +++ b/src/model/diff/modify/update_contact.cpp @@ -4,7 +4,7 @@ #include "update_contact.h" #include "../contact_visitor.h" #include "../../cluster.h" -#include +#include using namespace syncspirit::model::diff::modify; diff --git a/src/model/file_info.cpp b/src/model/file_info.cpp index ac95e7ac..52da42b9 100644 --- a/src/model/file_info.cpp +++ b/src/model/file_info.cpp @@ -360,8 +360,8 @@ bool file_info_t::need_download(const file_info_t &other) noexcept { file_info_ptr_t file_info_t::actualize() const noexcept { return folder_info->get_file_infos().get(get_uuid()); } -template <> std::string_view get_index<0>(const file_info_ptr_t &item) noexcept { return item->get_uuid(); } -template <> std::string_view get_index<1>(const file_info_ptr_t &item) noexcept { return item->get_name(); } +template <> SYNCSPIRIT_API std::string_view get_index<0>(const file_info_ptr_t &item) noexcept { return item->get_uuid(); } +template <> SYNCSPIRIT_API std::string_view get_index<1>(const file_info_ptr_t &item) noexcept { return item->get_name(); } file_info_ptr_t file_infos_map_t::by_name(std::string_view name) noexcept { return get<1>(name); } diff --git a/src/model/folder.cpp b/src/model/folder.cpp index 8099d5e4..abd9a9cb 100644 --- a/src/model/folder.cpp +++ b/src/model/folder.cpp @@ -5,7 +5,7 @@ #include "db/utils.h" #include "db/prefix.h" #include "structs.pb.h" -#include +#include #include "misc/error_code.h" #ifdef uuid_t @@ -92,8 +92,8 @@ std::optional folder_t::generate(const model::device_t &device) c return r; } -template <> std::string_view get_index<0>(const folder_ptr_t &item) noexcept { return item->get_key(); } -template <> std::string_view get_index<1>(const folder_ptr_t &item) noexcept { return item->get_id(); } +template <> SYNCSPIRIT_API std::string_view get_index<0>(const folder_ptr_t &item) noexcept { return item->get_key(); } +template <> SYNCSPIRIT_API std::string_view get_index<1>(const folder_ptr_t &item) noexcept { return item->get_id(); } folder_ptr_t folders_map_t::by_id(std::string_view id) const noexcept { return get<1>(id); } diff --git a/src/model/folder_info.cpp b/src/model/folder_info.cpp index a99abf07..bb2ff97f 100644 --- a/src/model/folder_info.cpp +++ b/src/model/folder_info.cpp @@ -6,7 +6,7 @@ #include "structs.pb.h" #include "../db/prefix.h" #include "misc/error_code.h" -#include +#include #ifdef uuid_t #undef uuid_t @@ -113,8 +113,8 @@ folder_info_ptr_t folder_infos_map_t::by_device_id(std::string_view device_id) c return get<1>(device_id); } -template <> std::string_view get_index<0>(const folder_info_ptr_t &item) noexcept { return item->get_uuid(); } -template <> std::string_view get_index<1>(const folder_info_ptr_t &item) noexcept { +template <> SYNCSPIRIT_API std::string_view get_index<0>(const folder_info_ptr_t &item) noexcept { return item->get_uuid(); } +template <> SYNCSPIRIT_API std::string_view get_index<1>(const folder_info_ptr_t &item) noexcept { return item->get_device()->device_id().get_sha256(); } diff --git a/src/model/ignored_device.cpp b/src/model/ignored_device.cpp index 6b1e7c31..f2c3752e 100644 --- a/src/model/ignored_device.cpp +++ b/src/model/ignored_device.cpp @@ -48,7 +48,7 @@ std::string ignored_device_t::serialize() noexcept { return std::string(&c, 1); } -template <> std::string_view get_index<0, ignored_device_ptr_t>(const ignored_device_ptr_t &item) noexcept { +template <> SYNCSPIRIT_API std::string_view get_index<0, ignored_device_ptr_t>(const ignored_device_ptr_t &item) noexcept { return item->get_sha256(); } diff --git a/src/model/ignored_folder.cpp b/src/model/ignored_folder.cpp index 1b9380c4..d50afa45 100644 --- a/src/model/ignored_folder.cpp +++ b/src/model/ignored_folder.cpp @@ -65,7 +65,7 @@ std::string ignored_folder_t::serialize() noexcept { return r.SerializeAsString(); } -template <> std::string_view get_index<0, ignored_folder_ptr_t>(const ignored_folder_ptr_t &item) noexcept { +template <> SYNCSPIRIT_API std::string_view get_index<0, ignored_folder_ptr_t>(const ignored_folder_ptr_t &item) noexcept { return item->get_id(); } diff --git a/src/net/acceptor_actor.cpp b/src/net/acceptor_actor.cpp index cd0919ff..db3089a0 100644 --- a/src/net/acceptor_actor.cpp +++ b/src/net/acceptor_actor.cpp @@ -3,6 +3,7 @@ #include "acceptor_actor.h" #include "names.h" +#include "utils/format.hpp" #include "utils/error_code.h" #include "utils/network_interface.h" #include "model/messages.h" diff --git a/src/net/initiator_actor.cpp b/src/net/initiator_actor.cpp index 786f025e..0f7bd108 100644 --- a/src/net/initiator_actor.cpp +++ b/src/net/initiator_actor.cpp @@ -4,11 +4,12 @@ #include "model/messages.h" #include "proto/relay_support.h" #include "utils/error_code.h" +#include "utils/format.hpp" #include "model/diff/peer/peer_state.h" #include #include #include -#include +#include using namespace syncspirit::net; diff --git a/src/net/initiator_actor.h b/src/net/initiator_actor.h index 431f3757..34710b75 100644 --- a/src/net/initiator_actor.h +++ b/src/net/initiator_actor.h @@ -80,7 +80,7 @@ template struct initiator_actor_config_builder_t : r::actor_con } }; -struct initiator_actor_t : r::actor_base_t { +struct SYNCSPIRIT_API initiator_actor_t : r::actor_base_t { using config_t = initiator_actor_config_t; template using config_builder_t = initiator_actor_config_builder_t; diff --git a/src/net/local_discovery_actor.cpp b/src/net/local_discovery_actor.cpp index d652c79e..a330fc73 100644 --- a/src/net/local_discovery_actor.cpp +++ b/src/net/local_discovery_actor.cpp @@ -5,6 +5,7 @@ #include "names.h" #include "proto/bep_support.h" #include "utils/error_code.h" +#include "utils/format.hpp" #include "model/diff/modify/update_contact.h" #include "model/messages.h" diff --git a/src/net/messages.h b/src/net/messages.h index 33cb3140..d3063507 100644 --- a/src/net/messages.h +++ b/src/net/messages.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include "model/misc/upnp.h" #include "model/cluster.h" #include "transport/base.h" diff --git a/src/net/peer_supervisor.cpp b/src/net/peer_supervisor.cpp index e6f4d23a..4270551b 100644 --- a/src/net/peer_supervisor.cpp +++ b/src/net/peer_supervisor.cpp @@ -6,6 +6,7 @@ #include "initiator_actor.h" #include "names.h" #include "utils/error_code.h" +#include "utils/format.hpp" #include "model/diff/peer/peer_state.h" #include "model/diff/modify/connect_request.h" #include "model/diff/modify/relay_connect_request.h" diff --git a/src/net/upnp_actor.cpp b/src/net/upnp_actor.cpp index e64d2dc6..18fc158e 100644 --- a/src/net/upnp_actor.cpp +++ b/src/net/upnp_actor.cpp @@ -4,6 +4,7 @@ #include "upnp_actor.h" #include "proto/upnp_support.h" #include "utils/error_code.h" +#include "utils/format.hpp" #include "names.h" #include "model/messages.h" #include "model/diff/modify/update_contact.h" diff --git a/src/proto/bep_support.cpp b/src/proto/bep_support.cpp index 8d7255c5..c57ebf55 100644 --- a/src/proto/bep_support.cpp +++ b/src/proto/bep_support.cpp @@ -218,7 +218,7 @@ outcome::result parse_announce(const asio::const_buffer &buff return std::move(msg); } -template +template SYNCSPIRIT_API void serialize(fmt::memory_buffer &buff, const Message &message, proto::MessageCompression compression) noexcept { using type = typename M2T::type; proto::Header header; @@ -239,21 +239,21 @@ void serialize(fmt::memory_buffer &buff, const Message &message, proto::MessageC message.SerializeToArray(ptr, message_sz); } -template void serialize(fmt::memory_buffer &buff, const proto::ClusterConfig &message, +template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::ClusterConfig &message, proto::MessageCompression compression) noexcept; -template void serialize(fmt::memory_buffer &buff, const proto::Index &message, +template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Index &message, proto::MessageCompression compression) noexcept; -template void serialize(fmt::memory_buffer &buff, const proto::IndexUpdate &message, +template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::IndexUpdate &message, proto::MessageCompression compression) noexcept; -template void serialize(fmt::memory_buffer &buff, const proto::Request &message, +template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Request &message, proto::MessageCompression compression) noexcept; -template void serialize(fmt::memory_buffer &buff, const proto::Response &message, +template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Response &message, proto::MessageCompression compression) noexcept; -template void serialize(fmt::memory_buffer &buff, const proto::DownloadProgress &message, +template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::DownloadProgress &message, proto::MessageCompression compression) noexcept; -template void serialize(fmt::memory_buffer &buff, const proto::Ping &message, +template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Ping &message, proto::MessageCompression compression) noexcept; -template void serialize(fmt::memory_buffer &buff, const proto::Close &message, +template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Close &message, proto::MessageCompression compression) noexcept; } // namespace syncspirit::proto diff --git a/src/proto/bep_support.h b/src/proto/bep_support.h index d5f28645..f15a6aff 100644 --- a/src/proto/bep_support.h +++ b/src/proto/bep_support.h @@ -3,7 +3,7 @@ #pragma once -#include +#include #include #include #include diff --git a/src/proto/discovery_support.h b/src/proto/discovery_support.h index 4191fa5c..97532499 100644 --- a/src/proto/discovery_support.h +++ b/src/proto/discovery_support.h @@ -5,7 +5,7 @@ #include "utils/uri.h" #include "model/device_id.h" #include "syncspirit-export.h" -#include +#include #include #include #include diff --git a/src/proto/upnp_support.h b/src/proto/upnp_support.h index 8d19c6c4..478ddaa6 100644 --- a/src/proto/upnp_support.h +++ b/src/proto/upnp_support.h @@ -5,7 +5,7 @@ #include "utils/uri.h" #include "model/misc/upnp.h" #include "syncspirit-export.h" -#include +#include #include #include #include diff --git a/src/transport/stream.h b/src/transport/stream.h index 548f7236..c12e0a78 100644 --- a/src/transport/stream.h +++ b/src/transport/stream.h @@ -24,11 +24,11 @@ struct upgradeable_stream_base_t : stream_base_t { virtual stream_sp_t upgrade(ssl_junction_t &ssl, bool active) noexcept = 0; }; -stream_sp_t initiate_tls_active(ra::supervisor_asio_t &supervisor, const utils::key_pair_t &my_keys, +stream_sp_t SYNCSPIRIT_API initiate_tls_active(ra::supervisor_asio_t &supervisor, const utils::key_pair_t &my_keys, const model::device_id_t &expected_peer, const utils::URI &uri, bool sni = false, std::string_view alpn = "") noexcept; -stream_sp_t initiate_tls_passive(ra::supervisor_asio_t &supervisor, const utils::key_pair_t &my_keys, +stream_sp_t SYNCSPIRIT_API initiate_tls_passive(ra::supervisor_asio_t &supervisor, const utils::key_pair_t &my_keys, tcp::socket sock) noexcept; -stream_sp_t initiate_stream(transport_config_t &config) noexcept; +stream_sp_t SYNCSPIRIT_API initiate_stream(transport_config_t &config) noexcept; } // namespace syncspirit::transport diff --git a/src/ui-daemon/command/add_folder.cpp b/src/ui-daemon/command/add_folder.cpp index 417b9210..55af5da1 100644 --- a/src/ui-daemon/command/add_folder.cpp +++ b/src/ui-daemon/command/add_folder.cpp @@ -4,7 +4,8 @@ #include "add_folder.h" #include "../governor_actor.h" #include "../error_code.h" -#include "../../utils/base32.h" +#include "utils/format.hpp" +#include "utils/base32.h" #include "model/diff/modify/create_folder.h" #include "pair_iterator.h" #include diff --git a/src/ui-daemon/governor_actor.cpp b/src/ui-daemon/governor_actor.cpp index fdb9b461..874fb487 100644 --- a/src/ui-daemon/governor_actor.cpp +++ b/src/ui-daemon/governor_actor.cpp @@ -2,8 +2,9 @@ // SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou #include "governor_actor.h" -#include "../net/names.h" -#include "../utils/error_code.h" +#include "net/names.h" +#include "utils/format.hpp" +#include "utils/error_code.h" using namespace syncspirit::daemon; diff --git a/src/utils/beast_support.h b/src/utils/beast_support.h index d7c695cb..42dfeec9 100644 --- a/src/utils/beast_support.h +++ b/src/utils/beast_support.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include "syncspirit-export.h" namespace syncspirit::utils { diff --git a/src/utils/error_code.h b/src/utils/error_code.h index ce4a9b1f..2ad85784 100644 --- a/src/utils/error_code.h +++ b/src/utils/error_code.h @@ -145,7 +145,7 @@ inline boost::system::error_code make_error_code(request_error_code_t e) { return {static_cast(e), request_error_code_category()}; } -boost::system::error_code adapt(const std::error_code &ec) noexcept; +SYNCSPIRIT_API boost::system::error_code adapt(const std::error_code &ec) noexcept; } // namespace syncspirit::utils diff --git a/src/utils/format.hpp b/src/utils/format.hpp new file mode 100644 index 00000000..89052fb1 --- /dev/null +++ b/src/utils/format.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include +#include + +#include + +template <> struct fmt::formatter { + using Path = boost::filesystem::path; + + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.end(); + } + + template + auto format(const Path& path, FormatContext& ctx) const -> decltype(ctx.out()) { + return fmt::format_to(ctx.out(), "{}", path.string()); + } +}; + +template <> struct fmt::formatter { + using Address = boost::asio::ip::address; + + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.end(); + } + + template + auto format(const Address& addr, FormatContext& ctx) const -> decltype(ctx.out()) { + return fmt::format_to(ctx.out(), "{}", addr.to_string()); + } +}; + +template struct fmt::formatter> { + + using EndPoint = boost::asio::ip::basic_endpoint; + + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.end(); + } + + template + auto format(const EndPoint& p, FormatContext& ctx) const -> decltype(ctx.out()) { + return fmt::format_to(ctx.out(), "{}:{}", p.address(), p.port()); + } +}; + diff --git a/tests/020-generic-map.cpp b/tests/020-generic-map.cpp index 3b387769..a9193bea 100644 --- a/tests/020-generic-map.cpp +++ b/tests/020-generic-map.cpp @@ -91,7 +91,7 @@ using item_map_t = syncspirit::model::generic_map_t; namespace syncspirit::model { -template <> inline std::string_view get_index<0>(const item_t &item) noexcept { return item.key; } +template <> SYNCSPIRIT_API inline std::string_view get_index<0>(const item_t &item) noexcept { return item.key; } } // namespace syncspirit::model diff --git a/tests/077-initiator.cpp b/tests/077-initiator.cpp index 6f642138..1dc44c7e 100644 --- a/tests/077-initiator.cpp +++ b/tests/077-initiator.cpp @@ -3,6 +3,7 @@ #include "access.h" #include "utils/tls.h" +#include "utils/format.hpp" #include "model/cluster.h" #include "model/messages.h" #include "net/names.h" diff --git a/tests/078-relay.cpp b/tests/078-relay.cpp index f8e30d2c..94803960 100644 --- a/tests/078-relay.cpp +++ b/tests/078-relay.cpp @@ -3,6 +3,7 @@ #include "access.h" #include "utils/tls.h" +#include "utils/format.hpp" #include "model/cluster.h" #include "model/messages.h" #include "model/diff/modify/relay_connect_request.h" From 81ab3f8c271a80cd6b1f27951e2173016284b758 Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Sun, 26 Feb 2023 17:20:47 +0300 Subject: [PATCH 003/158] format --- src/model/block_info.cpp | 4 ++- src/model/device.cpp | 4 ++- src/model/file_info.cpp | 8 ++++-- src/model/folder_info.cpp | 4 ++- src/model/ignored_device.cpp | 3 +- src/model/ignored_folder.cpp | 3 +- src/proto/bep_support.cpp | 21 +++++++------- src/transport/stream.h | 6 ++-- src/utils/format.hpp | 37 ++++++++++-------------- tests/access.h | 11 ++++---- tests/diff-builder.cpp | 54 +++++++++++++++++------------------- tests/diff-builder.h | 50 ++++++++++++++++++--------------- tests/test-db.cpp | 7 ++--- tests/test-db.h | 3 +- tests/test-main.cpp | 12 +++----- tests/test-utils.h | 1 - tests/test_supervisor.cpp | 43 +++++++++++++--------------- tests/test_supervisor.h | 13 ++++----- 18 files changed, 138 insertions(+), 146 deletions(-) diff --git a/src/model/block_info.cpp b/src/model/block_info.cpp index d281714c..e3e1ce7b 100644 --- a/src/model/block_info.cpp +++ b/src/model/block_info.cpp @@ -109,6 +109,8 @@ void block_info_t::lock() noexcept { ++locked; } void block_info_t::unlock() noexcept { --locked; } -template <> SYNCSPIRIT_API std::string_view get_index<0>(const block_info_ptr_t &item) noexcept { return item->get_hash(); } +template <> SYNCSPIRIT_API std::string_view get_index<0>(const block_info_ptr_t &item) noexcept { + return item->get_hash(); +} } // namespace syncspirit::model diff --git a/src/model/device.cpp b/src/model/device.cpp index 9a71c90b..7dd649fb 100644 --- a/src/model/device.cpp +++ b/src/model/device.cpp @@ -96,7 +96,9 @@ local_device_t::local_device_t(const device_id_t &device_id, std::string_view na std::string_view local_device_t::get_key() const noexcept { return local_device_id.get_key(); } -template <> SYNCSPIRIT_API std::string_view get_index<0, device_ptr_t>(const device_ptr_t &item) noexcept { return item->get_key(); } +template <> SYNCSPIRIT_API std::string_view get_index<0, device_ptr_t>(const device_ptr_t &item) noexcept { + return item->get_key(); +} template <> SYNCSPIRIT_API std::string_view get_index<1, device_ptr_t>(const device_ptr_t &item) noexcept { return item->device_id().get_sha256(); diff --git a/src/model/file_info.cpp b/src/model/file_info.cpp index 52da42b9..bfaf20b5 100644 --- a/src/model/file_info.cpp +++ b/src/model/file_info.cpp @@ -360,8 +360,12 @@ bool file_info_t::need_download(const file_info_t &other) noexcept { file_info_ptr_t file_info_t::actualize() const noexcept { return folder_info->get_file_infos().get(get_uuid()); } -template <> SYNCSPIRIT_API std::string_view get_index<0>(const file_info_ptr_t &item) noexcept { return item->get_uuid(); } -template <> SYNCSPIRIT_API std::string_view get_index<1>(const file_info_ptr_t &item) noexcept { return item->get_name(); } +template <> SYNCSPIRIT_API std::string_view get_index<0>(const file_info_ptr_t &item) noexcept { + return item->get_uuid(); +} +template <> SYNCSPIRIT_API std::string_view get_index<1>(const file_info_ptr_t &item) noexcept { + return item->get_name(); +} file_info_ptr_t file_infos_map_t::by_name(std::string_view name) noexcept { return get<1>(name); } diff --git a/src/model/folder_info.cpp b/src/model/folder_info.cpp index bb2ff97f..f8d72c9b 100644 --- a/src/model/folder_info.cpp +++ b/src/model/folder_info.cpp @@ -113,7 +113,9 @@ folder_info_ptr_t folder_infos_map_t::by_device_id(std::string_view device_id) c return get<1>(device_id); } -template <> SYNCSPIRIT_API std::string_view get_index<0>(const folder_info_ptr_t &item) noexcept { return item->get_uuid(); } +template <> SYNCSPIRIT_API std::string_view get_index<0>(const folder_info_ptr_t &item) noexcept { + return item->get_uuid(); +} template <> SYNCSPIRIT_API std::string_view get_index<1>(const folder_info_ptr_t &item) noexcept { return item->get_device()->device_id().get_sha256(); } diff --git a/src/model/ignored_device.cpp b/src/model/ignored_device.cpp index f2c3752e..362c5157 100644 --- a/src/model/ignored_device.cpp +++ b/src/model/ignored_device.cpp @@ -48,7 +48,8 @@ std::string ignored_device_t::serialize() noexcept { return std::string(&c, 1); } -template <> SYNCSPIRIT_API std::string_view get_index<0, ignored_device_ptr_t>(const ignored_device_ptr_t &item) noexcept { +template <> +SYNCSPIRIT_API std::string_view get_index<0, ignored_device_ptr_t>(const ignored_device_ptr_t &item) noexcept { return item->get_sha256(); } diff --git a/src/model/ignored_folder.cpp b/src/model/ignored_folder.cpp index d50afa45..633c5fb5 100644 --- a/src/model/ignored_folder.cpp +++ b/src/model/ignored_folder.cpp @@ -65,7 +65,8 @@ std::string ignored_folder_t::serialize() noexcept { return r.SerializeAsString(); } -template <> SYNCSPIRIT_API std::string_view get_index<0, ignored_folder_ptr_t>(const ignored_folder_ptr_t &item) noexcept { +template <> +SYNCSPIRIT_API std::string_view get_index<0, ignored_folder_ptr_t>(const ignored_folder_ptr_t &item) noexcept { return item->get_id(); } diff --git a/src/proto/bep_support.cpp b/src/proto/bep_support.cpp index c57ebf55..842dea6b 100644 --- a/src/proto/bep_support.cpp +++ b/src/proto/bep_support.cpp @@ -218,8 +218,9 @@ outcome::result parse_announce(const asio::const_buffer &buff return std::move(msg); } -template SYNCSPIRIT_API -void serialize(fmt::memory_buffer &buff, const Message &message, proto::MessageCompression compression) noexcept { +template +SYNCSPIRIT_API void serialize(fmt::memory_buffer &buff, const Message &message, + proto::MessageCompression compression) noexcept { using type = typename M2T::type; proto::Header header; header.set_compression(compression); @@ -240,20 +241,20 @@ void serialize(fmt::memory_buffer &buff, const Message &message, proto::MessageC } template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::ClusterConfig &message, - proto::MessageCompression compression) noexcept; + proto::MessageCompression compression) noexcept; template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Index &message, - proto::MessageCompression compression) noexcept; + proto::MessageCompression compression) noexcept; template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::IndexUpdate &message, - proto::MessageCompression compression) noexcept; + proto::MessageCompression compression) noexcept; template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Request &message, - proto::MessageCompression compression) noexcept; + proto::MessageCompression compression) noexcept; template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Response &message, - proto::MessageCompression compression) noexcept; + proto::MessageCompression compression) noexcept; template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::DownloadProgress &message, - proto::MessageCompression compression) noexcept; + proto::MessageCompression compression) noexcept; template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Ping &message, - proto::MessageCompression compression) noexcept; + proto::MessageCompression compression) noexcept; template void SYNCSPIRIT_API serialize(fmt::memory_buffer &buff, const proto::Close &message, - proto::MessageCompression compression) noexcept; + proto::MessageCompression compression) noexcept; } // namespace syncspirit::proto diff --git a/src/transport/stream.h b/src/transport/stream.h index c12e0a78..6d6cfbf9 100644 --- a/src/transport/stream.h +++ b/src/transport/stream.h @@ -25,10 +25,10 @@ struct upgradeable_stream_base_t : stream_base_t { }; stream_sp_t SYNCSPIRIT_API initiate_tls_active(ra::supervisor_asio_t &supervisor, const utils::key_pair_t &my_keys, - const model::device_id_t &expected_peer, const utils::URI &uri, bool sni = false, - std::string_view alpn = "") noexcept; + const model::device_id_t &expected_peer, const utils::URI &uri, + bool sni = false, std::string_view alpn = "") noexcept; stream_sp_t SYNCSPIRIT_API initiate_tls_passive(ra::supervisor_asio_t &supervisor, const utils::key_pair_t &my_keys, - tcp::socket sock) noexcept; + tcp::socket sock) noexcept; stream_sp_t SYNCSPIRIT_API initiate_stream(transport_config_t &config) noexcept; } // namespace syncspirit::transport diff --git a/src/utils/format.hpp b/src/utils/format.hpp index 89052fb1..582d80af 100644 --- a/src/utils/format.hpp +++ b/src/utils/format.hpp @@ -8,40 +8,31 @@ template <> struct fmt::formatter { using Path = boost::filesystem::path; - constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { - return ctx.end(); - } - - template - auto format(const Path& path, FormatContext& ctx) const -> decltype(ctx.out()) { - return fmt::format_to(ctx.out(), "{}", path.string()); - } + constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) { return ctx.end(); } + + template auto format(const Path &path, FormatContext &ctx) const -> decltype(ctx.out()) { + return fmt::format_to(ctx.out(), "{}", path.string()); + } }; template <> struct fmt::formatter { using Address = boost::asio::ip::address; - constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { - return ctx.end(); - } + constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) { return ctx.end(); } - template - auto format(const Address& addr, FormatContext& ctx) const -> decltype(ctx.out()) { - return fmt::format_to(ctx.out(), "{}", addr.to_string()); - } + template + auto format(const Address &addr, FormatContext &ctx) const -> decltype(ctx.out()) { + return fmt::format_to(ctx.out(), "{}", addr.to_string()); + } }; template struct fmt::formatter> { - using EndPoint = boost::asio::ip::basic_endpoint; + using EndPoint = boost::asio::ip::basic_endpoint; - constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { - return ctx.end(); - } + constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) { return ctx.end(); } - template - auto format(const EndPoint& p, FormatContext& ctx) const -> decltype(ctx.out()) { - return fmt::format_to(ctx.out(), "{}:{}", p.address(), p.port()); + template auto format(const EndPoint &p, FormatContext &ctx) const -> decltype(ctx.out()) { + return fmt::format_to(ctx.out(), "{}:{}", p.address(), p.port()); } }; - diff --git a/tests/access.h b/tests/access.h index 49295909..36675140 100644 --- a/tests/access.h +++ b/tests/access.h @@ -11,19 +11,18 @@ namespace { namespace to { struct device {}; struct state {}; -} -} -} - +} // namespace to +} // namespace +} // namespace syncspirit::test namespace syncspirit::model { template <> inline auto &folder_t::access() noexcept { return device; } -} +} // namespace syncspirit::model namespace rotor { template <> inline auto &actor_base_t::access() noexcept { return state; } -} +} // namespace rotor diff --git a/tests/diff-builder.cpp b/tests/diff-builder.cpp index a728ec39..74d6b4c1 100644 --- a/tests/diff-builder.cpp +++ b/tests/diff-builder.cpp @@ -17,11 +17,11 @@ using namespace syncspirit::test; using namespace syncspirit::model; -cluster_configurer_t::cluster_configurer_t(diff_builder_t& builder_, std::string_view peer_sha256_) noexcept: builder{builder_}, peer_sha256{peer_sha256_} { +cluster_configurer_t::cluster_configurer_t(diff_builder_t &builder_, std::string_view peer_sha256_) noexcept + : builder{builder_}, peer_sha256{peer_sha256_} {} -} - -cluster_configurer_t&& cluster_configurer_t::add(std::string_view sha256, std::string_view folder_id, uint64_t index, int64_t max_sequence) noexcept { +cluster_configurer_t &&cluster_configurer_t::add(std::string_view sha256, std::string_view folder_id, uint64_t index, + int64_t max_sequence) noexcept { auto folder = cc.add_folders(); folder->set_id(std::string(folder_id)); auto device = folder->add_devices(); @@ -31,8 +31,8 @@ cluster_configurer_t&& cluster_configurer_t::add(std::string_view sha256, std::s return std::move(*this); } -diff_builder_t& cluster_configurer_t::finish() noexcept { - auto& cluster = builder.cluster; +diff_builder_t &cluster_configurer_t::finish() noexcept { + auto &cluster = builder.cluster; auto peer = builder.cluster.get_devices().by_sha256(peer_sha256); auto diff = diff::peer::cluster_update_t::create(cluster, *peer, cc); assert(diff.has_value()); @@ -40,19 +40,18 @@ diff_builder_t& cluster_configurer_t::finish() noexcept { return builder; } - -index_maker_t::index_maker_t(diff_builder_t& builder_, std::string_view sha256, std::string_view folder_id) noexcept: builder{builder_}, - peer_sha256{sha256} { +index_maker_t::index_maker_t(diff_builder_t &builder_, std::string_view sha256, std::string_view folder_id) noexcept + : builder{builder_}, peer_sha256{sha256} { index.set_folder(std::string(folder_id)); } -index_maker_t&& index_maker_t::add(const proto::FileInfo& file) noexcept { +index_maker_t &&index_maker_t::add(const proto::FileInfo &file) noexcept { *index.add_files() = file; return std::move(*this); } -diff_builder_t& index_maker_t::finish() noexcept { - auto& cluster = builder.cluster; +diff_builder_t &index_maker_t::finish() noexcept { + auto &cluster = builder.cluster; auto peer = builder.cluster.get_devices().by_sha256(peer_sha256); auto diff = diff::peer::update_folder_t::create(cluster, *peer, index); assert(diff.has_value()); @@ -60,20 +59,16 @@ diff_builder_t& index_maker_t::finish() noexcept { return builder; } +diff_builder_t::diff_builder_t(model::cluster_t &cluster_) noexcept : cluster{cluster_} {} - -diff_builder_t::diff_builder_t(model::cluster_t& cluster_) noexcept: cluster{cluster_} { - -} - -diff_builder_t& diff_builder_t::apply(rotor::supervisor_t& sup) noexcept { +diff_builder_t &diff_builder_t::apply(rotor::supervisor_t &sup) noexcept { assert(!(diffs.empty() && bdiffs.empty())); auto diff = diff::cluster_diff_ptr_t(new diff::aggregate_t(std::move(diffs))); - auto& addr = sup.get_address(); + auto &addr = sup.get_address(); sup.send(addr, std::move(diff), nullptr); diffs.clear(); - for(auto& diff: bdiffs) { + for (auto &diff : bdiffs) { sup.send(addr, std::move(diff), nullptr); } bdiffs.clear(); @@ -82,7 +77,8 @@ diff_builder_t& diff_builder_t::apply(rotor::supervisor_t& sup) noexcept { return *this; } -diff_builder_t& diff_builder_t::create_folder(std::string_view id, std::string_view path, std::string_view label) noexcept { +diff_builder_t &diff_builder_t::create_folder(std::string_view id, std::string_view path, + std::string_view label) noexcept { db::Folder db_folder; db_folder.set_id(std::string(id)); db_folder.set_label(std::string(label)); @@ -91,7 +87,8 @@ diff_builder_t& diff_builder_t::create_folder(std::string_view id, std::string_v return *this; } -diff_builder_t& diff_builder_t::update_peer(std::string_view sha256, std::string_view name, std::string_view cert_name, bool auto_accept) noexcept { +diff_builder_t &diff_builder_t::update_peer(std::string_view sha256, std::string_view name, std::string_view cert_name, + bool auto_accept) noexcept { db::Device db_device; db_device.set_name(std::string(name)); db_device.set_cert_name(std::string(cert_name)); @@ -110,32 +107,33 @@ index_maker_t diff_builder_t::make_index(std::string_view sha256, std::string_vi return index_maker_t(*this, sha256, folder_id); } -diff_builder_t& diff_builder_t::share_folder(std::string_view sha256, std::string_view folder_id) noexcept { +diff_builder_t &diff_builder_t::share_folder(std::string_view sha256, std::string_view folder_id) noexcept { diffs.emplace_back(new diff::modify::share_folder_t(sha256, folder_id)); return *this; } -diff_builder_t& diff_builder_t::clone_file(const model::file_info_t &source) noexcept { +diff_builder_t &diff_builder_t::clone_file(const model::file_info_t &source) noexcept { diffs.emplace_back(new diff::modify::clone_file_t(source)); return *this; } -diff_builder_t& diff_builder_t::finish_file(const model::file_info_t &source) noexcept { +diff_builder_t &diff_builder_t::finish_file(const model::file_info_t &source) noexcept { diffs.emplace_back(new diff::modify::finish_file_t(source)); return *this; } -diff_builder_t& diff_builder_t::flush_file(const model::file_info_t &source) noexcept { +diff_builder_t &diff_builder_t::flush_file(const model::file_info_t &source) noexcept { diffs.emplace_back(new diff::modify::flush_file_t(source)); return *this; } -diff_builder_t& diff_builder_t::append_block(const model::file_info_t &target, size_t block_index, std::string data) noexcept { +diff_builder_t &diff_builder_t::append_block(const model::file_info_t &target, size_t block_index, + std::string data) noexcept { bdiffs.emplace_back(new diff::modify::append_block_t(target, block_index, std::move(data))); return *this; } -diff_builder_t& diff_builder_t::clone_block(const model::file_block_t& file_block) noexcept { +diff_builder_t &diff_builder_t::clone_block(const model::file_block_t &file_block) noexcept { bdiffs.emplace_back(new diff::modify::clone_block_t(file_block)); return *this; } diff --git a/tests/diff-builder.h b/tests/diff-builder.h index d1a1072b..1803c481 100644 --- a/tests/diff-builder.h +++ b/tests/diff-builder.h @@ -18,47 +18,51 @@ namespace r = rotor; struct diff_builder_t; struct cluster_configurer_t { - cluster_configurer_t(diff_builder_t& builder, std::string_view peer_sha256) noexcept; - cluster_configurer_t&& add(std::string_view sha256, std::string_view folder_id, uint64_t index, int64_t max_sequence) noexcept; - diff_builder_t& finish() noexcept; -private: + cluster_configurer_t(diff_builder_t &builder, std::string_view peer_sha256) noexcept; + cluster_configurer_t &&add(std::string_view sha256, std::string_view folder_id, uint64_t index, + int64_t max_sequence) noexcept; + diff_builder_t &finish() noexcept; + + private: proto::ClusterConfig cc; - diff_builder_t& builder; + diff_builder_t &builder; std::string_view peer_sha256; }; struct index_maker_t { - index_maker_t(diff_builder_t& builder, std::string_view peer_sha256, std::string_view folder_id) noexcept; - index_maker_t&& add(const proto::FileInfo&) noexcept; - diff_builder_t& finish() noexcept; -private: + index_maker_t(diff_builder_t &builder, std::string_view peer_sha256, std::string_view folder_id) noexcept; + index_maker_t &&add(const proto::FileInfo &) noexcept; + diff_builder_t &finish() noexcept; + + private: proto::Index index; - diff_builder_t& builder; + diff_builder_t &builder; std::string_view peer_sha256; }; struct diff_builder_t { - diff_builder_t(model::cluster_t&) noexcept; - diff_builder_t& apply(r::supervisor_t& sup) noexcept; - diff_builder_t& create_folder(std::string_view id, std::string_view path, std::string_view label = "") noexcept; - diff_builder_t& update_peer(std::string_view sha256, std::string_view name = "", std::string_view cert_name = "", bool auto_accept = true) noexcept; + diff_builder_t(model::cluster_t &) noexcept; + diff_builder_t &apply(r::supervisor_t &sup) noexcept; + diff_builder_t &create_folder(std::string_view id, std::string_view path, std::string_view label = "") noexcept; + diff_builder_t &update_peer(std::string_view sha256, std::string_view name = "", std::string_view cert_name = "", + bool auto_accept = true) noexcept; cluster_configurer_t configure_cluster(std::string_view sha256) noexcept; index_maker_t make_index(std::string_view sha256, std::string_view folder_id) noexcept; - diff_builder_t& share_folder(std::string_view sha256, std::string_view folder_id) noexcept; - diff_builder_t& clone_file(const model::file_info_t &source) noexcept; - diff_builder_t& finish_file(const model::file_info_t &source) noexcept; - diff_builder_t& flush_file(const model::file_info_t &source) noexcept; - diff_builder_t& append_block(const model::file_info_t &target, size_t block_index, std::string data) noexcept; - diff_builder_t& clone_block(const model::file_block_t&) noexcept; + diff_builder_t &share_folder(std::string_view sha256, std::string_view folder_id) noexcept; + diff_builder_t &clone_file(const model::file_info_t &source) noexcept; + diff_builder_t &finish_file(const model::file_info_t &source) noexcept; + diff_builder_t &flush_file(const model::file_info_t &source) noexcept; + diff_builder_t &append_block(const model::file_info_t &target, size_t block_index, std::string data) noexcept; + diff_builder_t &clone_block(const model::file_block_t &) noexcept; -private: + private: using bdiffs_t = std::vector; using diffs_t = model::diff::aggregate_t::diffs_t; - model::cluster_t& cluster; + model::cluster_t &cluster; diffs_t diffs; bdiffs_t bdiffs; friend struct cluster_configurer_t; friend struct index_maker_t; }; -} +} // namespace syncspirit::test diff --git a/tests/test-db.cpp b/tests/test-db.cpp index 97e98313..00ec51eb 100644 --- a/tests/test-db.cpp +++ b/tests/test-db.cpp @@ -5,7 +5,7 @@ namespace syncspirit::test { -env_t::~env_t () { +env_t::~env_t() { if (env) { mdbx_env_close(env); } @@ -18,8 +18,7 @@ env_t mk_env() { MDBX_env *env; auto r = mdbx_env_create(&env); assert(r == MDBX_SUCCESS); - MDBX_env_flags_t flags = - MDBX_EXCLUSIVE | MDBX_SAFE_NOSYNC | MDBX_WRITEMAP | MDBX_COALESCE | MDBX_LIFORECLAIM; + MDBX_env_flags_t flags = MDBX_EXCLUSIVE | MDBX_SAFE_NOSYNC | MDBX_WRITEMAP | MDBX_COALESCE | MDBX_LIFORECLAIM; r = mdbx_env_open(env, path.string().c_str(), flags, 0664); assert(r == MDBX_SUCCESS); // std::cout << path.c_str() << "\n"; @@ -32,4 +31,4 @@ db::transaction_t mk_txn(env_t &env, db::transaction_type_t type) { return std::move(r.value()); } -} +} // namespace syncspirit::test diff --git a/tests/test-db.h b/tests/test-db.h index 30784db2..670fa0c9 100644 --- a/tests/test-db.h +++ b/tests/test-db.h @@ -6,7 +6,6 @@ #include "db/utils.h" #include - namespace syncspirit::test { namespace bfs = boost::filesystem; @@ -22,4 +21,4 @@ env_t mk_env(); db::transaction_t mk_txn(env_t &env, db::transaction_type_t type); -} +} // namespace syncspirit::test diff --git a/tests/test-main.cpp b/tests/test-main.cpp index 929a3cb9..cf3a33fc 100644 --- a/tests/test-main.cpp +++ b/tests/test-main.cpp @@ -8,10 +8,7 @@ #include "structs.pb.h" #include "db/prefix.h" -int main(int argc, char *argv[]) { - return Catch::Session().run(argc, argv); -} - +int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); } namespace syncspirit::test { @@ -29,7 +26,7 @@ bfs::path locate_path(const char *test_file) { throw std::runtime_error(err); } -std::string read_file(const bfs::path& path) { +std::string read_file(const bfs::path &path) { sys::error_code ec; auto filesize = bfs::file_size(path, ec); auto file_path = path.string(); @@ -48,7 +45,7 @@ std::string read_file(const bfs::path& path) { return std::string(buffer.data(), filesize); } -void write_file(const bfs::path& path, std::string_view content) { +void write_file(const bfs::path &path, std::string_view content) { bfs::create_directories(path.parent_path()); auto file_path = path.string(); auto out = fopen(file_path.c_str(), "wb"); @@ -73,7 +70,6 @@ model::device_ptr_t make_device(std::string_view device_id, std::string_view nam return model::device_t::create(id, name).assume_value(); } - std::string hash_string(const std::string_view &hash) noexcept { auto r = std::string(); r.reserve(hash.size() * 2); @@ -85,4 +81,4 @@ std::string hash_string(const std::string_view &hash) noexcept { return r; } -} +} // namespace syncspirit::test diff --git a/tests/test-utils.h b/tests/test-utils.h index 797fa5a7..cd852141 100644 --- a/tests/test-utils.h +++ b/tests/test-utils.h @@ -33,5 +33,4 @@ std::string device_id2sha256(std::string_view device_id); model::device_ptr_t make_device(std::string_view device_id, std::string_view name = ""); std::string hash_string(const std::string_view &hash) noexcept; - } // namespace syncspirit::test diff --git a/tests/test_supervisor.cpp b/tests/test_supervisor.cpp index f3c150bf..d5bcead5 100644 --- a/tests/test_supervisor.cpp +++ b/tests/test_supervisor.cpp @@ -5,37 +5,34 @@ #include "net/names.h" namespace to { -struct queue{}; -struct on_timer_trigger{}; -} +struct queue {}; +struct on_timer_trigger {}; +} // namespace to template <> inline auto &rotor::supervisor_t::access() noexcept { return queue; } namespace rotor { -template <> inline auto rotor::actor_base_t::access(request_id_t request_id, - bool cancelled) noexcept { +template <> +inline auto rotor::actor_base_t::access(request_id_t request_id, + bool cancelled) noexcept { on_timer_trigger(request_id, cancelled); } -} - - +} // namespace rotor using namespace syncspirit::net; using namespace syncspirit::test; -supervisor_t::supervisor_t(r::supervisor_config_t& cfg): r::supervisor_t(cfg) { +supervisor_t::supervisor_t(r::supervisor_config_t &cfg) : r::supervisor_t(cfg) { log = utils::get_logger("net.test_supervisor"); } - void supervisor_t::configure(r::plugin::plugin_base_t &plugin) noexcept { parent_t::configure(plugin); plugin.with_casted([&](auto &p) { p.set_identity(names::coordinator, false); }); - plugin.with_casted([&](auto &p) { - p.register_name(names::coordinator, get_address()); - }); + plugin.with_casted( + [&](auto &p) { p.register_name(names::coordinator, get_address()); }); plugin.with_casted([&](auto &p) { p.subscribe_actor(&supervisor_t::on_model_update); p.subscribe_actor(&supervisor_t::on_block_update); @@ -46,7 +43,6 @@ void supervisor_t::configure(r::plugin::plugin_base_t &plugin) noexcept { } } - void supervisor_t::do_start_timer(const r::pt::time_duration &interval, r::timer_handler_base_t &handler) noexcept { timers.emplace_back(&handler); } @@ -54,9 +50,9 @@ void supervisor_t::do_start_timer(const r::pt::time_duration &interval, r::timer void supervisor_t::do_cancel_timer(r::request_id_t timer_id) noexcept { auto it = timers.begin(); while (it != timers.end()) { - auto& handler = *it; + auto &handler = *it; if (handler->request_id == timer_id) { - auto& actor_ptr = handler->owner; + auto &actor_ptr = handler->owner; actor_ptr->access(timer_id, true); on_timer_trigger(timer_id, true); timers.erase(it); @@ -70,16 +66,15 @@ void supervisor_t::do_cancel_timer(r::request_id_t timer_id) noexcept { void supervisor_t::do_invoke_timer(r::request_id_t timer_id) noexcept { LOG_DEBUG(log, "{}, invoking timer {}", identity, timer_id); - auto predicate = [&](auto& handler) { return handler->request_id == timer_id; }; + auto predicate = [&](auto &handler) { return handler->request_id == timer_id; }; auto it = std::find_if(timers.begin(), timers.end(), predicate); assert(it != timers.end()); - auto& handler = *it; - auto& actor_ptr = handler->owner; + auto &handler = *it; + auto &actor_ptr = handler->owner; actor_ptr->access(timer_id, false); timers.erase(it); } - void supervisor_t::start() noexcept {} void supervisor_t::shutdown() noexcept { do_shutdown(); } @@ -89,17 +84,17 @@ void supervisor_t::enqueue(r::message_ptr_t message) noexcept { void supervisor_t::on_model_update(model::message::model_update_t &msg) noexcept { LOG_TRACE(log, "{}, updating model", identity); - auto& diff = msg.payload.diff; + auto &diff = msg.payload.diff; auto r = diff->apply(*cluster); if (!r) { - LOG_ERROR(log, "{}, error updating model: {}", identity, r.assume_error().message()); + LOG_ERROR(log, "{}, error updating model: {}", identity, r.assume_error().message()); do_shutdown(make_error(r.assume_error())); } } void supervisor_t::on_block_update(model::message::block_update_t &msg) noexcept { LOG_TRACE(log, "{}, updating block", identity); - auto& diff = msg.payload.diff; + auto &diff = msg.payload.diff; auto r = diff->apply(*cluster); if (!r) { LOG_ERROR(log, "{}, error updating block: {}", identity, r.assume_error().message()); @@ -109,7 +104,7 @@ void supervisor_t::on_block_update(model::message::block_update_t &msg) noexcept void supervisor_t::on_contact_update(model::message::contact_update_t &msg) noexcept { LOG_TRACE(log, "{}, updating contact", identity); - auto& diff = msg.payload.diff; + auto &diff = msg.payload.diff; auto r = diff->apply(*cluster); if (!r) { LOG_ERROR(log, "{}, error updating contact: {}", identity, r.assume_error().message()); diff --git a/tests/test_supervisor.h b/tests/test_supervisor.h index b803826c..8f5f78cc 100644 --- a/tests/test_supervisor.h +++ b/tests/test_supervisor.h @@ -11,20 +11,19 @@ namespace syncspirit::test { namespace r = rotor; -struct supervisor_t final: r::supervisor_t { - using timers_t = std::list; +struct supervisor_t final : r::supervisor_t { + using timers_t = std::list; using parent_t = r::supervisor_t; using configure_callback_t = std::function; - - supervisor_t(r::supervisor_config_t& cfg); + supervisor_t(r::supervisor_config_t &cfg); void configure(r::plugin::plugin_base_t &plugin) noexcept override; void start() noexcept override; void shutdown() noexcept override; void enqueue(r::message_ptr_t message) noexcept override; - void on_model_update(model::message::model_update_t& ) noexcept; - void on_block_update(model::message::block_update_t& ) noexcept; + void on_model_update(model::message::model_update_t &) noexcept; + void on_block_update(model::message::block_update_t &) noexcept; void on_contact_update(model::message::contact_update_t &) noexcept; void do_start_timer(const r::pt::time_duration &interval, r::timer_handler_base_t &handler) noexcept override; void do_invoke_timer(r::request_id_t timer_id) noexcept; @@ -36,4 +35,4 @@ struct supervisor_t final: r::supervisor_t { timers_t timers; }; -}; +}; // namespace syncspirit::test From df8abf12a9ee7e588dad9465ba885d0249bc7c1b Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Sun, 26 Feb 2023 17:22:21 +0300 Subject: [PATCH 004/158] remove submodules --- .gitmodules | 24 ------------------------ lib/catch | 1 - lib/json | 1 - lib/lz4 | 1 - lib/pugixml | 1 - lib/rotor | 1 - lib/spdlog | 1 - lib/tomlplusplus | 1 - lib/uriparser | 1 - 9 files changed, 32 deletions(-) delete mode 160000 lib/catch delete mode 160000 lib/json delete mode 160000 lib/lz4 delete mode 160000 lib/pugixml delete mode 160000 lib/rotor delete mode 160000 lib/spdlog delete mode 160000 lib/tomlplusplus delete mode 160000 lib/uriparser diff --git a/.gitmodules b/.gitmodules index 123afd5a..d5e99980 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,27 +1,3 @@ -[submodule "lib/rotor"] - path = lib/rotor - url = https://github.com/basiliscos/cpp-rotor -[submodule "lib/spdlog"] - path = lib/spdlog - url = https://github.com/gabime/spdlog -[submodule "lib/json"] - path = lib/json - url = https://github.com/nlohmann/json.git -[submodule "lib/pugixml"] - path = lib/pugixml - url = https://github.com/zeux/pugixml.git -[submodule "lib/uriparser"] - path = lib/uriparser - url = https://github.com/uriparser/uriparser.git -[submodule "lib/tomlplusplus"] - path = lib/tomlplusplus - url = https://github.com/marzer/tomlplusplus.git -[submodule "lib/lz4"] - path = lib/lz4 - url = https://github.com/lz4/lz4.git [submodule "lib/mbdx"] path = lib/mbdx url = https://gitflic.ru/project/erthink/libmdbx.git -[submodule "lib/catch"] - path = lib/catch - url = https://github.com/catchorg/Catch2/ diff --git a/lib/catch b/lib/catch deleted file mode 160000 index 7727c152..00000000 --- a/lib/catch +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7727c15290ce2d289c1809d0eab3cceb88384ad6 diff --git a/lib/json b/lib/json deleted file mode 160000 index db78ac1d..00000000 --- a/lib/json +++ /dev/null @@ -1 +0,0 @@ -Subproject commit db78ac1d7716f56fc9f1b030b715f872f93964e4 diff --git a/lib/lz4 b/lib/lz4 deleted file mode 160000 index d4437184..00000000 --- a/lib/lz4 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d44371841a2f1728a3f36839fd4b7e872d0927d3 diff --git a/lib/pugixml b/lib/pugixml deleted file mode 160000 index dd50fa5b..00000000 --- a/lib/pugixml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit dd50fa5b45ab8d58d6c27566c2eaf04a8b7e5841 diff --git a/lib/rotor b/lib/rotor deleted file mode 160000 index 0396d3e8..00000000 --- a/lib/rotor +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0396d3e857f1dcf21d82abcedeaffdf3ec6e3b0c diff --git a/lib/spdlog b/lib/spdlog deleted file mode 160000 index 76fb40d9..00000000 --- a/lib/spdlog +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 76fb40d95455f249bd70824ecfcae7a8f0930fa3 diff --git a/lib/tomlplusplus b/lib/tomlplusplus deleted file mode 160000 index fe0ac895..00000000 --- a/lib/tomlplusplus +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fe0ac89500f0a34d2b42a7bb7363fe52f874f21f diff --git a/lib/uriparser b/lib/uriparser deleted file mode 160000 index 1bd8ae2b..00000000 --- a/lib/uriparser +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1bd8ae2b8b47d3155765c1ea282a8f9812d3853e From df658361fc26b24db3f49e91b4b64a76b041d5ec Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Tue, 28 Feb 2023 13:42:14 +0300 Subject: [PATCH 005/158] refactor --- src/net/controller_actor.cpp | 18 +++++++++--------- src/net/controller_actor.h | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/net/controller_actor.cpp b/src/net/controller_actor.cpp index 2e116a98..7e765820 100644 --- a/src/net/controller_actor.cpp +++ b/src/net/controller_actor.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou #include "controller_actor.h" #include "names.h" @@ -53,7 +53,7 @@ void controller_actor_t::configure(r::plugin::plugin_base_t &plugin) noexcept { plugin.with_casted([&](auto &p) { p.link(peer_addr, false); }); plugin.with_casted([&](auto &p) { p.subscribe_actor(&controller_actor_t::on_forward); - p.subscribe_actor(&controller_actor_t::on_ready); + p.subscribe_actor(&controller_actor_t::on_pull_ready); p.subscribe_actor(&controller_actor_t::on_termination); p.subscribe_actor(&controller_actor_t::on_block); p.subscribe_actor(&controller_actor_t::on_validation); @@ -113,7 +113,7 @@ void controller_actor_t::on_termination(message::termination_signal_t &message) do_shutdown(ee); } -void controller_actor_t::ready() noexcept { send(get_address()); } +void controller_actor_t::pull_ready() noexcept { send(get_address()); } model::file_info_ptr_t controller_actor_t::next_file(bool reset) noexcept { if (reset) { @@ -137,8 +137,8 @@ model::file_block_t controller_actor_t::next_block(bool reset) noexcept { return {}; } -void controller_actor_t::on_ready(message::ready_signal_t &message) noexcept { - LOG_TRACE(log, "{}, on_ready, blocks requested = {}", identity, blocks_requested); +void controller_actor_t::on_pull_ready(message::pull_signal_t &message) noexcept { + LOG_TRACE(log, "{}, on_pull_ready, blocks requested = {}", identity, blocks_requested); bool ignore = (blocks_requested > blocks_max_requested || request_pool < 0) // rx buff is going to be full || (state != r::state_t::OPERATIONAL) // wrequest pool sz = 32505856e are shutting down ; @@ -177,7 +177,7 @@ void controller_actor_t::on_ready(message::ready_signal_t &message) noexcept { diff = new model::diff::modify::clone_file_t(*file); send(coordinator, std::move(diff), this); } else { - ready(); + pull_ready(); } } else { substate = substate & ~substate_t::iterating_files; @@ -203,7 +203,7 @@ void controller_actor_t::preprocess_block(model::file_block_t &file_block) noexc ++blocks_requested; request_pool -= (int64_t)sz; } - ready(); + pull_ready(); } void controller_actor_t::on_forward(message::forwarded_message_t &message) noexcept { @@ -222,7 +222,7 @@ void controller_actor_t::on_model_update(model::message::model_update_t &message auto ee = make_error(r.assume_error()); return do_shutdown(ee); } - ready(); + pull_ready(); } } @@ -347,7 +347,7 @@ void controller_actor_t::on_block(message::block_response_t &message) noexcept { auto &data = message.payload.res.data; request(hasher_proxy, data, hash, &message).send(init_timeout); resources->acquire(resource::hash); - return ready(); + return pull_ready(); } void controller_actor_t::on_validation(hasher::message::validation_response_t &res) noexcept { diff --git a/src/net/controller_actor.h b/src/net/controller_actor.h index 6f6ec06f..681465a8 100644 --- a/src/net/controller_actor.h +++ b/src/net/controller_actor.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou #pragma once @@ -20,12 +20,12 @@ namespace outcome = boost::outcome_v2; namespace payload { -struct ready_signal_t {}; +struct pull_signal_t {}; } // namespace payload namespace message { -using ready_signal_t = r::message_t; +using pull_signal_t = r::message_t; } struct controller_actor_config_t : r::actor_config_t { @@ -99,7 +99,7 @@ struct SYNCSPIRIT_API controller_actor_t : public r::actor_base_t, private model void on_termination(message::termination_signal_t &message) noexcept; void on_forward(message::forwarded_message_t &message) noexcept; - void on_ready(message::ready_signal_t &message) noexcept; + void on_pull_ready(message::pull_signal_t &message) noexcept; void on_block(message::block_response_t &message) noexcept; void on_validation(hasher::message::validation_response_t &res) noexcept; void preprocess_block(model::file_block_t &block) noexcept; @@ -113,7 +113,7 @@ struct SYNCSPIRIT_API controller_actor_t : public r::actor_base_t, private model void on_message(proto::message::DownloadProgress &message) noexcept; void request_block(const model::file_block_t &block) noexcept; - void ready() noexcept; + void pull_ready() noexcept; model::file_info_ptr_t next_file(bool reset) noexcept; model::file_block_t next_block(bool reset) noexcept; From a01fd630d4cde096d2ea0c381e675fc85a3408a3 Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Tue, 28 Feb 2023 16:17:13 +0300 Subject: [PATCH 006/158] let catch library be managed by conan --- tests/{test-main.cpp => test-utils.cpp} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename tests/{test-main.cpp => test-utils.cpp} (96%) diff --git a/tests/test-main.cpp b/tests/test-utils.cpp similarity index 96% rename from tests/test-main.cpp rename to tests/test-utils.cpp index cf3a33fc..848ca1e6 100644 --- a/tests/test-main.cpp +++ b/tests/test-utils.cpp @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#define CATCH_CONFIG_RUNNER -#include "catch.hpp" #include "test-utils.h" #include "model/device_id.h" #include "structs.pb.h" From 5c980ae0d303354889e1034ba9f563d2033b74e9 Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Tue, 28 Feb 2023 16:18:59 +0300 Subject: [PATCH 007/158] let catch library be managed by conan --- conanfile.txt | 2 + tests/009-uri.cpp | 4 +- tests/010-upnp-support.cpp | 3 +- tests/011-tls-util.cpp | 5 +- tests/012-base32.cpp | 3 +- tests/013-global-discovery.cpp | 3 +- tests/014-configuration.cpp | 3 +- tests/015-logger.cpp | 3 +- tests/016-relay-support.cpp | 4 +- tests/020-generic-map.cpp | 3 +- tests/025-device_id.cpp | 3 +- tests/029-diff-generic.cpp | 3 +- tests/030-diff-load-cluster.cpp | 3 +- tests/031-diff-cluster_update.cpp | 3 +- tests/032-diff-modify.cpp | 3 +- tests/033-diffs-trivial.cpp | 3 +- tests/034-diff-new_file.cpp | 3 +- tests/035-diff-local_update.cpp | 3 +- tests/036-diff-blocks.cpp | 3 +- tests/037-diff-update_folder.cpp | 3 +- tests/038-diff-clone_finish-file.cpp | 3 +- tests/050-file_iterator.cpp | 3 +- tests/051-block_iterator.cpp | 3 +- tests/052-file_info.cpp | 3 +- tests/053-scan_task.cpp | 3 +- tests/060-bep.cpp | 3 +- tests/070-db.cpp | 22 +- tests/071-fs_actor.cpp | 14 +- tests/072-global_discovery.cpp | 16 +- tests/073-dialer.cpp | 10 +- tests/074-hasher.cpp | 3 +- tests/075-controller.cpp | 14 +- tests/076-scan_actor.cpp | 11 +- tests/077-initiator.cpp | 58 +- tests/078-relay.cpp | 14 +- tests/CMakeLists.txt | 13 +- tests/catch.hpp | 17937 ------------------------- tests/diff-builder.h | 7 +- tests/test-utils.h | 25 +- tests/test_supervisor.h | 3 +- 40 files changed, 164 insertions(+), 18064 deletions(-) delete mode 100644 tests/catch.hpp diff --git a/conanfile.txt b/conanfile.txt index 04bb3efc..04abfcf6 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -12,6 +12,8 @@ spdlog/1.11.0 tomlplusplus/3.3.0 uriparser/0.9.7 +[test_requires] +catch2/3.3.1 [options] pugixml/1.13no_exceptions=True diff --git a/tests/009-uri.cpp b/tests/009-uri.cpp index f69a80ae..7883ccfa 100644 --- a/tests/009-uri.cpp +++ b/tests/009-uri.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" +#include "test-utils.h" #include "utils/uri.h" using namespace syncspirit::utils; diff --git a/tests/010-upnp-support.cpp b/tests/010-upnp-support.cpp index cad7ad17..89ea05d4 100644 --- a/tests/010-upnp-support.cpp +++ b/tests/010-upnp-support.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "proto/upnp_support.h" #include diff --git a/tests/011-tls-util.cpp b/tests/011-tls-util.cpp index a2f07e75..499de7ec 100644 --- a/tests/011-tls-util.cpp +++ b/tests/011-tls-util.cpp @@ -1,10 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" +#include "test-utils.h" #include "utils/base32.h" #include "utils/tls.h" -#include "test-utils.h" #include #include #include diff --git a/tests/012-base32.cpp b/tests/012-base32.cpp index 6623e03a..c8d463e6 100644 --- a/tests/012-base32.cpp +++ b/tests/012-base32.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "utils/base32.h" diff --git a/tests/013-global-discovery.cpp b/tests/013-global-discovery.cpp index d745dede..63c00cea 100644 --- a/tests/013-global-discovery.cpp +++ b/tests/013-global-discovery.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "proto/discovery_support.h" #include "utils/error_code.h" diff --git a/tests/014-configuration.cpp b/tests/014-configuration.cpp index 6e9dc2b7..152ffc99 100644 --- a/tests/014-configuration.cpp +++ b/tests/014-configuration.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "config/utils.h" #include "utils/uri.h" diff --git a/tests/015-logger.cpp b/tests/015-logger.cpp index e76c37bf..f5969da7 100644 --- a/tests/015-logger.cpp +++ b/tests/015-logger.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "utils/log.h" diff --git a/tests/016-relay-support.cpp b/tests/016-relay-support.cpp index 4d2323ee..6cf824ef 100644 --- a/tests/016-relay-support.cpp +++ b/tests/016-relay-support.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2023 Ivan Baidakou -#include "catch.hpp" +#include "test-utils.h" #include "proto/relay_support.h" using namespace syncspirit::proto::relay; diff --git a/tests/020-generic-map.cpp b/tests/020-generic-map.cpp index a9193bea..f53f844b 100644 --- a/tests/020-generic-map.cpp +++ b/tests/020-generic-map.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/device.h" diff --git a/tests/025-device_id.cpp b/tests/025-device_id.cpp index dfb09dc9..cdad63d1 100644 --- a/tests/025-device_id.cpp +++ b/tests/025-device_id.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "model/device_id.h" #include "proto/luhn32.h" diff --git a/tests/029-diff-generic.cpp b/tests/029-diff-generic.cpp index 8fb848f9..919f115c 100644 --- a/tests/029-diff-generic.cpp +++ b/tests/029-diff-generic.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/030-diff-load-cluster.cpp b/tests/030-diff-load-cluster.cpp index b438d284..210af0bc 100644 --- a/tests/030-diff-load-cluster.cpp +++ b/tests/030-diff-load-cluster.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/031-diff-cluster_update.cpp b/tests/031-diff-cluster_update.cpp index 63f00560..8227bb75 100644 --- a/tests/031-diff-cluster_update.cpp +++ b/tests/031-diff-cluster_update.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/032-diff-modify.cpp b/tests/032-diff-modify.cpp index b837541d..373a4a3d 100644 --- a/tests/032-diff-modify.cpp +++ b/tests/032-diff-modify.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/033-diffs-trivial.cpp b/tests/033-diffs-trivial.cpp index 7a4a32d1..151f91c9 100644 --- a/tests/033-diffs-trivial.cpp +++ b/tests/033-diffs-trivial.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/034-diff-new_file.cpp b/tests/034-diff-new_file.cpp index 5cedb58f..9b18f579 100644 --- a/tests/034-diff-new_file.cpp +++ b/tests/034-diff-new_file.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/035-diff-local_update.cpp b/tests/035-diff-local_update.cpp index 617872f7..4fe0dd7e 100644 --- a/tests/035-diff-local_update.cpp +++ b/tests/035-diff-local_update.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/036-diff-blocks.cpp b/tests/036-diff-blocks.cpp index 9ed4f92c..9a352272 100644 --- a/tests/036-diff-blocks.cpp +++ b/tests/036-diff-blocks.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/037-diff-update_folder.cpp b/tests/037-diff-update_folder.cpp index b67deb58..3f9bcef2 100644 --- a/tests/037-diff-update_folder.cpp +++ b/tests/037-diff-update_folder.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/038-diff-clone_finish-file.cpp b/tests/038-diff-clone_finish-file.cpp index ff08a9a6..838d7efd 100644 --- a/tests/038-diff-clone_finish-file.cpp +++ b/tests/038-diff-clone_finish-file.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" diff --git a/tests/050-file_iterator.cpp b/tests/050-file_iterator.cpp index 54bef4dc..3a39ce13 100644 --- a/tests/050-file_iterator.cpp +++ b/tests/050-file_iterator.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "model/cluster.h" #include "model/misc/file_iterator.h" diff --git a/tests/051-block_iterator.cpp b/tests/051-block_iterator.cpp index 95bbbfc8..2a2f8dd3 100644 --- a/tests/051-block_iterator.cpp +++ b/tests/051-block_iterator.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "model/cluster.h" #include "model/misc/block_iterator.h" diff --git a/tests/052-file_info.cpp b/tests/052-file_info.cpp index 90c71e78..61ae1287 100644 --- a/tests/052-file_info.cpp +++ b/tests/052-file_info.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "model/cluster.h" #include "model/misc/version_utils.h" diff --git a/tests/053-scan_task.cpp b/tests/053-scan_task.cpp index a4a16d7b..194edeac 100644 --- a/tests/053-scan_task.cpp +++ b/tests/053-scan_task.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "fs/scan_task.h" diff --git a/tests/060-bep.cpp b/tests/060-bep.cpp index 928903e9..3c98d359 100644 --- a/tests/060-bep.cpp +++ b/tests/060-bep.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "proto/bep_support.h" #include "model/device_id.h" diff --git a/tests/070-db.cpp b/tests/070-db.cpp index 3852ece1..9d751f8d 100644 --- a/tests/070-db.cpp +++ b/tests/070-db.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" +#include #include "test-utils.h" #include "diff-builder.h" #include "model/diff/peer/cluster_remove.h" @@ -476,10 +476,14 @@ void test_clone_file() { F().run(); } -REGISTER_TEST_CASE(test_db_migration, "test_db_migration", "[db]"); -REGISTER_TEST_CASE(test_loading_empty_db, "test_loading_empty_db", "[db]"); -REGISTER_TEST_CASE(test_folder_creation, "test_folder_creation", "[db]"); -REGISTER_TEST_CASE(test_peer_updating, "test_peer_updating", "[db]"); -REGISTER_TEST_CASE(test_folder_sharing, "test_folder_sharing", "[db]"); -REGISTER_TEST_CASE(test_cluster_update_and_remove, "test_cluster_update_and_remove", "[db]"); -REGISTER_TEST_CASE(test_clone_file, "test_clone_file", "[db]"); +int _init() { + REGISTER_TEST_CASE(test_loading_empty_db, "test_loading_empty_db", "[db]"); + REGISTER_TEST_CASE(test_folder_creation, "test_folder_creation", "[db]"); + REGISTER_TEST_CASE(test_peer_updating, "test_peer_updating", "[db]"); + REGISTER_TEST_CASE(test_folder_sharing, "test_folder_sharing", "[db]"); + REGISTER_TEST_CASE(test_cluster_update_and_remove, "test_cluster_update_and_remove", "[db]"); + REGISTER_TEST_CASE(test_clone_file, "test_clone_file", "[db]"); + return 1; +} + +static int v = _init(); diff --git a/tests/071-fs_actor.cpp b/tests/071-fs_actor.cpp index ebcd36d5..1b28fc22 100644 --- a/tests/071-fs_actor.cpp +++ b/tests/071-fs_actor.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "fs/file_actor.h" #include "fs/utils.h" @@ -495,6 +494,11 @@ void test_clone_block() { F().run(); } -REGISTER_TEST_CASE(test_clone_file, "test_clone_file", "[fs]"); -REGISTER_TEST_CASE(test_append_block, "test_append_block", "[fs]"); -REGISTER_TEST_CASE(test_clone_block, "test_clone_block", "[fs]"); +int _init() { + REGISTER_TEST_CASE(test_clone_file, "test_clone_file", "[fs]"); + REGISTER_TEST_CASE(test_append_block, "test_append_block", "[fs]"); + REGISTER_TEST_CASE(test_clone_block, "test_clone_block", "[fs]"); + return 1; +} + +static int v = _init(); diff --git a/tests/072-global_discovery.cpp b/tests/072-global_discovery.cpp index d87c38db..12feb648 100644 --- a/tests/072-global_discovery.cpp +++ b/tests/072-global_discovery.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" @@ -253,7 +252,12 @@ void test_late_announcement() { F().run(); } -REGISTER_TEST_CASE(test_succesfull_announcement, "test_succesfull_announcement", "[net]"); -REGISTER_TEST_CASE(test_failded_announcement, "test_failded_announcement", "[net]"); -REGISTER_TEST_CASE(test_peer_discovery, "test_peer_discovery", "[net]"); -REGISTER_TEST_CASE(test_late_announcement, "test_late_announcement", "[net]"); +int _init() { + REGISTER_TEST_CASE(test_succesfull_announcement, "test_succesfull_announcement", "[net]"); + REGISTER_TEST_CASE(test_failded_announcement, "test_failded_announcement", "[net]"); + REGISTER_TEST_CASE(test_peer_discovery, "test_peer_discovery", "[net]"); + REGISTER_TEST_CASE(test_late_announcement, "test_late_announcement", "[net]"); + return 1; +} + +static int v = _init(); diff --git a/tests/073-dialer.cpp b/tests/073-dialer.cpp index 4187beeb..9d55d727 100644 --- a/tests/073-dialer.cpp +++ b/tests/073-dialer.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "model/cluster.h" @@ -128,4 +127,9 @@ void test_dialer() { F().run(); } -REGISTER_TEST_CASE(test_dialer, "test_dialer", "[net]"); +int _init() { + REGISTER_TEST_CASE(test_dialer, "test_dialer", "[net]"); + return 1; +} + +static int v = _init(); diff --git a/tests/074-hasher.cpp b/tests/074-hasher.cpp index d70bd2df..1339af7e 100644 --- a/tests/074-hasher.cpp +++ b/tests/074-hasher.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "test_supervisor.h" #include "access.h" diff --git a/tests/075-controller.cpp b/tests/075-controller.cpp index 0df6afac..6e1aaadf 100644 --- a/tests/075-controller.cpp +++ b/tests/075-controller.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "test_supervisor.h" @@ -675,6 +674,11 @@ void test_downloading() { F(true, 10).run(); } -REGISTER_TEST_CASE(test_startup, "test_startup", "[net]"); -REGISTER_TEST_CASE(test_index, "test_index", "[net]"); -REGISTER_TEST_CASE(test_downloading, "test_downloading", "[net]"); +int _init() { + REGISTER_TEST_CASE(test_startup, "test_startup", "[net]"); + REGISTER_TEST_CASE(test_index, "test_index", "[net]"); + REGISTER_TEST_CASE(test_downloading, "test_downloading", "[net]"); + return 1; +} + +static int v = _init(); diff --git a/tests/076-scan_actor.cpp b/tests/076-scan_actor.cpp index 2d2cb2b7..23c4b44b 100644 --- a/tests/076-scan_actor.cpp +++ b/tests/076-scan_actor.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2019-2022 Ivan Baidakou +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou -#include "catch.hpp" #include "test-utils.h" #include "access.h" #include "test_supervisor.h" @@ -135,6 +134,7 @@ void test_meta_changes() { SECTION("just 1 subdir, which cannot be read") { auto subdir = root_path / "abc"; CHECK(bfs::create_directories(subdir / "def", ec)); + auto guard = test::path_guard_t(subdir); bfs::permissions(subdir, bfs::perms::no_perms); bfs::permissions(subdir, bfs::perms::owner_read, ec); if (ec) { @@ -360,4 +360,9 @@ void test_meta_changes() { F().run(); } -REGISTER_TEST_CASE(test_meta_changes, "test_meta_changes", "[fs]"); +int _init() { + REGISTER_TEST_CASE(test_meta_changes, "test_meta_changes", "[fs]"); + return 1; +} + +static int v = _init(); diff --git a/tests/077-initiator.cpp b/tests/077-initiator.cpp index 1dc44c7e..7febbc09 100644 --- a/tests/077-initiator.cpp +++ b/tests/077-initiator.cpp @@ -1,4 +1,6 @@ -#include "catch.hpp" +// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou + #include "test-utils.h" #include "access.h" @@ -891,27 +893,33 @@ void test_relay_noninvitation_reply() { F().run(); } -REGISTER_TEST_CASE(test_connect_unsupproted_proto, "test_connect_unsupproted_proto", "[initiator]"); -REGISTER_TEST_CASE(test_connect_timeout, "test_connect_timeout", "[initiator]"); -REGISTER_TEST_CASE(test_handshake_timeout, "test_handshake_timeout", "[initiator]"); -REGISTER_TEST_CASE(test_handshake_garbage, "test_handshake_garbage", "[initiator]"); -REGISTER_TEST_CASE(test_connection_refused, "test_connection_refused", "[initiator]"); -REGISTER_TEST_CASE(test_connection_refused_no_model, "test_connection_refused_no_model", "[initiator]"); -REGISTER_TEST_CASE(test_resolve_failure, "test_resolve_failure", "[initiator]"); -REGISTER_TEST_CASE(test_success, "test_success", "[initiator]"); -REGISTER_TEST_CASE(test_success_no_model, "test_success_no_model", "[initiator]"); -REGISTER_TEST_CASE(test_passive_success, "test_passive_success", "[initiator]"); -REGISTER_TEST_CASE(test_passive_garbage, "test_passive_garbage", "[initiator]"); -REGISTER_TEST_CASE(test_passive_timeout, "test_passive_timeout", "[initiator]"); -REGISTER_TEST_CASE(test_relay_passive_success, "test_relay_passive_success", "[initiator]"); -REGISTER_TEST_CASE(test_relay_passive_gargabe, "test_relay_passive_gargabe", "[initiator]"); -REGISTER_TEST_CASE(test_relay_passive_wrong_message, "test_relay_passive_wrong_message", "[initiator]"); -REGISTER_TEST_CASE(test_relay_passive_unsuccessful_join, "test_relay_passive_unsuccessful_join", "[initiator]"); -REGISTER_TEST_CASE(test_relay_malformed_uri, "test_relay_malformed_uri", "[initiator]"); -REGISTER_TEST_CASE(test_relay_active_wrong_relay_deviceid, "test_relay_active_wrong_relay_deviceid", "[initiator]"); -REGISTER_TEST_CASE(test_relay_active_success, "test_relay_active_success", "[initiator]"); -REGISTER_TEST_CASE(test_relay_wrong_device, "test_relay_wrong_device", "[initiator]"); -REGISTER_TEST_CASE(test_relay_non_conneteable, "test_relay_non_conneteable", "[initiator]"); -REGISTER_TEST_CASE(test_relay_malformed_address, "test_relay_malformed_address", "[initiator]"); -REGISTER_TEST_CASE(test_relay_garbage_reply, "test_relay_garbage_reply", "[initiator]"); -REGISTER_TEST_CASE(test_relay_noninvitation_reply, "test_relay_noninvitation_reply", "[initiator]"); +int _init() { + REGISTER_TEST_CASE(test_connect_unsupproted_proto, "test_connect_unsupproted_proto", "[initiator]"); + REGISTER_TEST_CASE(test_connect_timeout, "test_connect_timeout", "[initiator]"); + REGISTER_TEST_CASE(test_handshake_timeout, "test_handshake_timeout", "[initiator]"); + REGISTER_TEST_CASE(test_handshake_garbage, "test_handshake_garbage", "[initiator]"); + REGISTER_TEST_CASE(test_connection_refused, "test_connection_refused", "[initiator]"); + REGISTER_TEST_CASE(test_connection_refused_no_model, "test_connection_refused_no_model", "[initiator]"); + REGISTER_TEST_CASE(test_resolve_failure, "test_resolve_failure", "[initiator]"); + REGISTER_TEST_CASE(test_success, "test_success", "[initiator]"); + REGISTER_TEST_CASE(test_success_no_model, "test_success_no_model", "[initiator]"); + REGISTER_TEST_CASE(test_passive_success, "test_passive_success", "[initiator]"); + REGISTER_TEST_CASE(test_passive_garbage, "test_passive_garbage", "[initiator]"); + REGISTER_TEST_CASE(test_passive_timeout, "test_passive_timeout", "[initiator]"); + REGISTER_TEST_CASE(test_relay_passive_success, "test_relay_passive_success", "[initiator]"); + REGISTER_TEST_CASE(test_relay_passive_gargabe, "test_relay_passive_gargabe", "[initiator]"); + REGISTER_TEST_CASE(test_relay_passive_wrong_message, "test_relay_passive_wrong_message", "[initiator]"); + REGISTER_TEST_CASE(test_relay_passive_unsuccessful_join, "test_relay_passive_unsuccessful_join", "[initiator]"); + REGISTER_TEST_CASE(test_relay_malformed_uri, "test_relay_malformed_uri", "[initiator]"); + REGISTER_TEST_CASE(test_relay_active_wrong_relay_deviceid, "test_relay_active_wrong_relay_deviceid", "[initiator]"); + REGISTER_TEST_CASE(test_relay_active_success, "test_relay_active_success", "[initiator]"); + REGISTER_TEST_CASE(test_relay_wrong_device, "test_relay_wrong_device", "[initiator]"); + REGISTER_TEST_CASE(test_relay_non_conneteable, "test_relay_non_conneteable", "[initiator]"); + REGISTER_TEST_CASE(test_relay_malformed_address, "test_relay_malformed_address", "[initiator]"); + REGISTER_TEST_CASE(test_relay_garbage_reply, "test_relay_garbage_reply", "[initiator]"); + REGISTER_TEST_CASE(test_relay_noninvitation_reply, "test_relay_noninvitation_reply", "[initiator]"); + + return 1; +} + +static int v = _init(); diff --git a/tests/078-relay.cpp b/tests/078-relay.cpp index 94803960..ee1fb168 100644 --- a/tests/078-relay.cpp +++ b/tests/078-relay.cpp @@ -1,4 +1,6 @@ -#include "catch.hpp" +// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2019-2023 Ivan Baidakou + #include "test-utils.h" #include "access.h" @@ -363,5 +365,11 @@ void test_passive() { F().run(); } -REGISTER_TEST_CASE(test_master_connect, "test_master_connect", "[relay]"); -REGISTER_TEST_CASE(test_passive, "test_passive", "[relay]"); +int _init() { + REGISTER_TEST_CASE(test_master_connect, "test_master_connect", "[relay]"); + REGISTER_TEST_CASE(test_passive, "test_passive", "[relay]"); + + return 1; +} + +static int v = _init(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a5e78d4a..ca685e23 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,5 @@ enable_testing() +include(GenerateExportHeader) find_package( Boost @@ -9,21 +10,27 @@ find_package( REQUIRED ) find_package(OpenSSL REQUIRED) +find_package(Catch2 REQUIRED) if(MINGW) ENABLE_LANGUAGE(RC) endif() -add_library(syncspirit_test_lib STATIC +add_library(syncspirit_test_lib SHARED $<$:win32-resource.rc> test_supervisor.cpp test-db.cpp - test-main.cpp + test-utils.cpp diff-builder.cpp ) -target_link_libraries(syncspirit_test_lib syncspirit_lib) +target_link_libraries(syncspirit_test_lib syncspirit_lib Catch2::Catch2WithMain) target_include_directories(syncspirit_test_lib PUBLIC "${syncspirit_SOURCE_DIR}/src" + "${CMAKE_CURRENT_BINARY_DIR}/include" +) +generate_export_header(syncspirit_test_lib + EXPORT_MACRO_NAME SYNCSPIRIT_TEST_API + EXPORT_FILE_NAME include/syncspirit-test-export.h ) add_custom_command(TARGET syncspirit_test_lib PRE_BUILD diff --git a/tests/catch.hpp b/tests/catch.hpp deleted file mode 100644 index 36eaeb27..00000000 --- a/tests/catch.hpp +++ /dev/null @@ -1,17937 +0,0 @@ -/* - * Catch v2.13.6 - * Generated: 2021-04-16 18:23:38.044268 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2021 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -// start catch.hpp - - -#define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 6 - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// start catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ - // Because REQUIREs trigger GCC's -Wparentheses, and because still - // supported version of g++ have only buggy support for _Pragmas, - // Wparentheses have to be suppressed globally. -# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wpadded" -#endif -// end catch_suppress_warnings.h -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -# define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -# define CATCH_CONFIG_EXTERNAL_INTERFACES -# if defined(CATCH_CONFIG_DISABLE_MATCHERS) -# undef CATCH_CONFIG_DISABLE_MATCHERS -# endif -# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -# endif -#endif - -#if !defined(CATCH_CONFIG_IMPL_ONLY) -// start catch_platform.h - -// See e.g.: -// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html -#ifdef __APPLE__ -# include -# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ - (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) -# define CATCH_PLATFORM_MAC -# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) -# define CATCH_PLATFORM_IPHONE -# endif - -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX - -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) -# define CATCH_PLATFORM_WINDOWS -#endif - -// end catch_platform.h - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// start catch_user_interfaces.h - -namespace Catch { - unsigned int rngSeed(); -} - -// end catch_user_interfaces.h -// start catch_tag_alias_autoregistrar.h - -// start catch_common.h - -// start catch_compiler_capabilities.h - -// Detect a number of compiler features - by compiler -// The following features are defined: -// -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -#ifdef __cplusplus - -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - -# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CATCH_CPP17_OR_GREATER -# endif - -#endif - -// Only GCC compiler should be used in this block, so other compilers trying to -// mask themselves as GCC should be ignored. -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) - -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) - -#endif - -#if defined(__clang__) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) - -// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug -// which results in calls to destructors being emitted for each temporary, -// without a matching initialization. In practice, this can result in something -// like `std::string::~string` being called on an uninitialized value. -// -// For example, this code will likely segfault under IBM XL: -// ``` -// REQUIRE(std::string("12") + "34" == "1234") -// ``` -// -// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. -# if !defined(__ibmxl__) && !defined(__CUDACC__) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ -# endif - -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ - _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) - -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) - #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) - #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#endif - -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Android somehow still does not support std::to_string -#if defined(__ANDROID__) -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING -# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Not all Windows environments support SEH properly -#if defined(__MINGW32__) -# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#endif - -//////////////////////////////////////////////////////////////////////////////// -// PS4 -#if defined(__ORBIS__) -# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE -// some versions of cygwin (most) do not support std::to_string. Use the libstd check. -// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 -# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ - && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) - -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING - -# endif -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#if defined(_MSC_VER) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) - -// Universal Windows platform does not support SEH -// Or console colours (or console at all...) -# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -# define CATCH_CONFIG_COLOUR_NONE -# else -# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH -# endif - -// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ -// _MSVC_TRADITIONAL == 0 means new conformant preprocessor -// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -# if !defined(__clang__) // Handle Clang masquerading for msvc -# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif // MSVC_TRADITIONAL -# endif // __clang__ - -#endif // _MSC_VER - -#if defined(_REENTRANT) || defined(_MSC_VER) -// Enable async processing, as -pthread is specified or no additional linking is required -# define CATCH_INTERNAL_CONFIG_USE_ASYNC -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// Check if we are compiled with -fno-exceptions or equivalent -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) -# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED -#endif - -//////////////////////////////////////////////////////////////////////////////// -// DJGPP -#ifdef __DJGPP__ -# define CATCH_INTERNAL_CONFIG_NO_WCHAR -#endif // __DJGPP__ - -//////////////////////////////////////////////////////////////////////////////// -// Embarcadero C++Build -#if defined(__BORLANDC__) - #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// Use of __COUNTER__ is suppressed during code analysis in -// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly -// handled by it. -// Otherwise all supported compilers support COUNTER macro, -// but user still might want to turn it off -#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// RTX is a special version of Windows that is real time. -// This means that it is detected as Windows, but does not provide -// the same set of capabilities as real Windows does. -#if defined(UNDER_RTSS) || defined(RTX64_BUILD) - #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH - #define CATCH_INTERNAL_CONFIG_NO_ASYNC - #define CATCH_CONFIG_COLOUR_NONE -#endif - -#if !defined(_GLIBCXX_USE_C99_MATH_TR1) -#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Various stdlib support checks that require __has_include -#if defined(__has_include) - // Check if string_view is available and usable - #if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW - #endif - - // Check if optional is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if byte is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # include - # if __cpp_lib_byte > 0 - # define CATCH_INTERNAL_CONFIG_CPP17_BYTE - # endif - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if variant is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # if defined(__clang__) && (__clang_major__ < 8) - // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 - // fix should be in clang 8, workaround in libstdc++ 8.2 - # include - # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # define CATCH_CONFIG_NO_CPP17_VARIANT - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__clang__) && (__clang_major__ < 8) - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // defined(__has_include) - -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif -// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. -#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) -# define CATCH_CONFIG_WCHAR -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) -# define CATCH_CONFIG_CPP11_TO_STRING -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) -# define CATCH_CONFIG_CPP17_OPTIONAL -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) -# define CATCH_CONFIG_CPP17_STRING_VIEW -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) -# define CATCH_CONFIG_CPP17_VARIANT -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) -# define CATCH_CONFIG_CPP17_BYTE -#endif - -#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) -# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) -# define CATCH_CONFIG_NEW_CAPTURE -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -# define CATCH_CONFIG_DISABLE_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) -# define CATCH_CONFIG_POLYFILL_ISNAN -#endif - -#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) -# define CATCH_CONFIG_USE_ASYNC -#endif - -#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) -# define CATCH_CONFIG_ANDROID_LOGWRITE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) -# define CATCH_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Even if we do not think the compiler has that warning, we still have -// to provide a macro that can be used by the code. -#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS -#endif - -// The goal of this macro is to avoid evaluation of the arguments, but -// still have the compiler warn on problems inside... -#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) -#endif - -#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#elif defined(__clang__) && (__clang_major__ < 5) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_TRY if ((true)) -#define CATCH_CATCH_ALL if ((false)) -#define CATCH_CATCH_ANON(type) if ((false)) -#else -#define CATCH_TRY try -#define CATCH_CATCH_ALL catch (...) -#define CATCH_CATCH_ANON(type) catch (type) -#endif - -#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) -#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif - -// end catch_compiler_capabilities.h -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#include -#include -#include - -// We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy {}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); - -namespace Catch { - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; - - protected: - NonCopyable(); - virtual ~NonCopyable(); - }; - - struct SourceLineInfo { - - SourceLineInfo() = delete; - SourceLineInfo( char const* _file, std::size_t _line ) noexcept - : file( _file ), - line( _line ) - {} - - SourceLineInfo( SourceLineInfo const& other ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo( SourceLineInfo&& ) noexcept = default; - SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - - bool empty() const noexcept { return file[0] == '\0'; } - bool operator == ( SourceLineInfo const& other ) const noexcept; - bool operator < ( SourceLineInfo const& other ) const noexcept; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // Bring in operator<< from global namespace into Catch namespace - // This is necessary because the overload of operator<< above makes - // lookup stop at namespace Catch - using ::operator<<; - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() const; - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) - -// end catch_common.h -namespace Catch { - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - -// end catch_tag_alias_autoregistrar.h -// start catch_test_registry.h - -// start catch_interfaces_testcase.h - -#include - -namespace Catch { - - class TestSpec; - - struct ITestInvoker { - virtual void invoke () const = 0; - virtual ~ITestInvoker(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool isThrowSafe( TestCase const& testCase, IConfig const& config ); - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -// end catch_interfaces_testcase.h -// start catch_stringref.h - -#include -#include -#include -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. - class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef( char const* rawChars ) noexcept; - - constexpr StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - explicit operator std::string() const { - return std::string(m_start, m_size); - } - - public: // operators - auto operator == ( StringRef const& other ) const noexcept -> bool; - auto operator != (StringRef const& other) const noexcept -> bool { - return !(*this == other); - } - - auto operator[] ( size_type index ) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - public: // named queries - constexpr auto empty() const noexcept -> bool { - return m_size == 0; - } - constexpr auto size() const noexcept -> size_type { - return m_size; - } - - // Returns the current start pointer. If the StringRef is not - // null-terminated, throws std::domain_exception - auto c_str() const -> char const*; - - public: // substrings and searches - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, size()). - // If start > size(), then the substring is empty. - auto substr( size_type start, size_type length ) const noexcept -> StringRef; - - // Returns the current start pointer. May not be null-terminated. - auto data() const noexcept -> char const*; - - constexpr auto isNullTerminated() const noexcept -> bool { - return m_start[m_size] == '\0'; - } - - public: // iterators - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } - }; - - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; - auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; - - constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } -} // namespace Catch - -constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -// end catch_stringref.h -// start catch_preprocessor.hpp - - -#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ -#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) - -#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ -// MSVC needs more evaluations -#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) -#else -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) -#endif - -#define CATCH_REC_END(...) -#define CATCH_REC_OUT - -#define CATCH_EMPTY() -#define CATCH_DEFER(id) id CATCH_EMPTY() - -#define CATCH_REC_GET_END2() 0, CATCH_REC_END -#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 -#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 -#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT -#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) -#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) - -#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) - -#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) - -// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, -// and passes userdata as the first parameter to each invocation, -// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) -#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) -#else -// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) -#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) -#endif - -#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ -#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) - -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) -#else -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) -#endif - -#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ - CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) - -#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) -#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) -#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) -#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) -#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) -#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) -#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) -#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) -#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) -#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) -#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - -#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N - -#define INTERNAL_CATCH_TYPE_GEN\ - template struct TypeList {};\ - template\ - constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ - template class...> struct TemplateTypeList{};\ - template class...Cs>\ - constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ - template\ - struct append;\ - template\ - struct rewrap;\ - template class, typename...>\ - struct create;\ - template class, typename>\ - struct convert;\ - \ - template \ - struct append { using type = T; };\ - template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ - struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ - template< template class L1, typename...E1, typename...Rest>\ - struct append, TypeList, Rest...> { using type = L1; };\ - \ - template< template class Container, template class List, typename...elems>\ - struct rewrap, List> { using type = TypeList>; };\ - template< template class Container, template class List, class...Elems, typename...Elements>\ - struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ - \ - template