aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2018-11-23 22:50:55 +0100
committerNick Mathewson <nickm@torproject.org>2018-12-17 16:39:28 -0500
commite3ceaebba25127a1d4a3da16e9128ab52491c080 (patch)
tree4031572e1fe7ff60b4845641a4a3cdc385cbcaed /src/test
parentbfb94dd2ca8e04fb1fe8aba9ad48effbb8b70662 (diff)
downloadtor-e3ceaebba25127a1d4a3da16e9128ab52491c080.tar.gz
tor-e3ceaebba25127a1d4a3da16e9128ab52491c080.zip
Add support for logging messages from pluggable transports.
This patch adds support for the "LOG" protocol message from a pluggable transport. This allows pluggable transport developers to relay log messages from their binary to Tor, which will both emit them as log messages from the Tor process itself, but also pass them on via the control port. See: https://bugs.torproject.org/28180 See: https://bugs.torproject.org/28181 See: https://bugs.torproject.org/28182
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_pt.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/test/test_pt.c b/src/test/test_pt.c
index 2501b867bb..c980276b14 100644
--- a/src/test/test_pt.c
+++ b/src/test/test_pt.c
@@ -304,11 +304,16 @@ process_read_stdout_replacement(process_t *process, buf_t *buffer)
/* Generate some dummy CMETHOD lines the first 5 times. The 6th
time, send 'CMETHODS DONE' to finish configuring the proxy. */
- if (times_called++ != 5) {
+ times_called++;
+
+ if (times_called <= 5) {
buf_add_printf(buffer, "SMETHOD mock%d 127.0.0.1:555%d\n",
times_called, times_called);
- } else {
+ } else if (times_called <= 6) {
buf_add_string(buffer, "SMETHODS DONE\n");
+ } else if (times_called <= 7) {
+ buf_add_string(buffer, "LOG mock3 Oh noes, something bad happened. "
+ "What do we do!?\n");
}
return (int)buf_datalen(buffer);
@@ -410,6 +415,16 @@ test_pt_configure_proxy(void *arg)
tt_str_op(smartlist_get(controlevent_msgs, 4), OP_EQ,
"650 TRANSPORT_LAUNCHED server mock5 127.0.0.1 5555\r\n");
+ /* Get the log message out. */
+ process_notify_event_stdout(mp->process);
+
+ tt_int_op(controlevent_n, OP_EQ, 6);
+ tt_int_op(controlevent_event, OP_EQ, EVENT_TRANSPORT_LOG);
+ tt_int_op(smartlist_len(controlevent_msgs), OP_EQ, 6);
+ tt_str_op(smartlist_get(controlevent_msgs, 5), OP_EQ,
+ "650 TRANSPORT_LOG mock3 Oh noes, something bad happened. "
+ "What do we do!?\r\n");
+
{ /* check that the transport info were saved properly in the tor state */
config_line_t *transport_in_state = NULL;
smartlist_t *transport_info_sl = smartlist_new();