]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Capture "Result does not fit in tor_timegm()" warnings in util tests
authorNick Mathewson <nickm@torproject.org>
Thu, 21 Sep 2017 19:32:16 +0000 (15:32 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 21 Sep 2017 19:32:16 +0000 (15:32 -0400)
Fixes bug 21800; bugfix on 0.2.9.x

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

diff --git a/changes/bug21800 b/changes/bug21800
new file mode 100644 (file)
index 0000000..53c20c0
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes (testing):
+    - Capture and detect several "Result does not fit" warnings
+      in unit tests on platforms with 32-bit time_t. Fixes bug 21800;
+      bugfix on 0.2.9.3-alpha.
index db629bcb6b02b80a1036b4a68d5c2b5d52f026a7..35fd02b1e921ab9212d7308da1f5efbe6b72f1d7 100644 (file)
@@ -635,7 +635,10 @@ test_util_time(void *arg)
    * time_t */
   a_time.tm_year = 2039-1900;
 #if SIZEOF_TIME_T == 4
+  setup_capture_of_logs(LOG_WARN);
   tt_int_op((time_t) -1,OP_EQ, tor_timegm(&a_time));
+  expect_single_log_msg_containing("Result does not fit in tor_timegm");
+  teardown_capture_of_logs();
 #elif SIZEOF_TIME_T == 8
   t_res = 2178252895UL;
   tt_int_op(t_res, OP_EQ, tor_timegm(&a_time));
@@ -965,7 +968,9 @@ test_util_time(void *arg)
   strlcpy(timestr, "Wed, 17 Feb 2038 06:13:20 GMT", sizeof(timestr));
 
   t_res = 0;
+  CAPTURE();
   i = parse_rfc1123_time(timestr, &t_res);
+  CHECK_TIMEGM_WARNING("does not fit in tor_timegm");
   tt_int_op(-1,OP_EQ, i);
 #elif SIZEOF_TIME_T == 8
   tt_str_op("Wed, 17 Feb 2038 06:13:20 GMT",OP_EQ, timestr);
@@ -1042,7 +1047,9 @@ test_util_time(void *arg)
   t_res = 0;
   i = parse_iso_time("2038-02-17 06:13:20", &t_res);
 #if SIZEOF_TIME_T == 4
+  CAPTURE();
   tt_int_op(-1,OP_EQ, i);
+  CHECK_TIMEGM_WARNING("does not fit in tor_timegm");
 #elif SIZEOF_TIME_T == 8
   tt_int_op(0,OP_EQ, i);
   tt_int_op(t_res,OP_EQ, (time_t)2150000000UL);
@@ -1218,8 +1225,11 @@ test_util_parse_http_time(void *arg)
 #if SIZEOF_TIME_T == 4
   /* parse_http_time should indicate failure on overflow, but it doesn't yet.
    * Hopefully #18480 will improve the failure semantics in this case. */
+  setup_capture_of_logs(LOG_WARN);
   tt_int_op(0,OP_EQ,parse_http_time("Wed, 17 Feb 2038 06:13:20 GMT", &a_time));
   tt_int_op((time_t)-1,OP_EQ, tor_timegm(&a_time));
+  expect_single_log_msg_containing("does not fit in tor_timegm");
+  teardown_capture_of_logs();
 #elif SIZEOF_TIME_T == 8
   tt_int_op(0,OP_EQ,parse_http_time("Wed, 17 Feb 2038 06:13:20 GMT", &a_time));
   tt_int_op((time_t)2150000000UL,OP_EQ, tor_timegm(&a_time));
@@ -1237,7 +1247,7 @@ test_util_parse_http_time(void *arg)
 
 #undef T
  done:
-  ;
+  teardown_capture_of_logs();
 }
 
 static void