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

[tor-commits] [tor/master] Tolerate another failure mode of get_if_addres6_list in tests



commit 6a1454aa462c7a1ef8d84fe703d4f28e727ca1c0
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Sep 8 11:47:16 2016 -0400

    Tolerate another failure mode of get_if_addres6_list in tests
---
 src/test/log_test_helpers.h |  5 +++++
 src/test/test_address.c     | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/test/log_test_helpers.h b/src/test/log_test_helpers.h
index 5685ddb..bf2f9a6 100644
--- a/src/test/log_test_helpers.h
+++ b/src/test/log_test_helpers.h
@@ -45,6 +45,11 @@ void mock_dump_saved_logs(void);
   assert_log_predicate(mock_saved_log_has_message_containing(str), \
                 "expected log to contain " # str);
 
+#define expect_log_msg_containing_either(str1, str2)                    \
+  assert_log_predicate(mock_saved_log_has_message_containing(str1) ||   \
+                       mock_saved_log_has_message_containing(str2),     \
+                "expected log to contain " # str1 " or " # str2);
+
 #define expect_single_log_msg_containing(str) \
   do {                                                        \
     assert_log_predicate(mock_saved_log_has_message_containing(str), \
diff --git a/src/test/test_address.c b/src/test/test_address.c
index e984bea..932dc38 100644
--- a/src/test/test_address.c
+++ b/src/test/test_address.c
@@ -794,7 +794,16 @@ test_address_get_if_addrs6_list_internal(void *arg)
 
   (void)arg;
 
+  /* We might drop a log_err */
+  int prev_level = setup_full_capture_of_logs(LOG_ERR);
   results = get_interface_address6_list(LOG_ERR, AF_INET6, 1);
+  tt_int_op(smartlist_len(mock_saved_logs()), OP_LE, 1);
+  if (smartlist_len(mock_saved_logs()) == 1) {
+    expect_log_msg_containing_either("connect() failed",
+                                     "unable to create socket");
+
+  }
+  teardown_capture_of_logs(prev_level);
 
   tt_assert(results != NULL);
   /* Work even on systems without IPv6 interfaces */
@@ -828,7 +837,9 @@ test_address_get_if_addrs6_list_no_internal(void *arg)
   results = get_interface_address6_list(LOG_ERR, AF_INET6, 0);
   tt_int_op(smartlist_len(mock_saved_logs()), OP_LE, 1);
   if (smartlist_len(mock_saved_logs()) == 1) {
-    expect_log_msg_containing("connect() failed");
+    expect_log_msg_containing_either("connect() failed",
+                                     "unable to create socket");
+
   }
   teardown_capture_of_logs(prev_level);
 

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