From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org Subject: [Tarantool-patches] [PATCH 04/10] test: move fake network code to fakenet.c/.h files Date: Tue, 1 Dec 2020 00:56:13 +0100 [thread overview] Message-ID: <8b5433bba93a2b7c2a9a56629d0f86cffbf59a22.1606780408.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1606780408.git.v.shpilevoy@tarantool.org> SWIM unit tests contain special libraries for emulating event loop and network: swim_test_ev and swim_test_transport. They provide API similar to libev and to network part of libc, which internally is implemented entirely in user-space and allows to simulate all kinds of errors, any time durations, etc. These test libraries are going to be re-used for Raft unit tests. But for that it is necessary to detach them from all SWIM dependencies. -- This commit moves all fake network code to separate files - fakenet.c/.h, which are now easy to relocate to a new library. These files still contain some swim methods, which are moved to their own file in a separate commit. Because their file will be swim_test_transport.c. But if they would be moved there in the same commit, git would treat it like everything *except* the swim methods was moved to fakenet.c/.h because of names clash. That would destroy git history. So the swim code movement is split in 2 commits. Part of #5303 --- test/unit/CMakeLists.txt | 6 +++--- test/unit/{swim_test_transport.c => fakenet.c} | 2 +- test/unit/{swim_test_transport.h => fakenet.h} | 5 +---- test/unit/swim_test_ev.c | 1 - test/unit/swim_test_utils.c | 1 - test/unit/swim_test_utils.h | 2 +- 6 files changed, 6 insertions(+), 11 deletions(-) rename test/unit/{swim_test_transport.c => fakenet.c} (99%) rename test/unit/{swim_test_transport.h => fakenet.h} (95%) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index e05466473..7c369740e 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -240,15 +240,15 @@ target_link_libraries(sio.test unit core) add_executable(crypto.test crypto.c core_test_utils.c) target_link_libraries(crypto.test crypto unit) -add_executable(swim.test swim.c swim_test_transport.c swim_test_ev.c +add_executable(swim.test swim.c fakenet.c swim_test_ev.c swim_test_utils.c ${PROJECT_SOURCE_DIR}/src/version.c core_test_utils.c) target_link_libraries(swim.test unit swim) -add_executable(swim_proto.test swim_proto.c swim_test_transport.c swim_test_ev.c +add_executable(swim_proto.test swim_proto.c fakenet.c swim_test_ev.c swim_test_utils.c ${PROJECT_SOURCE_DIR}/src/version.c core_test_utils.c) target_link_libraries(swim_proto.test unit swim) -add_executable(swim_errinj.test swim_errinj.c swim_test_transport.c +add_executable(swim_errinj.test swim_errinj.c fakenet.c swim_test_ev.c swim_test_utils.c ${PROJECT_SOURCE_DIR}/src/version.c core_test_utils.c) target_link_libraries(swim_errinj.test unit swim) diff --git a/test/unit/swim_test_transport.c b/test/unit/fakenet.c similarity index 99% rename from test/unit/swim_test_transport.c rename to test/unit/fakenet.c index a259addc9..a8101194a 100644 --- a/test/unit/swim_test_transport.c +++ b/test/unit/fakenet.c @@ -28,7 +28,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include "swim_test_transport.h" +#include "fakenet.h" #include "swim/swim_transport.h" #include "swim/swim_io.h" #include "fiber.h" diff --git a/test/unit/swim_test_transport.h b/test/unit/fakenet.h similarity index 95% rename from test/unit/swim_test_transport.h rename to test/unit/fakenet.h index 1f754de00..043c398ab 100644 --- a/test/unit/swim_test_transport.h +++ b/test/unit/fakenet.h @@ -1,5 +1,4 @@ -#ifndef TARANTOOL_SWIM_TEST_TRANSPORT_H_INCLUDED -#define TARANTOOL_SWIM_TEST_TRANSPORT_H_INCLUDED +#pragma once /* * Copyright 2010-2019, Tarantool AUTHORS, please see AUTHORS file. * @@ -99,5 +98,3 @@ fakenet_init(void); /** Destroy fake network system, free resources. */ void fakenet_free(void); - -#endif /* TARANTOOL_SWIM_TEST_TRANSPORT_H_INCLUDED */ diff --git a/test/unit/swim_test_ev.c b/test/unit/swim_test_ev.c index 23d909b05..625b697d9 100644 --- a/test/unit/swim_test_ev.c +++ b/test/unit/swim_test_ev.c @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ #include "swim_test_ev.h" -#include "swim_test_transport.h" #include "trivia/util.h" #include "swim/swim_ev.h" #include "tarantool_ev.h" diff --git a/test/unit/swim_test_utils.c b/test/unit/swim_test_utils.c index ef35f2134..6a3b6a685 100644 --- a/test/unit/swim_test_utils.c +++ b/test/unit/swim_test_utils.c @@ -30,7 +30,6 @@ */ #include "swim_test_utils.h" #include "swim_test_ev.h" -#include "swim_test_transport.h" #include "swim/swim_ev.h" #include "uuid/tt_uuid.h" #include "trivia/util.h" diff --git a/test/unit/swim_test_utils.h b/test/unit/swim_test_utils.h index ac86b6f72..ba1749a7e 100644 --- a/test/unit/swim_test_utils.h +++ b/test/unit/swim_test_utils.h @@ -38,7 +38,7 @@ #include "swim/swim.h" #include "swim/swim_ev.h" #include "swim/swim_proto.h" -#include "swim_test_transport.h" +#include "fakenet.h" #include "swim_test_ev.h" struct swim_cluster; -- 2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2020-11-30 23:56 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-30 23:56 [Tarantool-patches] [PATCH 00/10] Raft module, part 3 - fake network and libev for Raft and SWIM Vladislav Shpilevoy 2020-11-30 23:56 ` [Tarantool-patches] [PATCH 01/10] test: stop using swim_transport.addr as in-param Vladislav Shpilevoy 2020-11-30 23:56 ` [Tarantool-patches] [PATCH 10/10] fakesys: move fakeev to fakesys library Vladislav Shpilevoy 2020-11-30 23:56 ` [Tarantool-patches] [PATCH 02/10] test: factor out swim from libc emulation funcs Vladislav Shpilevoy 2020-11-30 23:56 ` [Tarantool-patches] [PATCH 03/10] test: rename fake libc network methods to fakenet Vladislav Shpilevoy 2020-11-30 23:56 ` Vladislav Shpilevoy [this message] 2020-11-30 23:56 ` [Tarantool-patches] [PATCH 05/10] test: factor out swim from fakenet.c/.h files Vladislav Shpilevoy 2020-11-30 23:56 ` [Tarantool-patches] [PATCH 06/10] fakesys: introduce fake system library Vladislav Shpilevoy 2020-11-30 23:56 ` [Tarantool-patches] [PATCH 07/10] test: rename fake libev methods to fakeev Vladislav Shpilevoy 2020-11-30 23:56 ` [Tarantool-patches] [PATCH 08/10] test: move fake libev code to fakeev.c/.h files Vladislav Shpilevoy 2020-11-30 23:56 ` [Tarantool-patches] [PATCH 09/10] test: factor out swim from fakeev.h/.c files Vladislav Shpilevoy 2020-12-01 13:42 ` [Tarantool-patches] [PATCH 00/10] Raft module, part 3 - fake network and libev for Raft and SWIM Serge Petrenko 2020-12-01 22:33 ` Vladislav Shpilevoy 2020-12-04 0:35 ` Alexander V. Tikhonov 2020-12-04 22:53 ` Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=8b5433bba93a2b7c2a9a56629d0f86cffbf59a22.1606780408.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=sergepetrenko@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 04/10] test: move fake network code to fakenet.c/.h files' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox