[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Fix endianness issues in test_config_resolve_my_address().



commit 385558c32f666456ed10ed9dce3f4009437b015d
Author: rl1987 <rl1987@xxxxxxxxxxxxxxxx>
Date:   Sun Feb 22 12:41:08 2015 +0200

    Fix endianness issues in test_config_resolve_my_address().
    
    Since resolve_my_address() yields IP address in host order there is
    no need to use byteorder functions for conversion.
---
 changes/bug14980       |    4 ++++
 src/test/test_config.c |   10 +++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/changes/bug14980 b/changes/bug14980
new file mode 100644
index 0000000..4676730
--- /dev/null
+++ b/changes/bug14980
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - Fix endianness issues in unit test for resolve_my_address() to
+      have it pass on big endian systems. Resolves issue 14980; bugfix on
+      Tor 0.2.6.3-alpha.
diff --git a/src/test/test_config.c b/src/test/test_config.c
index b63b78e..0444062 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -1092,7 +1092,7 @@ test_config_resolve_my_address(void *arg)
   tt_want(retval == 0);
   tt_want_str_op(method_used,==,"CONFIGURED");
   tt_want(hostname_out == NULL);
-  tt_assert(htonl(resolved_addr) == 0x69803480);
+  tt_assert(resolved_addr == 0x80348069);
 
   tor_free(options->Address);
 
@@ -1117,7 +1117,7 @@ test_config_resolve_my_address(void *arg)
   tt_want(n_hostname_01010101 == prev_n_hostname_01010101 + 1);
   tt_want_str_op(method_used,==,"RESOLVED");
   tt_want_str_op(hostname_out,==,"www.torproject.org");
-  tt_assert(htonl(resolved_addr) == 0x01010101);
+  tt_assert(resolved_addr == 0x01010101);
 
   UNMOCK(tor_lookup_hostname);
 
@@ -1149,7 +1149,7 @@ test_config_resolve_my_address(void *arg)
   tt_want(n_hostname_01010101 == prev_n_hostname_01010101 + 1);
   tt_want_str_op(method_used,==,"GETHOSTNAME");
   tt_want_str_op(hostname_out,==,"onionrouter!");
-  tt_assert(htonl(resolved_addr) == 0x01010101);
+  tt_assert(resolved_addr == 0x01010101);
 
   UNMOCK(tor_gethostname);
   UNMOCK(tor_lookup_hostname);
@@ -1242,7 +1242,7 @@ test_config_resolve_my_address(void *arg)
                  prev_n_get_interface_address + 1);
   tt_want_str_op(method_used,==,"INTERFACE");
   tt_want(hostname_out == NULL);
-  tt_assert(resolved_addr == ntohl(0x08080808));
+  tt_assert(resolved_addr == 0x08080808);
 
   UNMOCK(get_interface_address);
   tor_free(hostname_out);
@@ -1297,7 +1297,7 @@ test_config_resolve_my_address(void *arg)
   tt_want(n_gethostname_replacement == prev_n_gethostname_replacement + 1);
   tt_want(retval == 0);
   tt_want_str_op(method_used,==,"INTERFACE");
-  tt_assert(htonl(resolved_addr) == 0x09090909);
+  tt_assert(resolved_addr == 0x09090909);
 
   UNMOCK(tor_lookup_hostname);
   UNMOCK(tor_gethostname);

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits