summaryrefslogtreecommitdiff
path: root/src/test/test_dns.c
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2015-10-08 21:47:52 +0300
committerrl1987 <rl1987@sdf.lonestar.org>2015-10-24 14:30:50 +0300
commit1096f7638e883f9a6dfc86b9804090f090afb68f (patch)
treeb2a14e29e16ae358c4aae1555c443c887d1d7d93 /src/test/test_dns.c
parent2fc841aacbfdb0e824ab3bed9e06db8d9c793747 (diff)
downloadtor-1096f7638e883f9a6dfc86b9804090f090afb68f.tar.gz
tor-1096f7638e883f9a6dfc86b9804090f090afb68f.zip
A second test case for dns_resolve_impl.
Diffstat (limited to 'src/test/test_dns.c')
-rw-r--r--src/test/test_dns.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/test/test_dns.c b/src/test/test_dns.c
index f1b11a88e8..88a2f4a74b 100644
--- a/src/test/test_dns.c
+++ b/src/test/test_dns.c
@@ -5,6 +5,7 @@
#include "dns.h"
#include "connection.h"
+#include "router.h"
#define NS_MODULE dns
@@ -382,12 +383,38 @@ NS(test_main)(void *arg)
#define NS_SUBMODULE ASPECT(resolve_impl, non_exit)
+/** Given that Tor instance is not configured as an exit node, we want
+ * dns_resolve_impl() to fail with return value -1.
+ */
+static int
+NS(router_my_exit_policy_is_reject_star)(void)
+{
+ return 1;
+}
+
static void
NS(test_main)(void *arg)
{
- tt_skip();
+ int retval;
+ int made_pending;
+
+ edge_connection_t *exitconn = create_valid_exitconn();
+ or_circuit_t *on_circ = tor_malloc_zero(sizeof(or_circuit_t));
+
+ TO_CONN(exitconn)->address = tor_strdup("torproject.org");
+
+ NS_MOCK(router_my_exit_policy_is_reject_star);
+
+ retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
+ NULL);
+
+ tt_int_op(retval,==,-1);
done:
+ tor_free(TO_CONN(exitconn)->address);
+ tor_free(exitconn);
+ tor_free(on_circ);
+ NS_UNMOCK(router_my_exit_policy_is_reject_star);
return;
}