Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Konstantin Osipov <kostja@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH 1/5] test: create isolated ev_loop for swim unit tests
Date: Wed, 5 Jun 2019 23:53:05 +0200	[thread overview]
Message-ID: <1b959ddd-ea04-c018-a8a9-cb8dba2b042f@tarantool.org> (raw)
In-Reply-To: <20190605065155.GB28736@atlas>

Hi! Thanks for the review.

On 05/06/2019 09:51, Konstantin Osipov wrote:
> * Vladislav Shpilevoy <v.shpilevoy@tarantool.org> [19/06/03 14:33]:
>> --- a/src/lib/swim/swim_ev.c
>> +++ b/src/lib/swim/swim_ev.c
>> @@ -55,3 +55,9 @@ swim_ev_timer_stop(struct ev_loop *loop, struct ev_timer *watcher)
>>  {
>>  	ev_timer_stop(loop, watcher);
>>  }
>> +
>> +struct ev_loop *
>> +swim_loop(void)
> 
> The comment explaining why you need a separate loop should be
> here, not in the tests, since this is the place most people will
> be looking at and wondering why you need this wrapper at all.
> 
> You could hack this around with a define, but I think your
> approach is more clean, so please just add a comment.
> 

It can't be solved with define, because I need swim.o. I can't
postpone preprocessor work till linking time. Otherwise we could
just implement every function in swim_ev.h and swim_transport.h
as a macros.

The comment is moved and slightly modified.

=======================================================================

diff --git a/src/lib/swim/swim_ev.h b/src/lib/swim/swim_ev.h
index 900be150f..37e743d45 100644
--- a/src/lib/swim/swim_ev.h
+++ b/src/lib/swim/swim_ev.h
@@ -52,6 +52,21 @@ swim_ev_timer_again(struct ev_loop *loop, struct ev_timer *watcher);
 void
 swim_ev_timer_stop(struct ev_loop *loop, struct ev_timer *watcher);
 
+/**
+ * The unit tests code with the fake events and time does lots of
+ * forbidden things: it manually invokes pending watcher
+ * callbacks; manages global time without a kernel; puts not
+ * existing descriptors into the loop. All these actions does not
+ * affect the loop until yield. On yield a scheduler fiber wakes
+ * up and 1) infinitely generates EV_READ on not existing
+ * descriptors because considers them closed; 2) manual pending
+ * callbacks invocation asserts, because it is not allowed for
+ * non-scheduler fibers. To avoid these problems a new isolated
+ * loop is created, not visible for the scheduler. Here the fake
+ * events library can rack and ruin whatever it wants. This
+ * function is supposed to be an alias for 'loop()' in the
+ * Tarantool core, but be an isolated object in tests.
+ */
 struct ev_loop *
 swim_loop(void);
 
diff --git a/test/unit/swim_test_ev.c b/test/unit/swim_test_ev.c
index fb25ac9e4..23d909b05 100644
--- a/test/unit/swim_test_ev.c
+++ b/test/unit/swim_test_ev.c
@@ -63,17 +63,9 @@ typedef void (*swim_event_process_f)(struct swim_event *, struct ev_loop *);
 typedef void (*swim_event_delete_f)(struct swim_event *);
 
 /**
- * The unit tests code with the fake events and time does lots of
- * forbidden things: it manually invokes pending watcher
- * callbacks; manages global time without a kernel; puts not
- * existing descriptors into the loop. All these actions does not
- * affect the loop until yield. On yield a scheduler fiber wakes
- * up and 1) infinitely generates EV_READ on not existing
- * descriptors because considers them closed; 2) manual pending
- * callbacks invocation asserts, because it is not allowed for
- * non-scheduler fibers. To avoid these problems a new isolated
- * loop is created, not visible for the scheduler. Here the fake
- * events library can rack and ruin whatever it wants.
+ * An isolated event loop not visible to the fiber scheduler,
+ * where it is safe to use fake file descriptors, manually invoke
+ * callbacks etc.
  */
 static struct ev_loop *test_loop;
 

  reply	other threads:[~2019-06-05 21:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-02  0:00 [tarantool-patches] [PATCH 0/5] SWIM on_member_update Vladislav Shpilevoy
2019-06-02  0:00 ` [tarantool-patches] [PATCH 1/5] test: create isolated ev_loop for swim unit tests Vladislav Shpilevoy
2019-06-05  6:51   ` [tarantool-patches] " Konstantin Osipov
2019-06-05 21:53     ` Vladislav Shpilevoy [this message]
2019-06-08 14:24       ` Konstantin Osipov
2019-06-02  0:00 ` [tarantool-patches] [PATCH 2/5] swim: fix a 'use after free' in SWIM tests Vladislav Shpilevoy
2019-06-05  6:52   ` [tarantool-patches] " Konstantin Osipov
2019-06-02  0:00 ` [tarantool-patches] [PATCH 3/5] swim: allow to hang triggers on member updates Vladislav Shpilevoy
2019-06-05  7:11   ` [tarantool-patches] " Konstantin Osipov
2019-06-05 21:53     ` Vladislav Shpilevoy
2019-06-07 13:35       ` Konstantin Osipov
2019-06-02  0:00 ` [tarantool-patches] [PATCH 4/5] swim: call swim:new/delete via Lua C, not via FFI Vladislav Shpilevoy
2019-06-08 14:24   ` [tarantool-patches] " Konstantin Osipov
2019-06-02  0:10 ` [tarantool-patches] [PATCH 5/5] swim: expose Lua triggers on member update Vladislav Shpilevoy
2019-06-05 21:54   ` [tarantool-patches] " Vladislav Shpilevoy
2019-06-08 14:29     ` Konstantin Osipov
     [not found] ` <12b8ea76f7c1cd100a80ddcea3c29d20354e073e.1559433539.git.v.shpilevoy@tarantool.org>
2019-06-08 14:27   ` Konstantin Osipov
2019-06-08 19:52     ` Vladislav Shpilevoy
2019-06-09  5:15       ` Konstantin Osipov
2019-06-09 16:41         ` 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=1b959ddd-ea04-c018-a8a9-cb8dba2b042f@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 1/5] test: create isolated ev_loop for swim unit tests' \
    /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