[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Use run_main_loop_until_done() for process_t tests.
commit bc6983afed24c0b83a49d2cef531dcc036245a04
Author: Alexander Færøy <ahf@xxxxxxxxxxxxxx>
Date: Wed Nov 28 18:10:02 2018 +0100
Use run_main_loop_until_done() for process_t tests.
This patch changes the slow process_t tests to use
run_main_loop_until_done() instead of do_main_loop() since
do_main_loop() initializes a lot of subsystem callbacks that we don't
need to run in our tests.
See: https://bugs.torproject.org/28179
---
src/core/mainloop/mainloop.c | 11 +++++------
src/core/mainloop/mainloop.h | 1 +
src/test/test_process_slow.c | 3 ++-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/core/mainloop/mainloop.c b/src/core/mainloop/mainloop.c
index aaaa5009c..9e58448f3 100644
--- a/src/core/mainloop/mainloop.c
+++ b/src/core/mainloop/mainloop.c
@@ -200,7 +200,6 @@ static int can_complete_circuits = 0;
#define LAZY_DESCRIPTOR_RETRY_INTERVAL (60)
static int conn_close_if_marked(int i);
-static int run_main_loop_until_done(void);
static void connection_start_reading_from_linked_conn(connection_t *conn);
static int connection_should_read_from_linked_conn(connection_t *conn);
static void conn_read_callback(evutil_socket_t fd, short event, void *_conn);
@@ -2847,10 +2846,6 @@ do_main_loop(void)
}
}
#endif /* defined(HAVE_SYSTEMD_209) */
-
- main_loop_should_exit = 0;
- main_loop_exit_value = 0;
-
#ifdef ENABLE_RESTART_DEBUGGING
{
static int first_time = 1;
@@ -2976,10 +2971,14 @@ run_main_loop_once(void)
*
* Shadow won't invoke this function, so don't fill it up with things.
*/
-static int
+STATIC int
run_main_loop_until_done(void)
{
int loop_result = 1;
+
+ main_loop_should_exit = 0;
+ main_loop_exit_value = 0;
+
do {
loop_result = run_main_loop_once();
} while (loop_result == 1);
diff --git a/src/core/mainloop/mainloop.h b/src/core/mainloop/mainloop.h
index 14e80ebb2..730234857 100644
--- a/src/core/mainloop/mainloop.h
+++ b/src/core/mainloop/mainloop.h
@@ -100,6 +100,7 @@ extern struct token_bucket_rw_t global_bucket;
extern struct token_bucket_rw_t global_relayed_bucket;
#ifdef MAINLOOP_PRIVATE
+STATIC int run_main_loop_until_done(void);
STATIC void close_closeable_connections(void);
STATIC void initialize_periodic_events(void);
STATIC void teardown_periodic_events(void);
diff --git a/src/test/test_process_slow.c b/src/test/test_process_slow.c
index 2ec9ff28a..ad84127bb 100644
--- a/src/test/test_process_slow.c
+++ b/src/test/test_process_slow.c
@@ -6,6 +6,7 @@
* \brief Slow test cases for the Process API.
*/
+#define MAINLOOP_PRIVATE
#include "orconfig.h"
#include "core/or/or.h"
#include "core/mainloop/mainloop.h"
@@ -168,7 +169,7 @@ run_main_loop(void)
NULL);
/* Run our main loop. */
- ret = do_main_loop();
+ ret = run_main_loop_until_done();
/* Clean up our main loop timeout timer. */
tt_int_op(ret, OP_EQ, 0);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits