summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-10-30 22:47:59 (GMT)
committerGitHub <noreply@github.com>2023-10-30 22:47:59 (GMT)
commit7b153d14ef2e446986148ce7833a00bee26208f1 (patch)
treeb39422e17ffd7428237d5a43047bec50bf212800 /Lib
parent801741ff8155623fe6483971e68f30ff654323bc (diff)
downloadcpython-7b153d14ef2e446986148ce7833a00bee26208f1.zip
cpython-7b153d14ef2e446986148ce7833a00bee26208f1.tar.gz
cpython-7b153d14ef2e446986148ce7833a00bee26208f1.tar.bz2
gh-110697: Use CLOCK_RES in test_os.TimerfdTests (#111529)
More TimerfdTests tests tolerate a difference of 1 ms in measured elapsed time.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_os.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index c23de4d..22e40d9 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -4029,7 +4029,7 @@ class TimerfdTests(unittest.TestCase):
t = time.perf_counter() - t
total_time = initial_expiration + interval * (count - 1)
- self.assertGreater(t, total_time)
+ self.assertGreater(t, total_time - self.CLOCK_RES)
# wait 3.5 time of interval
time.sleep( (count+0.5) * interval)
@@ -4083,7 +4083,7 @@ class TimerfdTests(unittest.TestCase):
t = time.perf_counter() - t
total_time = initial_expiration + interval * (count - 1)
- self.assertGreater(t, total_time)
+ self.assertGreater(t, total_time - self.CLOCK_RES)
def check_timerfd_poll(self, nanoseconds):
fd = self.timerfd_create(time.CLOCK_REALTIME, flags=os.TFD_NONBLOCK)
@@ -4129,10 +4129,10 @@ class TimerfdTests(unittest.TestCase):
total_time = initial_expiration_ns + interval_ns * (count - 1)
if nanoseconds:
dt = time.perf_counter_ns() - t
- self.assertGreater(dt, total_time)
+ self.assertGreater(dt, total_time - self.CLOCK_RES_NS)
else:
dt = time.perf_counter() - t
- self.assertGreater(dt, total_time / sec_to_nsec)
+ self.assertGreater(dt, total_time / sec_to_nsec - self.CLOCK_RES)
selector.unregister(fd)
def test_timerfd_poll(self):
@@ -4189,7 +4189,7 @@ class TimerfdTests(unittest.TestCase):
t = time.perf_counter_ns() - t
total_time_ns = initial_expiration_ns + interval_ns * (count - 1)
- self.assertGreater(t, total_time_ns)
+ self.assertGreater(t, total_time_ns - self.CLOCK_RES_NS)
# wait 3.5 time of interval
time.sleep( (count+0.5) * interval_ns / one_sec_in_nsec)
@@ -4248,7 +4248,7 @@ class TimerfdTests(unittest.TestCase):
t = time.perf_counter_ns() - t
total_time_ns = initial_expiration_ns + interval_ns * (count - 1)
- self.assertGreater(t, total_time_ns)
+ self.assertGreater(t, total_time_ns - self.CLOCK_RES_NS)
class OSErrorTests(unittest.TestCase):
def setUp(self):