Skip to content

gh-110697: Use CLOCK_RES in test_os.TimerfdTests #111529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -4029,7 +4029,7 @@ def test_timerfd_interval(self):
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)
Expand Down Expand Up @@ -4083,7 +4083,7 @@ def test_timerfd_select(self):
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)
Expand Down Expand Up @@ -4129,10 +4129,10 @@ def check_timerfd_poll(self, nanoseconds):
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):
Expand Down Expand Up @@ -4189,7 +4189,7 @@ def test_timerfd_ns_interval(self):
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)
Expand Down Expand Up @@ -4248,7 +4248,7 @@ def test_timerfd_ns_select(self):
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):
Expand Down