aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_dir.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-09-08 14:39:20 -0400
committerNick Mathewson <nickm@torproject.org>2016-09-08 14:39:20 -0400
commitb0a9e54705d16d08ae7aff272492832dbb35646d (patch)
tree82064efbdc8c3ed2151c9783cbf6aab44e565df1 /src/test/test_dir.c
parentd0fe86f39ebcc9b2e17ee3b7fb638e34c2133418 (diff)
downloadtor-b0a9e54705d16d08ae7aff272492832dbb35646d.tar.gz
tor-b0a9e54705d16d08ae7aff272492832dbb35646d.zip
Resolve more BUG warnings in the unit tests
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r--src/test/test_dir.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 65b04af779..0afc0b7129 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -36,6 +36,7 @@
#include "test_dir_common.h"
#include "torcert.h"
#include "relay.h"
+#include "log_test_helpers.h"
#define NS_MODULE dir
@@ -3268,6 +3269,8 @@ static void
test_dir_fetch_type(void *arg)
{
(void)arg;
+ int log_level = 0;
+
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_EXTRAINFO, ROUTER_PURPOSE_BRIDGE,
NULL), OP_EQ, EXTRAINFO_DIRINFO | BRIDGE_DIRINFO);
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_EXTRAINFO, ROUTER_PURPOSE_GENERAL,
@@ -3293,9 +3296,15 @@ test_dir_fetch_type(void *arg)
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_MICRODESC, ROUTER_PURPOSE_GENERAL,
NULL), OP_EQ, MICRODESC_DIRINFO);
+ /* This will give a warning, because this function isn't supposed to be
+ * used for HS descriptors. */
+ log_level = setup_full_capture_of_logs(LOG_WARN);
tt_int_op(dir_fetch_type(DIR_PURPOSE_FETCH_RENDDESC_V2,
ROUTER_PURPOSE_GENERAL, NULL), OP_EQ, NO_DIRINFO);
- done: ;
+ expect_single_log_msg_containing("Unexpected purpose");
+ done:
+ if (log_level)
+ teardown_capture_of_logs(log_level);
}
static void
@@ -3963,6 +3972,7 @@ static void
test_dir_conn_purpose_to_string(void *data)
{
(void)data;
+ int log_level = 0;
#define EXPECT_CONN_PURPOSE(purpose, expected) \
tt_str_op(dir_conn_purpose_to_string(purpose), OP_EQ, expected);
@@ -3984,9 +3994,15 @@ test_dir_conn_purpose_to_string(void *data)
EXPECT_CONN_PURPOSE(DIR_PURPOSE_UPLOAD_RENDDESC_V2,
"hidden-service v2 descriptor upload");
EXPECT_CONN_PURPOSE(DIR_PURPOSE_FETCH_MICRODESC, "microdescriptor fetch");
+
+ /* This will give a warning, because there is no purpose 1024. */
+ log_level = setup_full_capture_of_logs(LOG_WARN);
EXPECT_CONN_PURPOSE(1024, "(unknown)");
+ expect_single_log_msg_containing("Called with unknown purpose 1024");
- done: ;
+ done:
+ if (log_level)
+ teardown_capture_of_logs(log_level);
}
NS_DECL(int,