aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_circuitlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-09-08 14:04:55 -0400
committerNick Mathewson <nickm@torproject.org>2016-09-08 14:04:55 -0400
commitd0fe86f39ebcc9b2e17ee3b7fb638e34c2133418 (patch)
tree8019f3d4dc568e3255ac1824a6ac06373373aeb9 /src/test/test_circuitlist.c
parent3269307dafafa8c7c2c3e0be5d5c3cb5e7df3153 (diff)
downloadtor-d0fe86f39ebcc9b2e17ee3b7fb638e34c2133418.tar.gz
tor-d0fe86f39ebcc9b2e17ee3b7fb638e34c2133418.zip
Fix bug warnings in test_circuitlist.
Diffstat (limited to 'src/test/test_circuitlist.c')
-rw-r--r--src/test/test_circuitlist.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/test_circuitlist.c b/src/test/test_circuitlist.c
index 1e640b5709..688515ce5f 100644
--- a/src/test/test_circuitlist.c
+++ b/src/test/test_circuitlist.c
@@ -9,6 +9,7 @@
#include "circuitbuild.h"
#include "circuitlist.h"
#include "test.h"
+#include "log_test_helpers.h"
static channel_t *
new_fake_channel(void)
@@ -270,6 +271,13 @@ test_rend_token_maps(void *arg)
}
static void
+mock_channel_dump_statistics(channel_t *chan, int severity)
+{
+ (void)chan;
+ (void)severity;
+}
+
+static void
test_pick_circid(void *arg)
{
bitarray_t *ba = NULL;
@@ -277,13 +285,25 @@ test_pick_circid(void *arg)
circid_t circid;
int i;
(void) arg;
+ int prev_level = 0;
+
+ MOCK(channel_dump_statistics, mock_channel_dump_statistics);
chan1 = tor_malloc_zero(sizeof(channel_t));
chan2 = tor_malloc_zero(sizeof(channel_t));
chan2->wide_circ_ids = 1;
+ chan1->cmux = circuitmux_alloc();
+ chan2->cmux = circuitmux_alloc();
+
+ /* CIRC_ID_TYPE_NEITHER is supposed to create a warning. */
chan1->circ_id_type = CIRC_ID_TYPE_NEITHER;
+ prev_level = setup_full_capture_of_logs(LOG_WARN);
tt_int_op(0, OP_EQ, get_unique_circ_id_by_chan(chan1));
+ expect_single_log_msg_containing("Trying to pick a circuit ID for a "
+ "connection from a client with no identity.");
+ teardown_capture_of_logs(prev_level);
+ prev_level = 0;
/* Basic tests, with no collisions */
chan1->circ_id_type = CIRC_ID_TYPE_LOWER;
@@ -337,10 +357,17 @@ test_pick_circid(void *arg)
}
done:
+ if (chan1)
+ circuitmux_free(chan1->cmux);
+ if (chan2)
+ circuitmux_free(chan2->cmux);
tor_free(chan1);
tor_free(chan2);
bitarray_free(ba);
circuit_free_all();
+ if (prev_level)
+ teardown_capture_of_logs(prev_level);
+ UNMOCK(channel_dump_statistics);
}
struct testcase_t circuitlist_tests[] = {