mirror of https://github.com/python/cpython
gh-110697: Use CLOCK_RES in test_os.TimerfdTests (#111529)
More TimerfdTests tests tolerate a difference of 1 ms in measured elapsed time.
This commit is contained in:
parent
801741ff81
commit
7b153d14ef
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue