diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-06-29 13:53:27 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-06-29 13:53:27 -0400 |
commit | a692b87f82152c01a9991f11a60f36d3b6f1bddd (patch) | |
tree | 78f112525d57fbad203605532b59d5f70d2fecc5 /src/test | |
parent | 0575a182a633429e755dc4366eced76656461d9b (diff) | |
parent | b2c3cb1b26c41969776ed1fd1b20588430346e45 (diff) | |
download | tor-a692b87f82152c01a9991f11a60f36d3b6f1bddd.tar.gz tor-a692b87f82152c01a9991f11a60f36d3b6f1bddd.zip |
Merge remote-tracking branch 'tor-github/pr/1696/head' into maint-0.4.2
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_controller_events.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/test_controller_events.c b/src/test/test_controller_events.c index 9fb2bc7256..0d276ef8a6 100644 --- a/src/test/test_controller_events.c +++ b/src/test/test_controller_events.c @@ -18,6 +18,7 @@ #include "feature/control/control_events.h" #include "test/test.h" #include "test/test_helpers.h" +#include "test/log_test_helpers.h" #include "core/or/or_circuit_st.h" #include "core/or/origin_circuit_st.h" @@ -396,6 +397,43 @@ test_cntev_dirboot_defer_orconn(void *arg) } static void +test_cntev_signal(void *arg) +{ + (void)arg; + int rv; + + MOCK(queue_control_event_string, mock_queue_control_event_string); + + /* Nothing is listening for signals, so no event should be queued. */ + rv = control_event_signal(SIGHUP); + tt_int_op(0, OP_EQ, rv); + tt_ptr_op(saved_event_str, OP_EQ, NULL); + + /* Now try with signals included in the event mask. */ + control_testing_set_global_event_mask(EVENT_MASK_(EVENT_GOT_SIGNAL)); + rv = control_event_signal(SIGHUP); + tt_int_op(0, OP_EQ, rv); + tt_str_op(saved_event_str, OP_EQ, "650 SIGNAL RELOAD\r\n"); + + rv = control_event_signal(SIGACTIVE); + tt_int_op(0, OP_EQ, rv); + tt_str_op(saved_event_str, OP_EQ, "650 SIGNAL ACTIVE\r\n"); + + /* Try a signal that doesn't exist. */ + setup_full_capture_of_logs(LOG_WARN); + tor_free(saved_event_str); + rv = control_event_signal(99999); + tt_int_op(-1, OP_EQ, rv); + tt_ptr_op(saved_event_str, OP_EQ, NULL); + expect_single_log_msg_containing("Unrecognized signal 99999"); + + done: + tor_free(saved_event_str); + teardown_capture_of_logs(); + UNMOCK(queue_control_event_string); +} + +static void setup_orconn_state(orconn_state_msg_t *msg, uint64_t gid, uint64_t chan, int proxy_type) { @@ -550,6 +588,7 @@ struct testcase_t controller_event_tests[] = { TEST(event_mask, TT_FORK), T_PUBSUB(dirboot_defer_desc, TT_FORK), T_PUBSUB(dirboot_defer_orconn, TT_FORK), + T_PUBSUB(signal, TT_FORK), T_PUBSUB(orconn_state, TT_FORK), T_PUBSUB(orconn_state_pt, TT_FORK), T_PUBSUB(orconn_state_proxy, TT_FORK), |