Skip to content

Commit

Permalink
Use monotonic clock for testing timer time
Browse files Browse the repository at this point in the history
  • Loading branch information
sloretz committed Oct 17, 2017
1 parent 14f3bc7 commit c3ab486
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rclpy/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def tearDownClass(cls):
def test_wait_for_service_5sec(self):
cli = self.node.create_client(GetParameters, 'get/parameters')
try:
start = time.time()
start = time.monotonic()
cli.wait_for_service(timeout_sec=5.0)
end = time.time()
end = time.monotonic()
self.assertGreater(5.0, end - start - TIME_FUDGE)
self.assertLess(5.0, end - start + TIME_FUDGE)
finally:
Expand All @@ -48,9 +48,9 @@ def test_wait_for_service_5sec(self):
def test_wait_for_service_nowait(self):
cli = self.node.create_client(GetParameters, 'get/parameters')
try:
start = time.time()
start = time.monotonic()
cli.wait_for_service(timeout_sec=0)
end = time.time()
end = time.monotonic()
self.assertGreater(0, end - start - TIME_FUDGE)
self.assertLess(0, end - start + TIME_FUDGE)
finally:
Expand Down

0 comments on commit c3ab486

Please sign in to comment.