From e8286d4fd34d71f72c221db69840cda2daf76c84 Mon Sep 17 00:00:00 2001 From: Kameron Carr Date: Sat, 2 Mar 2024 17:26:45 -0800 Subject: [PATCH] verify_timedrift_corrected: Leap year Creating a time stamp with year `current_year - 2` will fail on Feb 29 because there is no Feb 29 for two years ago. This test case only requires the time difference to be significantly larger than 5 minutes. --- microsoft/testsuites/core/timesync.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/microsoft/testsuites/core/timesync.py b/microsoft/testsuites/core/timesync.py index f5e79af248..828cd0316d 100644 --- a/microsoft/testsuites/core/timesync.py +++ b/microsoft/testsuites/core/timesync.py @@ -1,5 +1,6 @@ import time from copy import deepcopy +from datetime import timedelta from pathlib import PurePosixPath from time import sleep from typing import List, Optional, Union, cast @@ -418,7 +419,7 @@ def verify_timedrift_corrected(self, node: Node, log: Logger) -> None: date = node.tools[Date] node_time = date.current() modified_time = deepcopy(node_time) - modified_time = modified_time.replace(year=node_time.year - 2) + modified_time = modified_time - timedelta(days=2) date.set(modified_time) # Poll every second and check if the time drift is corrected