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

[tor-commits] [tor/master] Stop log_heartbeat test from failing in timezones with non-integer offsets



commit 9e5a6f02937912fbb2a1582aae99186310192fa1
Author: Fergus Dall <fergus@xxxxxxxxxxxxxxxxxxxxx>
Date:   Tue Jan 12 18:09:16 2016 +1030

    Stop log_heartbeat test from failing in timezones with non-integer offsets
    
    Instead of comparing the end of the time string against a constant,
    compare it to the output of format_local_iso_time when given the
    correct input.
---
 changes/log_heartbeat_test |    5 +++++
 src/test/test_status.c     |    8 +++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/changes/log_heartbeat_test b/changes/log_heartbeat_test
new file mode 100644
index 0000000..f0d143b
--- /dev/null
+++ b/changes/log_heartbeat_test
@@ -0,0 +1,5 @@
+  o Minor bugfix (testing):
+    - The test for log_heartbeat was incorrectly failing in timezones
+      with non-integer offsets. Instead of comparing the end of the
+      time string against a constant, compare it to the output of
+      format_local_iso_time when given the correct input.
diff --git a/src/test/test_status.c b/src/test/test_status.c
index 57d69b1..84a0f6c 100644
--- a/src/test/test_status.c
+++ b/src/test/test_status.c
@@ -714,9 +714,11 @@ NS(logv)(int severity, log_domain_mask_t domain,
       tt_str_op(va_arg(ap, char *), OP_EQ, "0 kB");  /* acc_used */
       tt_str_op(va_arg(ap, char *), OP_EQ, "0 kB");  /* acc_max */
       tt_str_op(va_arg(ap, char *), OP_EQ, "max");  /* acc_rule */
-      /* format_local_iso_time uses local tz, just check mins and secs. */
-      tt_ptr_op(strstr(va_arg(ap, char *), ":01:00"),
-                OP_NE, NULL); /* end_buf */
+      /* format_local_iso_time uses local tz, so we can't just compare
+       * the string against a constant */
+      char datetime[ISO_TIME_LEN+1];
+      format_local_iso_time(datetime, 60);
+      tt_str_op(va_arg(ap, char *), OP_EQ, datetime); /* end_buf */
       tt_str_op(va_arg(ap, char *), OP_EQ, "0:01 hours");   /* remaining */
       break;
     case 2:



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