Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org
Subject: [Tarantool-patches] [PATCH 08/10] test: move fake libev code to fakeev.c/.h files
Date: Tue,  1 Dec 2020 00:56:17 +0100	[thread overview]
Message-ID: <30ed4b9bb21f8ade19813cf734324b3ac7e9517a.1606780408.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1606780408.git.v.shpilevoy@tarantool.org>

SWIM unit tests contain a special library for emulating the event
loop: swim_test_ev. It provides API similar to libev, but
implemented entirely in user-space, including clock functions.

The latter is the most important point, as the original libev
does not allow to define your own timing functions - internally it
relies on select/kqueue/epoll/poll/select/... with true clock.

Because of that it is impossible to perform long tests with the
original libev, which could last for minutes or even tens of
seconds if their count is big. swim_test_ev uses virtual time,
where hours can be played in milliseconds.

The fake libev is going to be re-used for Raft unit tests. But for
that it is necessary to detach it from all SWIM dependencies.

--

The patch renames swim_test_ev.c/.h to fakeev.c/.h because they
will contain only fakeev functions soon.

The swim methods, implementing swim_ev.h via fakeev, are moved to
their own file in a separate commit. Because their file will be
swim_test_ev.c. If they would be moved here, git would treat it
like everything *except* swim functions was moved to fakeev.h/.c.
It would ruin git history, and is split in 2 commits to avoid
this.

Part of #5303
---
 test/unit/CMakeLists.txt               | 6 +++---
 test/unit/{swim_test_ev.c => fakeev.c} | 2 +-
 test/unit/{swim_test_ev.h => fakeev.h} | 5 +----
 test/unit/swim_test_utils.c            | 1 -
 test/unit/swim_test_utils.h            | 2 +-
 5 files changed, 6 insertions(+), 10 deletions(-)
 rename test/unit/{swim_test_ev.c => fakeev.c} (99%)
 rename test/unit/{swim_test_ev.h => fakeev.h} (96%)

diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index e6a79e911..436178280 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -240,16 +240,16 @@ 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 swim_test_transport.c fakeev.c
                swim_test_utils.c ${PROJECT_SOURCE_DIR}/src/version.c core_test_utils.c)
 target_link_libraries(swim.test unit fakesys 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 swim_test_transport.c fakeev.c
                swim_test_utils.c ${PROJECT_SOURCE_DIR}/src/version.c core_test_utils.c)
 target_link_libraries(swim_proto.test unit fakesys swim)
 
 add_executable(swim_errinj.test swim_errinj.c swim_test_transport.c
-               swim_test_ev.c swim_test_utils.c
+               fakeev.c swim_test_utils.c
                ${PROJECT_SOURCE_DIR}/src/version.c core_test_utils.c)
 target_link_libraries(swim_errinj.test unit fakesys swim)
 
diff --git a/test/unit/swim_test_ev.c b/test/unit/fakeev.c
similarity index 99%
rename from test/unit/swim_test_ev.c
rename to test/unit/fakeev.c
index 6847836e3..20de35d7f 100644
--- a/test/unit/swim_test_ev.c
+++ b/test/unit/fakeev.c
@@ -28,7 +28,7 @@
  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#include "swim_test_ev.h"
+#include "fakeev.h"
 #include "trivia/util.h"
 #include "swim/swim_ev.h"
 #include "tarantool_ev.h"
diff --git a/test/unit/swim_test_ev.h b/test/unit/fakeev.h
similarity index 96%
rename from test/unit/swim_test_ev.h
rename to test/unit/fakeev.h
index d93b149de..b50fe5b3d 100644
--- a/test/unit/swim_test_ev.h
+++ b/test/unit/fakeev.h
@@ -1,5 +1,4 @@
-#ifndef TARANTOOL_SWIM_TEST_EV_H_INCLUDED
-#define TARANTOOL_SWIM_TEST_EV_H_INCLUDED
+#pragma once
 /*
  * Copyright 2010-2019, Tarantool AUTHORS, please see AUTHORS file.
  *
@@ -110,5 +109,3 @@ fakeev_loop_update(struct ev_loop *loop);
 /** Destroy pending events, reset global watch. */
 void
 fakeev_reset(void);
-
-#endif /* TARANTOOL_SWIM_TEST_EV_H_INCLUDED */
diff --git a/test/unit/swim_test_utils.c b/test/unit/swim_test_utils.c
index c9d92a704..708889460 100644
--- a/test/unit/swim_test_utils.c
+++ b/test/unit/swim_test_utils.c
@@ -29,7 +29,6 @@
  * SUCH DAMAGE.
  */
 #include "swim_test_utils.h"
-#include "swim_test_ev.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 0f0051edd..665423a03 100644
--- a/test/unit/swim_test_utils.h
+++ b/test/unit/swim_test_utils.h
@@ -39,7 +39,7 @@
 #include "swim/swim_ev.h"
 #include "swim/swim_proto.h"
 #include "fakesys/fakenet.h"
-#include "swim_test_ev.h"
+#include "fakeev.h"
 
 struct swim_cluster;
 
-- 
2.24.3 (Apple Git-128)

  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 ` [Tarantool-patches] [PATCH 04/10] test: move fake network code to fakenet.c/.h files Vladislav Shpilevoy
2020-11-30 23:56 ` [Tarantool-patches] [PATCH 05/10] test: factor out swim from " 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 ` Vladislav Shpilevoy [this message]
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=30ed4b9bb21f8ade19813cf734324b3ac7e9517a.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 08/10] test: move fake libev code to fakeev.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