From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 1536145C309 for ; Tue, 1 Dec 2020 02:56:26 +0300 (MSK) From: Vladislav Shpilevoy Date: Tue, 1 Dec 2020 00:56:13 +0100 Message-Id: <8b5433bba93a2b7c2a9a56629d0f86cffbf59a22.1606780408.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 04/10] test: move fake network code to fakenet.c/.h files List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, sergepetrenko@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)