]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge branch 'bug33104_041'
authorNick Mathewson <nickm@torproject.org>
Mon, 10 Feb 2020 19:23:13 +0000 (14:23 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 10 Feb 2020 19:23:13 +0000 (14:23 -0500)
1  2 
src/feature/control/control.c
src/feature/control/control_events.c
src/test/test_controller_events.c

Simple merge
Simple merge
index e9d09fbeefed53306a3498f92fb2abcaac91eba1,5b108ab3171f2bdadc5cabcb9c1e194e84007e0b..60dfbd630ad2c06fa85ba8d63f993e937be00503
  #include "core/or/orconn_event.h"
  #include "core/mainloop/connection.h"
  #include "feature/control/control_events.h"
 +#include "feature/control/control_fmt.h"
  #include "test/test.h"
 +#include "test/test_helpers.h"
+ #include "test/log_test_helpers.h"
  
 +#include "core/or/entry_connection_st.h"
  #include "core/or/or_circuit_st.h"
  #include "core/or/origin_circuit_st.h"
 +#include "core/or/socks_request_st.h"
  
  static void
  add_testing_cell_stats_entry(circuit_t *circ, uint8_t command,
@@@ -398,13 -394,51 +399,50 @@@ test_cntev_dirboot_defer_orconn(void *a
    UNMOCK(queue_control_event_string);
  }
  
+ 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_event_msg_t *msg, uint64_t gid, uint64_t chan,
 +setup_orconn_state(orconn_state_msg_t *msg, uint64_t gid, uint64_t chan,
                     int proxy_type)
  {
 -  msg->type = ORCONN_MSGTYPE_STATE;
 -  msg->u.state.gid = gid;
 -  msg->u.state.chan = chan;
 -  msg->u.state.proxy_type = proxy_type;
 +  msg->gid = gid;
 +  msg->chan = chan;
 +  msg->proxy_type = proxy_type;
  }
  
  static void
@@@ -678,11 -577,11 +716,12 @@@ struct testcase_t controller_event_test
    TEST(append_cell_stats, TT_FORK),
    TEST(format_cell_stats, TT_FORK),
    TEST(event_mask, TT_FORK),
 -  TEST(dirboot_defer_desc, TT_FORK),
 -  TEST(dirboot_defer_orconn, TT_FORK),
 +  TEST(format_stream, TT_FORK),
+   TEST(signal, TT_FORK),
 -  TEST(orconn_state, TT_FORK),
 -  TEST(orconn_state_pt, TT_FORK),
 -  TEST(orconn_state_proxy, TT_FORK),
 +  T_PUBSUB(dirboot_defer_desc, TT_FORK),
 +  T_PUBSUB(dirboot_defer_orconn, TT_FORK),
 +  T_PUBSUB(orconn_state, TT_FORK),
 +  T_PUBSUB(orconn_state_pt, TT_FORK),
 +  T_PUBSUB(orconn_state_proxy, TT_FORK),
    END_OF_TESTCASES
  };