[tarantool-patches] [PATCH v2 1/2] test: modify swim_run_test to break event loop
Serge Petrenko
sergepetrenko at tarantool.org
Tue Oct 8 18:03:55 MSK 2019
Add a wrapper function around swim test passed to swim_run_test which
breaks from default cord event loop. Otherwise we will hang indefinitely
in ev_run in case there is a started watcher.
Found during work on #2694
---
test/unit/swim_test_utils.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/test/unit/swim_test_utils.c b/test/unit/swim_test_utils.c
index 7da82d93c..46c0386f0 100644
--- a/test/unit/swim_test_utils.c
+++ b/test/unit/swim_test_utils.c
@@ -858,6 +858,17 @@ swim_error_check_match(const char *msg)
return strstr(diag_last_error(diag_get())->errmsg, msg) != NULL;
}
+
+static fiber_func swim_test;
+
+static int
+swim_test_wrapper(va_list ap)
+{
+ int rc = swim_test(ap);
+ ev_break(loop(), EVBREAK_ALL);
+ return rc;
+}
+
void
swim_run_test(const char *log_file, fiber_func test)
{
@@ -876,7 +887,8 @@ swim_run_test(const char *log_file, fiber_func test)
*/
say_info("Random seed = %llu", (unsigned long long) seed);
- struct fiber *main_fiber = fiber_new("main", test);
+ swim_test = test;
+ struct fiber *main_fiber = fiber_new("main", swim_test_wrapper);
fiber_set_joinable(main_fiber, true);
assert(main_fiber != NULL);
fiber_wakeup(main_fiber);
--
2.21.0 (Apple Git-122)
More information about the Tarantool-patches
mailing list