]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
test_time.c: Tolerate DST transitions
authorJosh Soref <jsoref@gmail.com>
Sun, 7 Nov 2021 15:32:17 +0000 (10:32 -0500)
committerJoshua Colp <jcolp@sangoma.com>
Tue, 4 Jan 2022 11:55:44 +0000 (05:55 -0600)
When test_timezone_watch runs very near a DST transition,
two time zones that would otherwise be expected to report the same
time can differ because of the DST transition.

Instead of having the test fail when this happens, report the
times, time zones, and dst flags.

ASTERISK-29722

Change-Id: Id59bdac8b277e14343ccdf0c99b89e92f79f316a

tests/test_time.c

index ceb2ae2a5342a74e413b2e6bcec16d16e1be8cee..7c033816a4de54711d14fe5acaf297b7c6aa0fbe 100644 (file)
@@ -91,8 +91,12 @@ AST_TEST_DEFINE(test_timezone_watch)
                        ast_localtime(&tv, &atm[i], tzfile);
                        if (i != 0) {
                                if (atm[i].tm_hour == atm[i - 1].tm_hour) {
-                                       res = AST_TEST_FAIL;
-                                       ast_test_status_update(test, "Failed %s test: %d(%s) = %d(%s)\n", type == 0 ? "deletion" : "symlink", atm[i].tm_hour, zones[i], atm[i-1].tm_hour, zones[i-1]);
+                                       if (atm[i].tm_isdst == atm[i - 1].tm_isdst) {
+                                               res = AST_TEST_FAIL;
+                                               ast_test_status_update(test, "Failed %s test: %d(%s) = %d(%s)\n", type == 0 ? "deletion" : "symlink", atm[i].tm_hour, zones[i], atm[i-1].tm_hour, zones[i-1]);
+                                       } else {
+                                               ast_log(LOG_WARNING, "DST transition during %s test: %d(%s/%d) != %d(%s/%d)\n", type == 0 ? "deletion" : "symlink", atm[i].tm_hour, zones[i], atm[i].tm_isdst, atm[i-1].tm_hour, zones[i-1], atm[i-1].tm_isdst);
+                                       }
                                }
                        }