[tor-commits] [tor/master] Third test case for dns_resolve_impl.

nickm at torproject.org nickm at torproject.org
Fri Oct 30 14:07:17 UTC 2015


commit 787a27be3e27d11d873352a8eb14e068ed3fdad5
Author: rl1987 <rl1987 at sdf.lonestar.org>
Date:   Sat Oct 10 17:49:24 2015 +0300

    Third test case for dns_resolve_impl.
---
 src/test/test_dns.c |   30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/test/test_dns.c b/src/test/test_dns.c
index 88a2f4a..aeabdf6 100644
--- a/src/test/test_dns.c
+++ b/src/test/test_dns.c
@@ -422,12 +422,40 @@ NS(test_main)(void *arg)
 
 #define NS_SUBMODULE ASPECT(resolve_impl, addr_is_invalid_dest)
 
+/** Given that address is not a valid destination (as judged by
+ * address_is_invalid_destination() function), we want dns_resolve_impl()
+ * function to fail with return value -1.
+ */
+
+static int
+NS(router_my_exit_policy_is_reject_star)(void)
+{
+  return 0;
+}
+
 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));
+
+  NS_MOCK(router_my_exit_policy_is_reject_star);
+
+  TO_CONN(exitconn)->address = tor_strdup("invalid#@!.org");
+
+  retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
+                            NULL);
+
+  tt_int_op(retval,==,-1);
 
   done:
+  NS_UNMOCK(router_my_exit_policy_is_reject_star);
+  tor_free(TO_CONN(exitconn)->address);
+  tor_free(exitconn);
+  tor_free(on_circ);
   return;
 }
 





More information about the tor-commits mailing list