Skip to content

Commit

Permalink
Merge pull request #852 from abdhaleegit/wait-move
Browse files Browse the repository at this point in the history
Move wait_for function to utils
  • Loading branch information
PraveenPenguin authored Jun 25, 2024
2 parents 392e59a + 8866d37 commit 4ca0d5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
15 changes: 15 additions & 0 deletions common/OpTestUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,21 @@ def format_email(self, linux_path , repo):
with open("email.json","w") as email:
json.dump({"subject":subject,"body":body},email)

def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None):
args = args or []
kwargs = kwargs or {}
start_time = time.monotonic()
end_time = start_time + timeout
time.sleep(first)
while time.monotonic() < end_time:
if text:
log.debug("%s (%.9f secs)", text, (time.monotonic() - start_time))
output = func(*args, **kwargs)
if output:
return output
time.sleep(step)
return None


class Server(object):
'''
Expand Down
21 changes: 0 additions & 21 deletions testcases/OpTestKernelTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,6 @@ def setUp(self):
self.fail(
"Provide host ip user details refer, --host-{ip,user,password}")

def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None):
args = args or []
kwargs = kwargs or {}

start_time = time.monotonic()
end_time = start_time + timeout

time.sleep(first)

while time.monotonic() < end_time:
if text:
log.debug("%s (%.9f secs)", text, (time.monotonic() - start_time))

output = func(*args, **kwargs)
if output:
return output

time.sleep(step)

return None

def build_kernel(self):
"""
Build and install the Linux kernel.
Expand Down

0 comments on commit 4ca0d5b

Please sign in to comment.