]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Detect and suppress an additional gmtime() warning in test_util.c
authorNick Mathewson <nickm@torproject.org>
Mon, 8 Apr 2019 21:02:14 +0000 (17:02 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 8 Apr 2019 21:02:14 +0000 (17:02 -0400)
Fixes bug 29922; bugfix on 0.2.9.3-alpha when we tried to capture
all these warnings.  No need to backport any farther than 0.3.5,
though -- these warnings don't cause test failures before then.

This one was tricky to find because apparently it only happened on
_some_ windows builds.

changes/bug29922 [new file with mode: 0644]
src/test/test_util.c

diff --git a/changes/bug29922 b/changes/bug29922
new file mode 100644 (file)
index 0000000..dacb951
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes (testing, windows):
+    - Fix a test failure caused by an unexpected bug warning in
+      our test for tor_gmtime_r(-1). Fixes bug 29922;
+      bugfix on 0.2.9.3-alpha.
index 4701fadf1aa032a651dec4893ff61fbf24615765..1b8897a170e2e20a155dd4d8bdd4406f0054ce76 100644 (file)
@@ -699,6 +699,13 @@ test_util_time(void *arg)
 
 #define CHECK_TIMEGM_ARG_OUT_OF_RANGE(msg) \
     CHECK_TIMEGM_WARNING("Out-of-range argument to tor_timegm")
+#define CHECK_POSSIBLE_TIMEGM_ARG_OUT_OF_RANGE(msg)             \
+  do {                                                          \
+    if (mock_saved_log_n_entries()) {                           \
+      expect_single_log_msg_containing("Out-of-range argument");\
+    }                                                           \
+    teardown_capture_of_logs();                                 \
+  } while (0)
 
   /* year */
 
@@ -885,7 +892,9 @@ test_util_time(void *arg)
    * depending on whether the implementation of the system gmtime(_r)
    * sets struct tm (1) or not (1970) */
   t_res = -1;
+  CAPTURE();
   tor_gmtime_r(&t_res, &b_time);
+  CHECK_POSSIBLE_TIMEGM_ARG_OUT_OF_RANGE();
   tt_assert(b_time.tm_year == (1970-1900) ||
             b_time.tm_year == (1969-1900));